:root {
    color-scheme: light;
    --bg: #f3f8ff;
    --panel: #ffffff;
    --panel-soft: #f7fbff;
    --text: #061f45;
    --muted: #516781;
    --border: #bad4f7;
    --primary: #0038a8;
    --primary-dark: #002b7f;
    --primary-soft: #eaf3ff;
    --flag-blue: #0038a8;
    --danger: #c93637;
    --warning: #b85c00;
    --success: #087443;
    --shadow: 0 22px 60px rgba(0, 56, 168, .18);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-height: 100%;
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: Arial, "Noto Sans Hebrew", "Segoe UI", sans-serif;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(243, 248, 255, .98)),
        var(--bg);
}

body.sidebar-open {
    overflow: hidden;
}

body.auth-mode {
    background: #f7fbff;
    overflow-x: hidden;
}

body.auth-mode::before {
    position: fixed;
    inset: 0;
    z-index: 0;
    content: "";
    pointer-events: none;
    background:
        linear-gradient(180deg, transparent 0 10%, rgba(0, 56, 168, .18) 10% 15%, transparent 15% 85%, rgba(0, 56, 168, .18) 85% 90%, transparent 90%),
        linear-gradient(116deg, transparent 0 35%, rgba(0, 56, 168, .08) 35% 38%, transparent 38% 62%, rgba(0, 56, 168, .07) 62% 65%, transparent 65%),
        repeating-linear-gradient(90deg, rgba(0, 56, 168, .045) 0 1px, transparent 1px 34px),
        linear-gradient(180deg, #ffffff 0%, #edf6ff 100%);
    background-size: 100% 100%, 260px 100%, 90px 100%, 100% 100%;
    animation: flagDrift 22s linear infinite;
}

body.auth-mode::after {
    position: fixed;
    inset: auto 50% 50% auto;
    z-index: 0;
    content: "✡";
    pointer-events: none;
    color: rgba(0, 56, 168, .075);
    font-size: min(42vw, 290px);
    font-weight: 400;
    line-height: 1;
    transform: translate(50%, 50%);
    animation: starPulse 7s ease-in-out infinite;
}

@keyframes flagDrift {
    from {
        background-position: 0 0, 0 0, 0 0, 0 0;
    }
    to {
        background-position: 0 0, 260px 0, 90px 0, 0 0;
    }
}

@keyframes starPulse {
    0%,
    100% {
        opacity: .65;
        transform: translate(50%, 50%) scale(.98);
    }

    50% {
        opacity: 1;
        transform: translate(50%, 50%) scale(1.03);
    }
}

button,
input,
select,
textarea {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    margin-top: 7px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 56, 168, .14);
}

label {
    display: block;
    color: #344054;
    font-size: 14px;
    font-weight: 700;
}

.login-shell {
    position: relative;
    z-index: 1;
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-card {
    position: relative;
    z-index: 1;
    overflow: hidden;
    width: min(440px, 100%);
    padding: 30px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(255, 255, 255, .94)),
        #fff;
    border: 1px solid rgba(0, 56, 168, .22);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.login-card::before {
    position: absolute;
    inset: 0 0 auto;
    height: 8px;
    content: "";
    background: linear-gradient(90deg, var(--flag-blue), #ffffff 42% 58%, var(--flag-blue));
}

.login-card h1 {
    margin: 14px 0 8px;
    color: var(--primary-dark);
    font-size: 27px;
    letter-spacing: 0;
}

.login-card p {
    margin: 0 0 18px;
    color: var(--muted);
}

.login-card label {
    margin-top: 14px;
}

.login-mark,
.brand-logo {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    color: #fff;
    font-weight: 800;
    background:
        linear-gradient(180deg, #ffffff 0 18%, var(--flag-blue) 18% 82%, #ffffff 82% 100%);
    border: 1px solid rgba(0, 56, 168, .18);
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(0, 56, 168, .16);
}

.sidebar-close {
    display: none;
}

.admin-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 280px 1fr;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(239, 247, 255, .96)),
        var(--bg);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px;
    color: #f9fafb;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .13) 0 6px, transparent 6px calc(100% - 6px), rgba(255, 255, 255, .13) calc(100% - 6px)),
        linear-gradient(180deg, #002b7f 0%, #0038a8 54%, #0056c7 100%);
    border-left: 1px solid rgba(0, 56, 168, .22);
    box-shadow: inset 0 6px 0 #ffffff, inset 0 -6px 0 #ffffff;
}

.brand {
    position: relative;
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
}

.brand-logo {
    width: 46px;
    height: 46px;
    background: #ffffff;
    color: var(--primary);
}

.brand strong,
.admin-profile strong {
    display: block;
}

.brand span,
.admin-profile span {
    display: block;
    margin-top: 3px;
    color: rgba(255, 255, 255, .78);
    font-size: 13px;
}

.admin-profile {
    padding: 14px;
    margin-bottom: 18px;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 8px;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav button {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    color: #ffffff;
    cursor: pointer;
    background: transparent;
    border: 0;
    border-radius: 8px;
    text-align: right;
}

.nav button.active,
.nav button:hover {
    color: #003f8f;
    background: #ffffff;
}

.main {
    min-width: 0;
    padding: 24px;
}

.topbar {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 16px 18px;
    background: rgba(255, 255, 255, .82);
    border: 1px solid rgba(0, 56, 168, .12);
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(0, 56, 168, .08);
    backdrop-filter: blur(10px);
}

.topbar div {
    flex: 1;
}

.topbar h1 {
    margin: 0;
    font-size: clamp(24px, 3vw, 34px);
}

.topbar p {
    margin: 5px 0 0;
    color: var(--muted);
}

.content {
    display: grid;
    gap: 16px;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
    position: relative;
    min-width: 0;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 56, 168, .08);
}

.card::before {
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    content: "";
    background: linear-gradient(90deg, var(--flag-blue), rgba(0, 56, 168, .18));
    border-radius: 8px 8px 0 0;
}

.card h2 {
    margin: 0 0 14px;
    font-size: 19px;
}

.card h3 {
    margin: 18px 0 8px;
    font-size: 16px;
}

.container-card {
    display: grid;
    align-content: start;
    gap: 10px;
}

.stat {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid #eef2f7;
}

.stat:last-child {
    border-bottom: 0;
}

.stat span {
    max-width: 60%;
    overflow-wrap: anywhere;
    text-align: left;
    direction: ltr;
}

.row,
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.toolbar {
    justify-content: flex-start;
}

.actions {
    margin-top: 8px;
}

.button,
.icon-button {
    min-height: 40px;
    padding: 9px 14px;
    color: var(--text);
    cursor: pointer;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    touch-action: manipulation;
    transition: transform .12s ease, background .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.button:hover,
.icon-button:hover {
    transform: translateY(-1px);
}

.button:disabled {
    cursor: not-allowed;
    opacity: .5;
    transform: none;
}

.button.primary {
    color: #fff;
    background: linear-gradient(180deg, #0750c9, var(--primary));
    border-color: var(--primary);
    box-shadow: 0 8px 18px rgba(0, 56, 168, .18);
}

.button.primary:hover {
    background: var(--primary-dark);
}

.button.warning {
    color: #fff;
    background: var(--warning);
    border-color: var(--warning);
}

.button.danger {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

.button.success {
    color: #fff;
    background: var(--success);
    border-color: var(--success);
}

.button.full {
    width: 100%;
    margin-top: 18px;
}

.icon-button {
    display: grid;
    min-width: 42px;
    place-items: center;
    padding: 8px;
    font-size: 20px;
}

#menuButton {
    display: none;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 9px;
    color: #344054;
    background: #eef2f7;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.badge.ok {
    color: #05603a;
    background: #dcfae6;
    border-color: #a6f4c5;
}

.badge.bad {
    color: #912018;
    background: #fee4e2;
    border-color: #fecdca;
}

.badge.warn {
    color: #93370d;
    background: #fef0c7;
    border-color: #fedf89;
}

.message,
.notice {
    min-height: 22px;
    color: var(--muted);
}

.message.visible {
    min-height: 0;
    padding: 11px 13px;
    margin-top: 14px;
    color: var(--text);
    background: var(--primary-soft);
    border: 1px solid #b7d5ff;
    border-radius: 8px;
}

.message.error,
.notice.error {
    color: var(--danger);
}

.message.visible.error {
    color: #912018;
    background: #fff1f3;
    border-color: #fecdd6;
}

.message.success {
    color: var(--success);
}

.message.visible.success {
    color: #05603a;
    background: #ecfdf3;
    border-color: #abefc6;
}

.notice {
    padding: 12px 14px;
    background: #eff8ff;
    border: 1px solid #b2ddff;
    border-radius: 8px;
}

.notice.error {
    background: #fff1f3;
    border-color: #fecdd6;
}

.hint {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
}

.hint.loading {
    color: var(--primary);
}

.mono,
.log-box {
    direction: ltr;
    font-family: Consolas, "SFMono-Regular", Menlo, monospace;
}

.form {
    display: grid;
    gap: 14px;
}

.list {
    display: grid;
    gap: 12px;
}

.admin-panels {
    display: grid;
    gap: 16px;
}

.wide-card,
.security-card {
    width: 100%;
}

.security-card {
    border-color: rgba(0, 56, 168, .32);
    background:
        linear-gradient(180deg, rgba(234, 243, 255, .8), rgba(255, 255, 255, .96)),
        #fff;
}

.item,
.settings-line {
    min-width: 0;
    padding: 14px;
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.item-title {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.settings-line {
    display: grid;
    grid-template-columns: 140px 1fr 1fr;
    gap: 12px;
    align-items: end;
}

.check-line {
    display: inline-flex;
    gap: 9px;
    align-items: center;
    font-weight: 600;
}

.check-line input {
    width: 18px;
    min-height: 18px;
    margin: 0;
}

.checks {
    display: flex;
    gap: 16px;
    align-items: end;
    padding-top: 24px;
}

.empty {
    padding: 16px;
    color: var(--muted);
    text-align: center;
}

.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 24, 40, .58);
}

.modal-panel {
    position: relative;
    width: min(900px, calc(100vw - 28px));
    max-height: calc(100vh - 60px);
    margin: 30px auto;
    overflow: hidden;
    background: #fff;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-head h2 {
    margin: 0;
    font-size: 18px;
}

.log-box {
    max-height: calc(100vh - 150px);
    margin: 0;
    padding: 16px;
    overflow: auto;
    color: #e6edf3;
    background: #0d1117;
    white-space: pre-wrap;
    word-break: break-word;
    text-align: left;
}

.modal-body {
    padding: 18px;
    color: var(--text);
}

.modal-body p {
    margin: 10px 0 0;
}

.loader {
    width: 44px;
    height: 44px;
    margin: 4px auto 12px;
    border: 4px solid #e4e7ec;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.loading-card {
    display: grid;
    min-height: 220px;
    place-items: center;
    gap: 8px;
    text-align: center;
}

.loading-card strong,
.page-loader-card strong {
    color: var(--primary-dark);
    font-size: 18px;
}

.loading-card span,
.page-loader-card span {
    color: var(--muted);
    font-size: 14px;
}

.page-loader[hidden] {
    display: none;
}

.page-loader {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .86), rgba(239, 247, 255, .9)),
        linear-gradient(180deg, transparent 0 12%, rgba(0, 56, 168, .11) 12% 16%, transparent 16% 84%, rgba(0, 56, 168, .11) 84% 88%, transparent 88%);
    backdrop-filter: blur(8px);
}

.page-loader-card {
    display: grid;
    width: min(340px, 100%);
    place-items: center;
    gap: 7px;
    padding: 26px;
    text-align: center;
    background: #ffffff;
    border: 1px solid rgba(0, 56, 168, .22);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1050px) {
    .grid.three {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        inset: 0;
        z-index: 40;
        display: grid;
        width: 100vw;
        height: 100dvh;
        grid-template-rows: auto auto 1fr auto;
        overflow: hidden;
        padding: 22px;
        transform: translateX(105%);
        transition: transform .18s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        position: absolute;
        top: 0;
        left: 0;
        display: grid;
        color: #fff;
        background: rgba(255, 255, 255, .08);
        border-color: rgba(255, 255, 255, .16);
    }

    .nav {
        align-content: start;
        overflow: hidden;
    }

    .nav button {
        min-height: 50px;
        padding: 13px 14px;
        font-size: 17px;
        background: rgba(255, 255, 255, .08);
        border: 1px solid rgba(255, 255, 255, .16);
    }

    .admin-profile {
        margin-bottom: 14px;
    }

    #menuButton {
        display: grid;
    }

    .main {
        padding: 16px;
    }

    .topbar {
        align-items: flex-start;
        gap: 12px;
        padding: 14px;
        margin-bottom: 14px;
    }

    .grid.two,
    .settings-line {
        grid-template-columns: 1fr;
    }

    .stat {
        display: grid;
        gap: 4px;
    }

    .stat span {
        max-width: 100%;
        text-align: right;
    }

    .row,
    .toolbar {
        align-items: stretch;
    }

    .item-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .row .button,
    .toolbar .button {
        flex: 1 1 160px;
    }

    .card {
        padding: 16px;
    }

    .login-card {
        padding: 24px 20px 22px;
        border-radius: 14px;
    }

    .login-shell {
        min-height: 100dvh;
        padding: 18px;
    }

    .admin-panels {
        gap: 14px;
    }

    .page-loader {
        padding: 16px;
    }

    .modal-panel {
        width: calc(100vw - 18px);
        max-height: calc(100dvh - 18px);
        margin: 9px auto;
    }
}
