:root {
    color-scheme: dark;
    --bg: #070911;
    --bg-soft: #0b0f1a;
    --surface: rgba(17, 23, 38, 0.82);
    --surface-solid: #111726;
    --surface-raised: rgba(24, 32, 52, 0.9);
    --surface-hover: rgba(31, 41, 66, 0.9);
    --line: rgba(148, 163, 184, 0.15);
    --line-strong: rgba(148, 163, 184, 0.28);
    --text: #f4f7fb;
    --muted: #9ba8bc;
    --faint: #6f7d92;
    --primary: #8b7cff;
    --primary-bright: #a99cff;
    --cyan: #3ddbd2;
    --green: #3ddc97;
    --orange: #f6b94f;
    --red: #ff6b7c;
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
    --shadow-soft: 0 12px 35px rgba(0, 0, 0, 0.18);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 13px;
    --radius-sm: 10px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 12% -5%, rgba(139, 124, 255, 0.18), transparent 31rem),
        radial-gradient(circle at 92% 8%, rgba(61, 219, 210, 0.11), transparent 29rem),
        linear-gradient(180deg, #080b14 0%, #070911 46%, #090c14 100%) !important;
    color: var(--text) !important;
    font-family:
        Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
        "Noto Sans Arabic", Arial, sans-serif !important;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: -0.006em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    content: "";
    opacity: 0.18;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(to bottom, black, transparent 72%);
}

::selection {
    color: #fff;
    background: rgba(139, 124, 255, 0.55);
}

a {
    color: #a8c8ff !important;
    text-decoration: none !important;
    transition: color 160ms ease, opacity 160ms ease;
}

a:hover {
    color: #d4e4ff !important;
}

:focus-visible {
    outline: 3px solid rgba(139, 124, 255, 0.62);
    outline-offset: 3px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(7, 9, 17, 0.78);
    box-shadow: 0 8px 35px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(22px) saturate(145%);
    -webkit-backdrop-filter: blur(22px) saturate(145%);
}

.topbar-inner {
    display: flex;
    align-items: center;
    width: min(1440px, calc(100% - 32px));
    min-height: 68px;
    margin: 0 auto;
    gap: 22px;
}

.brand {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 11px;
    color: var(--text) !important;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.brand:hover {
    color: #fff !important;
}

.brand-mark {
    position: relative;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 11px;
    background:
        linear-gradient(145deg, rgba(255,255,255,0.2), transparent 45%),
        linear-gradient(135deg, var(--primary), #5b7cff 55%, var(--cyan));
    box-shadow: 0 8px 22px rgba(116, 98, 255, 0.3);
}

.brand-mark::before {
    width: 12px;
    height: 15px;
    border-radius: 4px 7px 7px 4px;
    background: #fff;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
    content: "";
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.25));
}

.brand-copy {
    display: grid;
    line-height: 1.05;
}

.brand-copy small {
    margin-top: 4px;
    color: var(--faint);
    font-size: 9px;
    font-weight: 750;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.topnav {
    display: flex;
    align-self: stretch;
    align-items: center;
    min-width: 0;
    gap: 4px;
}

.nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 13px;
    border-radius: 11px;
    color: var(--muted) !important;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text) !important;
    background: rgba(255, 255, 255, 0.045);
}

.nav-link.is-active {
    color: #fff !important;
    background: rgba(139, 124, 255, 0.13);
}

.nav-link.is-active::after {
    position: absolute;
    right: 13px;
    bottom: 4px;
    left: 13px;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), var(--cyan));
    content: "";
}

.topbar-actions {
    display: flex;
    align-items: center;
    margin-inline-start: auto;
    gap: 10px;
}

.system-state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.system-state::before {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.1), 0 0 16px rgba(61, 220, 151, 0.55);
    content: "";
}

.topbar form,
.topbar button {
    width: auto !important;
    margin: 0 !important;
}

.signout-button {
    min-height: 36px !important;
    padding: 0 12px !important;
    border-color: var(--line) !important;
    background: rgba(255, 255, 255, 0.035) !important;
    box-shadow: none !important;
    color: var(--muted) !important;
    font-size: 12px !important;
}

.signout-button:hover {
    color: #fff !important;
    border-color: var(--line-strong) !important;
    background: rgba(255, 255, 255, 0.07) !important;
}

.wrapper {
    width: min(1360px, calc(100% - 32px)) !important;
    max-width: none !important;
    margin: 0 auto !important;
    padding: 38px 0 64px !important;
}

.page-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 26px;
    gap: 28px;
}

.page-hero-copy {
    max-width: 760px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--primary-bright);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.eyebrow::before {
    width: 22px;
    height: 1px;
    background: linear-gradient(90deg, var(--primary), var(--cyan));
    content: "";
}

h1, h2, h3 {
    color: var(--text);
    letter-spacing: -0.035em;
}

h1 {
    margin: 0 !important;
    font-size: clamp(2rem, 4vw, 3.55rem) !important;
    font-weight: 840 !important;
    line-height: 1.02 !important;
}

h2 {
    font-size: 1.18rem !important;
    font-weight: 790 !important;
}

h3 {
    font-weight: 760 !important;
}

.subtitle {
    max-width: 720px;
    margin: 12px 0 0 !important;
    color: var(--muted) !important;
    font-size: 15px;
    line-height: 1.65;
}

.panel,
.navigation,
.statistics,
.filters,
.card,
.category-card,
.statistic,
.queue-summary,
.batch-actions,
.flash {
    border: 1px solid var(--line) !important;
    background: linear-gradient(145deg, rgba(23, 30, 49, 0.86), rgba(13, 18, 31, 0.88)) !important;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.panel,
.navigation,
.filters,
.card,
.category-card,
.queue-summary,
.batch-actions,
.flash {
    border-radius: var(--radius-lg) !important;
}

.panel,
.card,
.category-card {
    padding: 18px !important;
}

.panel,
.navigation,
.flash {
    margin-bottom: 14px !important;
}

.navigation {
    padding: 15px 17px !important;
}

.navigation strong {
    display: block;
    margin-bottom: 3px;
    font-size: 13px;
}

.metadata,
.muted,
.help-text {
    color: var(--muted) !important;
}

.metadata {
    font-size: 12.5px;
    line-height: 1.55;
}

.statistics,
.stats {
    overflow: hidden;
    border-radius: var(--radius-xl) !important;
    gap: 1px !important;
}

.stat,
.statistic {
    position: relative;
    min-width: 0;
    padding: 18px 12px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: rgba(13, 18, 31, 0.76) !important;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.stat::after,
.statistic::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 2px;
    opacity: 0;
    background: linear-gradient(90deg, var(--primary), var(--cyan));
    content: "";
    transition: opacity 180ms ease;
}

.stat:hover::after,
.statistic:hover::after {
    opacity: 1;
}

.stat strong,
.statistic strong {
    margin-bottom: 5px;
    color: var(--text);
    font-size: clamp(1.35rem, 2vw, 1.85rem) !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
}

input,
select,
textarea,
button {
    min-height: 44px;
    border: 1px solid var(--line) !important;
    border-radius: var(--radius-sm) !important;
    background: rgba(6, 9, 17, 0.72) !important;
    color: var(--text) !important;
    font: inherit;
    transition:
        border-color 160ms ease,
        background 160ms ease,
        box-shadow 160ms ease,
        transform 160ms var(--ease);
}

input,
select,
textarea {
    padding: 10px 12px !important;
}

input::placeholder,
textarea::placeholder {
    color: #66748a;
}

/* Native dropdown lists are rendered by the OS, which does NOT inherit the
   select's own colours — the options came out dark-on-dark and unreadable.
   Opaque values only: native popups ignore rgba transparency. */
select option,
select optgroup {
    background-color: #0e1626;
    color: #e6edf6;
}

select option:checked,
select option:hover {
    background-color: #2b3a55;
    color: #ffffff;
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--line-strong) !important;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(139, 124, 255, 0.72) !important;
    background: rgba(10, 13, 24, 0.92) !important;
    box-shadow: 0 0 0 4px rgba(139, 124, 255, 0.12);
}

textarea {
    line-height: 1.5;
}

button {
    padding: 10px 15px !important;
    cursor: pointer;
    border-color: rgba(151, 136, 255, 0.45) !important;
    background:
        linear-gradient(135deg, rgba(156, 136, 255, 0.98), rgba(105, 93, 232, 0.98)) !important;
    box-shadow: 0 10px 24px rgba(92, 76, 210, 0.22);
    font-weight: 760 !important;
}

button:hover:not(:disabled) {
    border-color: rgba(188, 179, 255, 0.72) !important;
    box-shadow: 0 12px 30px rgba(92, 76, 210, 0.32);
    transform: translateY(-1px);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.46;
    filter: saturate(0.5);
}

button.secondary,
.compact-button {
    border-color: var(--line-strong) !important;
    background: rgba(255, 255, 255, 0.045) !important;
    box-shadow: none;
}

button.secondary:hover,
.compact-button:hover {
    background: rgba(255, 255, 255, 0.085) !important;
}

button.danger,
.reset-button {
    border-color: rgba(255, 107, 124, 0.42) !important;
    background: rgba(130, 38, 54, 0.55) !important;
    box-shadow: none;
}

button.warning {
    border-color: rgba(246, 185, 79, 0.4) !important;
    background: rgba(116, 74, 18, 0.58) !important;
    box-shadow: none;
}

label {
    color: var(--muted) !important;
    font-size: 12.5px;
    font-weight: 650;
}

input[type="checkbox"],
input[type="radio"] {
    min-height: 0;
    accent-color: var(--primary);
}

.filters {
    padding: 16px !important;
    border-radius: var(--radius-xl) !important;
}

.filter-wide {
    min-width: 220px;
}

.filter-actions a {
    border-color: var(--line) !important;
    color: var(--muted) !important;
    background: rgba(255, 255, 255, 0.025);
}

.filter-actions a:hover {
    color: var(--text) !important;
    background: rgba(255, 255, 255, 0.065);
}

.category-picker,
details {
    border-color: var(--line) !important;
}

.category-picker {
    padding: 12px !important;
    border-radius: var(--radius-md) !important;
    background: rgba(5, 8, 15, 0.33);
}

summary {
    color: #b8cfff !important;
    font-weight: 720 !important;
}

.category-options {
    padding-inline-end: 4px;
}

.category-option,
.version {
    border-color: var(--line) !important;
    background: rgba(255, 255, 255, 0.02);
}

.category-option:hover,
.version:hover {
    border-color: var(--line-strong) !important;
    background: rgba(255, 255, 255, 0.045);
}

.card,
.category-card {
    position: relative;
    overflow: hidden;
    transition:
        border-color 180ms ease,
        background 180ms ease,
        transform 180ms var(--ease),
        box-shadow 180ms ease;
}

.card::before,
.category-card::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    opacity: 0;
    background: linear-gradient(180deg, var(--primary), var(--cyan));
    content: "";
    transition: opacity 180ms ease;
}

.card:hover,
.category-card:hover {
    border-color: rgba(139, 124, 255, 0.28) !important;
    background: linear-gradient(145deg, rgba(27, 35, 57, 0.93), rgba(15, 20, 34, 0.93)) !important;
    box-shadow: 0 19px 45px rgba(0, 0, 0, 0.24);
    transform: translateY(-1px);
}

.card:hover::before,
.category-card:hover::before {
    opacity: 1;
}

.title,
.category-title {
    color: var(--text);
    letter-spacing: -0.022em;
}

.badges,
.status {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.badge {
    margin: 4px 0 0 !important;
    padding: 4px 9px !important;
    border: 1px solid var(--line) !important;
    border-radius: 999px !important;
    background: rgba(255, 255, 255, 0.035);
    color: var(--muted);
    font-size: 11px !important;
    font-weight: 700;
    line-height: 1.25;
}

.badge.preferred,
.badge.success,
.success {
    color: var(--green) !important;
    border-color: rgba(61, 220, 151, 0.22) !important;
    background: rgba(61, 220, 151, 0.07);
}

.badge.versions,
.warning,
.pending,
.job-active {
    color: var(--orange) !important;
}

.failed,
.job-failed {
    color: var(--red) !important;
}

.flash {
    position: relative;
    padding: 14px 17px 14px 46px !important;
    color: #dbe8ff;
}

.flash::before {
    position: absolute;
    top: 50%;
    left: 17px;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(139, 124, 255, 0.18);
    color: var(--primary-bright);
    content: "i";
    font-size: 12px;
    font-weight: 900;
    transform: translateY(-50%);
}

.queue-summary {
    padding: 13px 17px !important;
    color: var(--muted);
}

.queue-summary span {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
}

.queue-summary strong {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.batch-actions {
    padding: 14px 16px !important;
}

.pager {
    align-items: center !important;
    min-height: 56px;
    margin: 22px 0 !important;
    padding: 0 6px;
    color: var(--muted);
}

.pager a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.025);
    font-size: 13px;
    font-weight: 720;
}

.actions {
    gap: 9px !important;
}

.actions form {
    margin: 0;
}

.progress {
    height: 10px !important;
    border: 0 !important;
    border-radius: 999px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.35);
}

.progress div {
    position: relative;
    overflow: hidden;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), #698dff, var(--cyan)) !important;
    box-shadow: 0 0 24px rgba(61, 219, 210, 0.28);
}

.progress div::after {
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 25%, rgba(255,255,255,0.25) 50%, transparent 75%);
    content: "";
    animation: progress-shine 2.2s linear infinite;
    transform: translateX(-100%);
}

.activity-grid > div {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(5, 8, 15, 0.3);
}

.failure-box {
    border-color: rgba(255, 107, 124, 0.28) !important;
    background: linear-gradient(145deg, rgba(60, 20, 31, 0.65), rgba(26, 15, 24, 0.85)) !important;
}

.item {
    border-color: var(--line) !important;
}

.original-name,
.version-title,
.title,
.item,
[dir="auto"] {
    unicode-bidi: plaintext;
    text-align: start;
}

bdi {
    unicode-bidi: isolate;
}

.english-translation {
    color: #afc9ff !important;
}

.page-providers .panel:has(> form),
.page-categories .profile-panel {
    padding: 22px !important;
}

.page-providers .grid {
    gap: 13px !important;
}

.page-providers .checks {
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(5, 8, 15, 0.32);
}

.page-providers .checks label {
    display: inline-flex;
    align-items: center;
    color: var(--text) !important;
}

.page-providers .panel > h2 {
    margin-bottom: 8px;
}

.page-categories .statistics {
    box-shadow: var(--shadow-soft);
}

.page-categories .bulk-actions {
    gap: 10px !important;
}

.page-categories .category-editor {
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.page-login {
    display: grid;
    place-items: center;
    padding: 24px;
}

.page-login::after {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: -1;
    width: 520px;
    height: 520px;
    border-radius: 50%;
    background: rgba(116, 98, 255, 0.12);
    content: "";
    filter: blur(70px);
    transform: translate(-50%, -50%);
}

.login-shell {
    width: min(440px, 100%);
    animation: rise-in 560ms var(--ease) both;
}

.login-brand {
    display: grid;
    place-items: center;
    margin-bottom: 24px;
    text-align: center;
}

.login-brand .brand-mark {
    width: 52px;
    height: 52px;
    margin-bottom: 15px;
    border-radius: 16px;
}

.login-brand .brand-mark::before {
    width: 17px;
    height: 21px;
}

.login-brand h1 {
    font-size: 1.55rem !important;
}

.login-brand p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.page-login form {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 24px !important;
    border: 1px solid var(--line) !important;
    border-radius: var(--radius-xl) !important;
    background: linear-gradient(145deg, rgba(24, 31, 51, 0.88), rgba(12, 16, 28, 0.94)) !important;
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px);
}

.page-login form h1 {
    display: none;
}

.page-login input,
.page-login button {
    margin-top: 12px !important;
    min-height: 50px;
}

.page-login .error {
    margin-top: 14px;
    padding: 11px 13px;
    border: 1px solid rgba(255, 107, 124, 0.25);
    border-radius: var(--radius-sm);
    background: rgba(255, 107, 124, 0.08);
    color: #ff9baa !important;
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes progress-shine {
    to {
        transform: translateX(100%);
    }
}

@media (max-width: 900px) {
    .topbar-inner {
        width: min(100% - 22px, 1440px);
        min-height: 62px;
        gap: 10px;
    }

    .brand-copy span,
    .brand-copy small,
    .system-state {
        display: none;
    }

    .topnav {
        flex: 1;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .topnav::-webkit-scrollbar {
        display: none;
    }

    .nav-link {
        padding: 0 10px;
        font-size: 12px;
    }

    .wrapper {
        width: min(100% - 22px, 1360px) !important;
        padding-top: 26px !important;
    }

    .page-hero {
        display: block;
    }

    h1 {
        font-size: clamp(1.9rem, 8vw, 3rem) !important;
    }

    .statistics {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .heading {
        gap: 10px;
    }
}

@media (max-width: 620px) {
    .topbar-inner {
        width: calc(100% - 14px);
    }

    .brand-mark {
        width: 31px;
        height: 31px;
    }

    .nav-link {
        height: 36px;
        padding: 0 8px;
    }

    .signout-button {
        padding: 0 9px !important;
    }

    .wrapper {
        width: calc(100% - 16px) !important;
        padding: 20px 0 40px !important;
    }

    .panel,
    .card,
    .category-card {
        padding: 14px !important;
        border-radius: 15px !important;
    }

    .filters {
        padding: 12px !important;
        border-radius: 16px !important;
    }

    .statistics,
    .stats {
        border-radius: 16px !important;
    }

    .stat,
    .statistic {
        padding: 14px 8px !important;
    }

    .heading,
    .item-row {
        flex-direction: column;
        align-items: stretch !important;
    }

    .heading-main {
        width: 100%;
    }

    .import-actions,
    .actions,
    .actions form {
        width: 100%;
    }

    .actions button,
    .import-actions button,
    .import-actions form {
        width: 100% !important;
    }

    .batch-actions,
    .snapshot-toolbar {
        align-items: stretch !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
