:root {
    color-scheme: dark;
    --bg: #060910;
    --bg-2: #080d17;
    --panel: #0d1421;
    --panel-2: #111a2b;
    --panel-3: #162239;
    --line: rgba(148, 173, 214, 0.14);
    --line-strong: rgba(148, 173, 214, 0.26);
    --text: #f3f7ff;
    --muted: #93a2bd;
    --muted-2: #6f7f9b;
    --accent: #27d6c3;
    --accent-2: #3d8bff;
    --accent-3: #8b63ff;
    --gold: #f2c45e;
    --danger: #ff6f7d;
    --success: #46d992;
    --warning: #ffb454;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
    --radius: 22px;
    --radius-sm: 14px;
    --sidebar-width: 274px;
    --font: "Segoe UI", Tahoma, "Noto Kufi Arabic", "Cairo", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(circle at 88% -12%, rgba(39, 214, 195, 0.12), transparent 34rem),
        radial-gradient(circle at 6% 18%, rgba(61, 139, 255, 0.09), transparent 30rem),
        var(--bg);
    overflow-x: hidden;
}
body.modal-open { overflow: hidden; }

button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--accent); }
code {
    direction: ltr;
    unicode-bidi: embed;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.88em;
    color: var(--accent);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(147, 162, 189, 0.24);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

h1, h2, h3, h4, h5, p { margin: 0; }
h1, h2, h3, h4, h5 { line-height: 1.35; }
h1 { font-size: clamp(2.5rem, 4.5vw, 4.6rem); letter-spacing: -0.045em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.38rem; }
h4 { font-size: 1.05rem; }
h5 { font-size: 0.96rem; }
p { line-height: 1.8; }

.muted { color: var(--muted); }
.subtle { color: var(--muted-2); font-size: 0.82rem; }
.eyebrow {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    color: var(--accent);
    direction: ltr;
}

.ambient {
    position: fixed;
    border-radius: 50%;
    filter: blur(20px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.55;
}
.ambient-a {
    width: 38rem;
    height: 38rem;
    top: -24rem;
    left: -12rem;
    background: radial-gradient(circle, rgba(39, 214, 195, 0.13), transparent 66%);
}
.ambient-b {
    width: 34rem;
    height: 34rem;
    bottom: -22rem;
    right: -12rem;
    background: radial-gradient(circle, rgba(139, 99, 255, 0.12), transparent 66%);
}

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */
.login-screen {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(26rem, 0.8fr);
    gap: clamp(1rem, 5vw, 5rem);
    align-items: center;
    padding: clamp(1.4rem, 4vw, 4.5rem);
}
.login-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(147, 162, 189, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(147, 162, 189, 0.035) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: radial-gradient(circle at 46% 45%, #000, transparent 74%);
    pointer-events: none;
}
.login-visual {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: min(72vh, 720px);
    padding: clamp(1.2rem, 3vw, 3rem);
}
.brand-lockup,
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}
.brand-lockup strong,
.sidebar-brand strong {
    display: block;
    letter-spacing: 0.12em;
    font-size: 0.93rem;
    direction: ltr;
}
.brand-lockup span:not(.brand-mark),
.sidebar-brand span:not(.brand-mark) {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    margin-top: 0.25rem;
}
.brand-mark {
    display: block;
    flex: 0 0 auto;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    object-fit: cover;
    background: #08080a;
    border: 2px solid rgba(245, 197, 24, 0.55);
    box-shadow: 0 0 24px rgba(245, 197, 24, 0.18);
}
.brand-mark.small {
    width: 2.65rem;
    height: 2.65rem;
    border-width: 2px;
}
.login-copy {
    max-width: 44rem;
    padding: 2rem 0;
}
.login-copy h1 { margin: 1rem 0 1.25rem; }
.login-copy h1 em {
    font-style: normal;
    color: transparent;
    background: linear-gradient(90deg, var(--accent), #77a8ff 55%, #b795ff);
    -webkit-background-clip: text;
    background-clip: text;
}
.login-copy p {
    color: var(--muted);
    max-width: 32rem;
    font-size: 1.02rem;
}
.login-points {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.login-points div {
    min-width: 7.7rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(13, 20, 33, 0.62);
    backdrop-filter: blur(14px);
}
.login-points span {
    display: block;
    font-weight: 900;
    color: var(--text);
    direction: ltr;
    font-size: 1rem;
}
.login-points small { display: block; color: var(--muted); margin-top: 0.25rem; font-size: 0.7rem; }
.login-card-wrap {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
}
.login-card {
    width: min(100%, 29rem);
    border: 1px solid var(--line-strong);
    border-radius: 28px;
    background:
        linear-gradient(155deg, rgba(22, 34, 57, 0.84), rgba(8, 13, 23, 0.92));
    box-shadow: var(--shadow);
    backdrop-filter: blur(26px);
    padding: clamp(1.4rem, 3vw, 2.4rem);
}
.login-card-head {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--muted);
    font-size: 0.75rem;
    margin-bottom: 1.25rem;
}
.secure-dot,
.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 5px rgba(70, 217, 146, 0.11), 0 0 16px rgba(70, 217, 146, 0.7);
}
.login-card h2 { margin-bottom: 0.4rem; font-size: 1.55rem; }
.login-card > p { font-size: 0.88rem; }
.login-note {
    margin-top: 1.1rem;
    color: var(--muted-2);
    font-size: 0.73rem;
    line-height: 1.7;
}
.form-error {
    border: 1px solid rgba(255, 111, 125, 0.3);
    background: rgba(255, 111, 125, 0.08);
    color: #ffb9c0;
    border-radius: 12px;
    padding: 0.7rem 0.85rem;
    font-size: 0.82rem;
    line-height: 1.6;
}

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */
.app-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    border-left: 1px solid var(--line);
    background:
        linear-gradient(180deg, rgba(13, 20, 33, 0.95), rgba(7, 11, 19, 0.98)),
        var(--bg-2);
    backdrop-filter: blur(22px);
    z-index: 30;
}
.sidebar-brand {
    padding: 0.4rem 0.5rem 1.35rem;
    border-bottom: 1px solid var(--line);
}
.nav-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1rem 0;
    overflow-y: auto;
}
.nav-link {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid transparent;
    border-radius: 13px;
    padding: 0.78rem 0.85rem;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    text-align: right;
    transition: 180ms ease;
}
.nav-link svg {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
}
.nav-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.035);
}
.nav-link.active {
    color: var(--text);
    border-color: rgba(39, 214, 195, 0.18);
    background: linear-gradient(90deg, rgba(39, 214, 195, 0.12), rgba(39, 214, 195, 0.025));
}
.nav-link.active::after {
    content: "";
    position: absolute;
    right: -1px;
    top: 24%;
    bottom: 24%;
    width: 3px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 14px var(--accent);
}
.nav-badge {
    margin-right: auto;
    min-width: 1.3rem;
    text-align: center;
    border-radius: 999px;
    padding: 0.08rem 0.38rem;
    background: rgba(255, 111, 125, 0.17);
    color: #ffb7bf;
    border: 1px solid rgba(255, 111, 125, 0.22);
    font-size: 0.68rem;
    font-weight: 800;
}
.sidebar-foot {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}
.system-state {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem 0.9rem;
}
.system-state strong { display: block; font-size: 0.75rem; }
.system-state span:not(.status-dot) { display: block; color: var(--muted-2); font-size: 0.65rem; margin-top: 0.15rem; direction: ltr; }
.danger-link { color: #ff9aa4; }
.danger-link:hover { color: #ffd4d8; background: rgba(255, 111, 125, 0.07); }
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(3, 6, 11, 0.7);
    backdrop-filter: blur(6px);
}

.main-shell {
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    min-height: 94px;
    padding: 1rem clamp(1rem, 2.6vw, 2.3rem);
    border-bottom: 1px solid var(--line);
    background: rgba(6, 9, 16, 0.78);
    backdrop-filter: blur(22px);
}
.topbar-start, .topbar-end {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.topbar-start h2 { margin: 0.18rem 0 0.22rem; font-size: 1.2rem; }
.topbar-start p { color: var(--muted); font-size: 0.75rem; }
.mobile-menu { display: none !important; }
.content {
    width: 100%;
    max-width: 1580px;
    margin: 0 auto;
    padding: clamp(1rem, 2.6vw, 2.3rem);
    padding-bottom: 4rem;
}
.panel { display: none; animation: panelIn 220ms ease both; }
.panel.active { display: block; }
@keyframes panelIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   Shared elements
   -------------------------------------------------------------------------- */
.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.2rem;
}
.section-heading h3 { margin-top: 0.15rem; }
.heading-actions, .card-actions { display: flex; gap: 0.55rem; flex-wrap: wrap; align-items: center; }
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.48rem;
    min-height: 2.6rem;
    padding: 0.62rem 1rem;
    border-radius: 12px;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.82rem;
    text-decoration: none;
    transition: 160ms ease;
    white-space: nowrap;
}
.button svg { width: 1rem; height: 1rem; }
.button:disabled { opacity: 0.48; cursor: not-allowed; }
.button-primary {
    color: #04120f;
    background: linear-gradient(135deg, var(--accent), #7bffdb);
    box-shadow: 0 10px 28px rgba(39, 214, 195, 0.18);
}
.button-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 14px 32px rgba(39, 214, 195, 0.26); }
.button-ghost {
    border-color: var(--line-strong);
    background: rgba(17, 26, 43, 0.58);
    color: var(--text);
}
.button-ghost:hover:not(:disabled) { border-color: rgba(39, 214, 195, 0.35); background: rgba(39, 214, 195, 0.06); }
.button-danger {
    border-color: rgba(255, 111, 125, 0.26);
    background: rgba(255, 111, 125, 0.08);
    color: #ffb8c0;
}
.button-danger:hover:not(:disabled) { background: rgba(255, 111, 125, 0.14); }
.button-success {
    border-color: rgba(70, 217, 146, 0.26);
    background: rgba(70, 217, 146, 0.09);
    color: #a9ffd2;
}
.button-warning {
    border-color: rgba(255, 180, 84, 0.26);
    background: rgba(255, 180, 84, 0.09);
    color: #ffd59c;
}
.button-small { min-height: 2.2rem; padding: 0.45rem 0.75rem; font-size: 0.76rem; }
.button-tiny { min-height: 1.85rem; padding: 0.3rem 0.6rem; font-size: 0.7rem; border-radius: 9px; }
.button-wide { width: 100%; }
.icon-button {
    display: inline-grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(17, 26, 43, 0.56);
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    transition: 160ms ease;
}
.icon-button:hover { color: var(--text); border-color: var(--line-strong); }
.icon-button svg { width: 1.1rem; height: 1.1rem; }

.field { display: flex; flex-direction: column; gap: 0.42rem; min-width: 0; }
.field > span {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 700;
}
.field > span b {
    display: inline-block;
    margin-right: 0.35rem;
    color: var(--muted-2);
    font-size: 0.65rem;
    font-weight: 600;
    direction: ltr;
}
.field.compact { min-width: 11rem; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(6, 10, 18, 0.62);
    color: var(--text);
    padding: 0.68rem 0.78rem;
    outline: none;
    transition: 160ms ease;
}
input::placeholder, textarea::placeholder { color: #5e6c86; }
input:focus, select:focus, textarea:focus {
    border-color: rgba(39, 214, 195, 0.5);
    box-shadow: 0 0 0 3px rgba(39, 214, 195, 0.08);
}
select {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(0.9rem) calc(50% - 2px),
        calc(0.9rem + 4px) calc(50% - 2px);
    background-size: 4px 4px, 4px 4px;
    background-repeat: no-repeat;
    padding-left: 1.8rem;
}
textarea { resize: vertical; min-height: 6rem; line-height: 1.7; }
input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
}
.input-with-action { position: relative; }
.input-with-action input { padding-left: 4.5rem; }
.input-with-action .icon-button {
    position: absolute;
    left: 0.32rem;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    height: 2rem;
    padding: 0 0.7rem;
    font-size: 0.7rem;
}
.stack { display: flex; flex-direction: column; gap: 1rem; }
.two-col, .three-col, .form-grid {
    display: grid;
    gap: 0.85rem;
}
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.75rem; }

.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        linear-gradient(155deg, rgba(17, 26, 43, 0.74), rgba(9, 14, 24, 0.85));
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.16);
    padding: clamp(1rem, 2vw, 1.45rem);
}
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}
.card-head h4 { margin-top: 0.12rem; }
.badge, .chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 0.26rem 0.62rem;
    font-size: 0.67rem;
    font-weight: 800;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.025);
    white-space: nowrap;
}
.badge-success { color: #a9ffd2; border-color: rgba(70, 217, 146, 0.25); background: rgba(70, 217, 146, 0.08); }
.badge-warning { color: #ffd59c; border-color: rgba(255, 180, 84, 0.25); background: rgba(255, 180, 84, 0.08); }
.badge-danger { color: #ffb8c0; border-color: rgba(255, 111, 125, 0.25); background: rgba(255, 111, 125, 0.08); }
.badge-info { color: #b8d1ff; border-color: rgba(61, 139, 255, 0.25); background: rgba(61, 139, 255, 0.08); }
.chip-warning { color: #ffd59c; border-color: rgba(255, 180, 84, 0.25); background: rgba(255, 180, 84, 0.08); }
.notice {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.02);
    font-size: 0.8rem;
    line-height: 1.7;
    margin-bottom: 1rem;
}
.notice strong { color: var(--text); white-space: nowrap; }
.notice-warning { border-color: rgba(255, 180, 84, 0.22); background: rgba(255, 180, 84, 0.055); color: #dbc39c; }
.notice-danger { border-color: rgba(255, 111, 125, 0.22); background: rgba(255, 111, 125, 0.055); color: #e6aab1; }

/* --------------------------------------------------------------------------
   Dashboard
   -------------------------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
    margin-bottom: 1rem;
}
.stat-card {
    position: relative;
    overflow: hidden;
    min-height: 9.4rem;
    border: 1px solid var(--line);
    border-radius: 19px;
    padding: 1.05rem 1.05rem 0.95rem;
    background:
        linear-gradient(155deg, rgba(20, 32, 53, 0.82), rgba(9, 14, 24, 0.86));
}
.stat-card::after {
    content: "";
    position: absolute;
    width: 8rem;
    height: 8rem;
    border-radius: 50%;
    left: -3rem;
    bottom: -4.5rem;
    background: radial-gradient(circle, var(--stat-glow, rgba(39, 214, 195, 0.16)), transparent 70%);
}
.stat-icon {
    width: 2.35rem;
    height: 2.35rem;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(39, 214, 195, 0.08);
    color: var(--accent);
    margin-bottom: 0.8rem;
    font-size: 1rem;
}
.stat-card h5 { color: var(--muted); font-size: 0.72rem; font-weight: 700; }
.stat-card strong {
    display: block;
    margin-top: 0.42rem;
    font-size: clamp(1.55rem, 2.8vw, 2.2rem);
    letter-spacing: -0.04em;
    direction: ltr;
    text-align: right;
}
.stat-card small { display: block; margin-top: 0.35rem; color: var(--muted-2); font-size: 0.68rem; }
.stat-card.pending { --stat-glow: rgba(255, 180, 84, 0.2); }
.stat-card.pending .stat-icon { color: var(--warning); background: rgba(255, 180, 84, 0.08); }
.stat-card.danger { --stat-glow: rgba(255, 111, 125, 0.18); }
.stat-card.danger .stat-icon { color: var(--danger); background: rgba(255, 111, 125, 0.08); }
.stat-card.blue { --stat-glow: rgba(61, 139, 255, 0.2); }
.stat-card.blue .stat-icon { color: #7bb0ff; background: rgba(61, 139, 255, 0.09); }
.stat-card.purple { --stat-glow: rgba(139, 99, 255, 0.2); }
.stat-card.purple .stat-icon { color: #b89aff; background: rgba(139, 99, 255, 0.09); }

.split-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 0.9rem;
    margin-bottom: 0.9rem;
}
.mini-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}
.mini-stat {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.018);
}
.mini-stat span { display: block; color: var(--muted); font-size: 0.68rem; }
.mini-stat strong { display: block; margin-top: 0.35rem; font-size: 1.3rem; direction: ltr; text-align: right; }
.tmdb-card .card-actions { margin-top: 1rem; }

/* --------------------------------------------------------------------------
   Tables & toolbars
   -------------------------------------------------------------------------- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.toolbar-embedded { margin: 0 0 0.8rem; padding-top: 0.2rem; }
.inline-form { display: flex; align-items: flex-end; gap: 0.65rem; flex-wrap: wrap; }
.table-card { padding: 0.45rem; }
.table-wrap { overflow-x: auto; border-radius: 17px; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}
.data-table th, .data-table td {
    padding: 0.78rem 0.7rem;
    border-bottom: 1px solid rgba(147, 162, 189, 0.09);
    text-align: right;
    vertical-align: middle;
    font-size: 0.78rem;
}
.data-table th {
    color: var(--muted-2);
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    background: rgba(6, 10, 18, 0.35);
    white-space: nowrap;
}
.data-table tbody tr { transition: background 140ms ease; }
.data-table tbody tr:hover { background: rgba(39, 214, 195, 0.025); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num {
    direction: ltr;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.data-table .muted-cell { color: var(--muted); }
.data-table .actions-cell { white-space: nowrap; }
.row-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: flex-end; }
.table-main { display: flex; flex-direction: column; gap: 0.2rem; }
.table-main strong { font-size: 0.8rem; }
.table-main span { color: var(--muted-2); font-size: 0.7rem; direction: ltr; text-align: right; }
.table-empty, .empty-state {
    padding: 2.2rem 1rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.84rem;
}
.compact-empty { padding: 1.4rem 1rem; }
.empty-state strong { display: block; color: var(--text); margin-bottom: 0.3rem; }
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 0.6rem 0.45rem;
    color: var(--muted);
    font-size: 0.74rem;
}
.pagination button {
    min-width: 2rem;
    height: 1.9rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}
.pagination button:disabled { opacity: 0.35; cursor: not-allowed; }
.pagination .page-current {
    padding: 0.3rem 0.55rem;
    border-radius: 8px;
    background: rgba(39, 214, 195, 0.08);
    color: var(--accent);
    font-weight: 800;
}

/* --------------------------------------------------------------------------
   Settings
   -------------------------------------------------------------------------- */
.settings-form { display: flex; flex-direction: column; gap: 1rem; }
.settings-group {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(155deg, rgba(17, 26, 43, 0.64), rgba(9, 14, 24, 0.78));
    padding: 1.15rem;
}
.settings-group-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--line);
}
.settings-group-head p { color: var(--muted); font-size: 0.75rem; margin-top: 0.25rem; }
.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem;
}
.settings-field { min-width: 0; }
.settings-field-wide { grid-column: 1 / -1; }
.settings-field small { color: var(--muted-2); font-size: 0.68rem; line-height: 1.6; }
.switch-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.72rem 0.8rem;
    background: rgba(6, 10, 18, 0.36);
    min-height: 3.2rem;
}
.switch-field span { color: var(--muted); font-size: 0.76rem; font-weight: 700; line-height: 1.5; }
.switch {
    position: relative;
    display: inline-block;
    width: 2.45rem;
    height: 1.35rem;
    flex: 0 0 auto;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch i {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(147, 162, 189, 0.23);
    cursor: pointer;
    transition: 180ms ease;
}
.switch i::after {
    content: "";
    position: absolute;
    width: 0.95rem;
    height: 0.95rem;
    border-radius: 50%;
    top: 0.2rem;
    right: 0.22rem;
    background: #b4c2d8;
    transition: 180ms ease;
}
.switch input:checked + i { background: rgba(39, 214, 195, 0.4); }
.switch input:checked + i::after { right: 1.25rem; background: var(--accent); box-shadow: 0 0 12px rgba(39, 214, 195, 0.6); }
.sticky-actions {
    position: sticky;
    bottom: 0.8rem;
    z-index: 5;
    padding: 0.8rem 1rem;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: rgba(8, 13, 23, 0.88);
    backdrop-filter: blur(18px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.24);
}

/* --------------------------------------------------------------------------
   Rewards
   -------------------------------------------------------------------------- */
.rewards-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}
.reward-category {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(155deg, rgba(17, 26, 43, 0.72), rgba(9, 14, 24, 0.84));
    overflow: hidden;
}
.reward-category-head {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem;
    border-bottom: 1px solid var(--line);
}
.category-icon {
    position: relative;
    width: 2.7rem;
    height: 2.7rem;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 13px;
    background: rgba(39, 214, 195, 0.08);
    color: var(--accent);
    font-weight: 900;
    overflow: hidden;
}
.category-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.reward-category-head h4 { font-size: 0.95rem; }
.reward-category-head span { display: block; color: var(--muted-2); font-size: 0.68rem; margin-top: 0.2rem; }
.reward-category-head .heading-actions { margin-right: auto; }
.reward-items { padding: 0.55rem; display: flex; flex-direction: column; gap: 0.4rem; }
.reward-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.62rem;
    border-radius: 12px;
    border: 1px solid transparent;
}
.reward-item:hover { border-color: var(--line); background: rgba(255, 255, 255, 0.018); }
.reward-item-main { min-width: 0; flex: 1; }
.reward-item-main strong { display: block; font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reward-item-main span { display: block; color: var(--muted); font-size: 0.69rem; margin-top: 0.18rem; }
.reward-item .row-actions { flex: 0 0 auto; }
.reward-item.inactive { opacity: 0.52; }
.reward-empty { color: var(--muted); text-align: center; font-size: 0.75rem; padding: 1.2rem; }

/* --------------------------------------------------------------------------
   Media & TMDB importer
   -------------------------------------------------------------------------- */
.importer-card { margin-bottom: 1rem; }
.importer-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
}
.importer-box {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0.9rem;
    background: rgba(6, 10, 18, 0.32);
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}
.importer-box h5 { color: var(--text); font-size: 0.8rem; }
.results-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 1rem 0 0.6rem;
}
.tmdb-results {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    min-height: 5rem;
}
.tmdb-card-item {
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    background: rgba(8, 13, 23, 0.7);
}
.tmdb-poster {
    position: relative;
    aspect-ratio: 2 / 3;
    background:
        radial-gradient(circle at 30% 25%, rgba(39, 214, 195, 0.15), transparent 60%),
        #111a2b;
    overflow: hidden;
}
.tmdb-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 1rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.74rem;
}
.tmdb-card-item .tmdb-poster > .badge { position: absolute; top: 0.5rem; right: 0.5rem; backdrop-filter: blur(8px); }
.tmdb-card-body { padding: 0.7rem; display: flex; flex-direction: column; gap: 0.35rem; }
.tmdb-card-body strong { font-size: 0.78rem; line-height: 1.5; min-height: 2.3em; }
.tmdb-meta { display: flex; justify-content: space-between; gap: 0.4rem; color: var(--muted); font-size: 0.66rem; }
.tmdb-card-body .button { margin-top: 0.25rem; }
.tmdb-card-item.imported { border-color: rgba(70, 217, 146, 0.2); }

.media-cell { display: flex; align-items: center; gap: 0.7rem; min-width: 15rem; }
.media-thumb {
    position: relative;
    width: 2.7rem;
    height: 3.7rem;
    flex: 0 0 auto;
    border-radius: 9px;
    overflow: hidden;
    background: #111a2b;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb .poster-fallback { font-size: 0.6rem; padding: 0.2rem; }
.media-cell-main { min-width: 0; }
.media-cell-main strong { display: block; font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-cell-main span { display: block; color: var(--muted-2); font-size: 0.68rem; margin-top: 0.2rem; }
.source-label { font-size: 0.67rem; color: var(--muted); direction: ltr; }
.featured-star { color: var(--gold); }

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal-root {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 1rem;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 5, 10, 0.76);
    backdrop-filter: blur(8px);
}
.modal-shell {
    position: relative;
    width: min(100%, 62rem);
    max-height: min(88vh, 900px);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line-strong);
    border-radius: 24px;
    background:
        linear-gradient(155deg, rgba(19, 30, 50, 0.98), rgba(7, 11, 19, 0.99));
    box-shadow: 0 35px 100px rgba(0, 0, 0, 0.6);
    animation: modalIn 180ms ease both;
}
.modal-shell.wide { width: min(100%, 78rem); }
.modal-shell.narrow { width: min(100%, 36rem); }
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.985) translateY(5px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.15rem 1.25rem 0.9rem;
    border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0.2rem 0 0.25rem; font-size: 1.15rem; }
.modal-head p { font-size: 0.75rem; }
.modal-body {
    overflow-y: auto;
    padding: 1.15rem 1.25rem 1.35rem;
}
.modal-body form { display: flex; flex-direction: column; gap: 0.9rem; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.55rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    margin-top: 0.4rem;
    border-top: 1px solid var(--line);
}
.modal-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.9rem;
}
.audit-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem;
    margin-bottom: 0.9rem;
}
.audit-box {
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(6, 10, 18, 0.34);
    padding: 0.7rem;
}
.audit-box span { display: block; color: var(--muted); font-size: 0.66rem; }
.audit-box strong { display: block; margin-top: 0.3rem; font-size: 1.15rem; direction: ltr; text-align: right; }
.detail-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem 1rem;
    margin: 0.8rem 0;
}
.detail-list div {
    display: flex;
    justify-content: space-between;
    gap: 0.7rem;
    padding: 0.42rem 0;
    border-bottom: 1px dashed rgba(147, 162, 189, 0.1);
    font-size: 0.74rem;
}
.detail-list span { color: var(--muted); }
.detail-list strong { font-weight: 600; text-align: left; word-break: break-word; }
.detail-list code { font-size: 0.7rem; }
.snapshot {
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #05080e;
    padding: 0.8rem;
    color: #b9c9e4;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.68rem;
    line-height: 1.65;
    direction: ltr;
    text-align: left;
    max-height: 17rem;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.section-subhead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1.1rem 0 0.55rem;
}
.section-subhead h4 { font-size: 0.88rem; }
.log-table { min-width: 620px; }
.log-table th, .log-table td { font-size: 0.71rem; }
.positive { color: var(--success); }
.negative { color: var(--danger); }
.check-row {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.75rem;
    background: rgba(6, 10, 18, 0.3);
}
.check-row input { margin-top: 0.18rem; flex: 0 0 auto; }
.check-row span { color: var(--muted); font-size: 0.76rem; line-height: 1.6; }
.check-row strong { display: block; color: var(--text); margin-bottom: 0.12rem; }

/* --------------------------------------------------------------------------
   Toasts, loading, responsive
   -------------------------------------------------------------------------- */
.toast-root {
    position: fixed;
    z-index: 200;
    left: 1rem;
    bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: min(24rem, calc(100vw - 2rem));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: rgba(13, 20, 33, 0.96);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
    padding: 0.8rem 0.9rem;
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    animation: toastIn 180ms ease both;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.toast-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    margin-top: 0.28rem;
    flex: 0 0 auto;
    background: var(--accent);
}
.toast.success .toast-dot { background: var(--success); }
.toast.error .toast-dot { background: var(--danger); }
.toast.warning .toast-dot { background: var(--warning); }
.toast strong { display: block; font-size: 0.78rem; margin-bottom: 0.15rem; }
.toast p { color: var(--muted); font-size: 0.72rem; line-height: 1.6; }
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 190;
    display: grid;
    place-items: center;
    background: rgba(3, 6, 11, 0.55);
    backdrop-filter: blur(4px);
}
.loading-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: rgba(13, 20, 33, 0.94);
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow);
    font-size: 0.82rem;
}
.spinner {
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    border: 2px solid rgba(39, 214, 195, 0.18);
    border-top-color: var(--accent);
    animation: spin 720ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.noscript {
    position: fixed;
    inset: auto 1rem 1rem;
    z-index: 300;
    padding: 1rem;
    border-radius: 14px;
    background: #2a1015;
    color: #ffd2d7;
    text-align: center;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1280px) {
    .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .tmdb-results { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
    .login-screen { grid-template-columns: 1fr; }
    .login-visual { min-height: 30rem; }
    .login-copy { padding: 1rem 0; }
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        inset: 0 0 0 auto;
        width: min(var(--sidebar-width), 86vw);
        transform: translateX(105%);
        transition: transform 220ms ease;
        box-shadow: -30px 0 80px rgba(0, 0, 0, 0.4);
    }
    .sidebar.open { transform: translateX(0); }
    .mobile-menu { display: inline-grid !important; }
    .topbar { align-items: flex-start; }
    .topbar-end { flex-wrap: wrap; justify-content: flex-end; }
    .importer-grid { grid-template-columns: 1fr; }
    .rewards-grid { grid-template-columns: 1fr; }
    .split-grid { grid-template-columns: 1fr; }
    .audit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .login-screen { padding: 1rem; }
    .login-visual { padding: 0.5rem; min-height: auto; gap: 2rem; }
    .login-copy h1 { font-size: clamp(2.2rem, 12vw, 3.4rem); }
    .login-points { display: none; }
    .topbar { min-height: auto; padding: 0.9rem 1rem; }
    .topbar-start h2 { font-size: 1rem; }
    .topbar-start p, #today-date { display: none; }
    .topbar-end { gap: 0.45rem; }
    .content { padding: 1rem; }
    .section-heading { align-items: flex-start; flex-direction: column; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mini-stat-grid { grid-template-columns: 1fr; }
    .form-grid, .settings-grid, .two-col, .three-col, .detail-list { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .tmdb-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .inline-form { width: 100%; }
    .inline-form .field.compact, .inline-form .button { flex: 1 1 100%; }
    .toolbar { align-items: stretch; }
    .field.compact { min-width: 0; }
    .modal-root { padding: 0; }
    .modal-shell, .modal-shell.wide, .modal-shell.narrow {
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }
    .modal-body { padding-bottom: 2rem; }
    .sticky-actions { bottom: 0; }
    .audit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
    .stat-grid, .tmdb-results, .audit-grid { grid-template-columns: 1fr; }
    .stat-card { min-height: 8rem; }
    .button { padding-inline: 0.75rem; }
    .topbar-end .button span { display: none; }
    .login-card { border-radius: 22px; }
}
