:root {
    color-scheme: light;
    --ink: #14213d;
    --muted: #64748b;
    --line: #d7dee8;
    --panel: rgba(255, 255, 255, 0.88);
    --brand: #0f766e;
    --brand-dark: #115e59;
    --accent: #b45309;
    --error: #b91c1c;
    --success: #047857;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Noto Naskh Arabic", "Inter", system-ui, sans-serif;
    color: var(--ink);
    background:
        linear-gradient(145deg, rgba(15, 118, 110, 0.16), rgba(148, 163, 184, 0.18) 45%, rgba(180, 83, 9, 0.1)),
        #e8eff1;
}

body.ltr,
[dir="ltr"] {
    font-family: "Inter", "Noto Naskh Arabic", system-ui, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.auth-shell,
.form-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 22px;
}

.glass {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.76);
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(18px);
}

.auth-card,
.form-panel {
    width: min(100%, 500px);
    border-radius: 18px;
    padding: 30px;
}

.form-panel {
    width: min(100%, 760px);
}

.form-page .form-panel {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    padding: 30px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.18);
}

.form-page .form-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: linear-gradient(90deg, var(--brand), var(--accent));
}

.brand-logo {
    width: 92px;
    height: 92px;
    object-fit: contain;
    display: block;
    margin: 0 auto 16px;
}

.form-heading {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(215, 222, 232, 0.82);
}

.form-title-block {
    display: grid;
    grid-column: 2;
    justify-items: center;
    gap: 12px;
    min-width: 0;
}

.form-logo {
    width: 82px;
    height: 82px;
    margin: 0;
    filter: drop-shadow(0 10px 16px rgba(15, 23, 42, 0.14));
}

.form-title-block h1 {
    margin-bottom: 0;
    text-align: center;
    color: #0f3f3a;
    font-size: 26px;
    font-weight: 800;
}

.form-heading > .pill {
    grid-column: 3;
    justify-self: end;
    align-self: start;
    padding: 10px 14px;
    font-size: 13px;
    background: #475569;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0 0 22px;
    font-size: 30px;
    line-height: 1.2;
}

.stack,
.grid-form {
    display: grid;
    gap: 16px;
}

.grid-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.full-span {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 6px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 46px;
    border: 1px solid #cfd9e4;
    border-radius: 10px;
    padding: 11px 13px;
    background: linear-gradient(180deg, #ffffff, #fbfdff);
    color: var(--ink);
    font: inherit;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.02);
}

input:focus,
select:focus {
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

input[readonly] {
    background: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
}

.date-parts {
    display: grid;
    grid-template-columns: minmax(54px, 0.72fr) minmax(54px, 0.72fr) minmax(86px, 1fr);
    gap: 8px;
    direction: ltr;
}

.date-parts input {
    min-width: 0;
    text-align: center;
    font-weight: 800;
}

.date-parts input::placeholder {
    color: #7890a8;
    font-weight: 700;
}

.native-searchable-select {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.searchable-select {
    position: relative;
    width: 100%;
    min-width: 0;
}

.searchable-select.is-open {
    z-index: 30;
}

.searchable-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 46px;
    border: 1px solid #cfd9e4;
    border-radius: 10px;
    padding: 11px 13px;
    background: linear-gradient(180deg, #ffffff, #fbfdff);
    color: var(--ink);
    box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.02);
    text-align: right;
}

.searchable-select.is-open .searchable-select-trigger {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.searchable-select-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.searchable-select-icon {
    flex: 0 0 auto;
    color: var(--brand);
    font-family: "Inter", system-ui, sans-serif;
    font-size: 18px;
    font-weight: 800;
}

.searchable-select-panel {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 8px);
    z-index: 20;
    display: none;
    width: 100%;
    max-width: 100%;
    padding: 10px;
    border: 1px solid #cfd9e4;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 22px 48px rgba(15, 23, 42, 0.18);
}

.searchable-select.is-open .searchable-select-panel {
    display: block;
}

.searchable-select-search {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    margin-bottom: 8px;
    border-color: #b8c7d6;
    background: #f8fafc;
}

.searchable-select-list {
    max-height: 240px;
    overflow: auto;
    display: grid;
    gap: 4px;
    overscroll-behavior: contain;
}

.searchable-select-option {
    width: 100%;
    max-width: 100%;
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 9px 10px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

.searchable-select-option:hover,
.searchable-select-option.is-selected {
    background: #ecfdf5;
    color: var(--brand-dark);
}

.searchable-select-empty {
    padding: 14px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-align: center;
}

button,
.pill {
    border: 0;
    border-radius: 10px;
    padding: 13px 18px;
    background: var(--brand);
    color: white;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    text-align: center;
}

button:hover,
.pill:hover {
    background: var(--brand-dark);
}

.secondary-pill {
    background: #475569;
}

.secondary-pill:hover {
    background: #334155;
}

.grid-form button {
    grid-column: 1 / -1;
    min-height: 50px;
    margin-top: 4px;
    background: linear-gradient(135deg, #0f766e, #0d9488);
    box-shadow: 0 16px 28px rgba(15, 118, 110, 0.24);
}

.polling-center-preview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
    border: 1px solid #cfe6e1;
    border-radius: 10px;
    background: #f0fdfa;
}

.polling-center-preview div {
    display: grid;
    gap: 2px;
}

.polling-center-preview span {
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
}

.polling-center-preview strong {
    color: #0f3f3a;
    font-size: 13px;
    font-weight: 800;
}

.grid-form button:hover {
    transform: translateY(-1px);
}

.searchable-select .searchable-select-trigger {
    background: linear-gradient(180deg, #ffffff, #fbfdff);
    color: var(--ink);
    box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.02);
}

.searchable-select .searchable-select-trigger:hover {
    background: #fff;
}

.searchable-select .searchable-select-option {
    background: transparent;
    color: var(--ink);
    box-shadow: none;
}

.searchable-select .searchable-select-option:hover,
.searchable-select .searchable-select-option.is-selected {
    background: #ecfdf5;
    color: var(--brand-dark);
    transform: none;
}

.admin-link,
.muted-link {
    display: block;
    margin-top: 18px;
    color: var(--muted);
    text-align: center;
    font-weight: 700;
}

.alert {
    border-radius: 12px;
    margin: 0 0 14px;
    padding: 12px 14px;
    font-weight: 700;
}

.alert.error {
    color: var(--error);
    background: #fee2e2;
}

.alert.success {
    color: var(--success);
    background: #d1fae5;
}

.otp-code {
    margin: 0 0 16px;
    padding: 18px;
    border: 1px dashed var(--brand);
    border-radius: 14px;
    background: #ecfdf5;
    color: var(--brand-dark);
    font-family: "Inter", monospace;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: 8px;
    text-align: center;
}

.panel-heading,
.admin-topbar,
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.admin-shell {
    min-height: 100vh;
    padding: 28px;
}

.admin-topbar {
    margin: 0 auto 20px;
    max-width: 1280px;
}

.admin-topbar nav {
    display: flex;
    gap: 10px;
}

.stats-row {
    max-width: 1280px;
    margin: 0 auto 18px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.admin-tabs {
    max-width: 1280px;
    margin: 0 auto 18px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--line);
}

.admin-tabs a {
    border: 1px solid transparent;
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    padding: 12px 16px;
    color: var(--muted);
    font-weight: 800;
}

.admin-tabs a.active {
    background: #fff;
    border-color: var(--line);
    color: var(--brand-dark);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.04);
}

.stat-card,
.sheet-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 14px 45px rgba(15, 23, 42, 0.08);
}

.stat-card {
    padding: 18px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 26px;
}

.sheet-card {
    max-width: 1280px;
    margin: 0 auto;
    overflow: hidden;
}

.toolbar {
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.toolbar input {
    max-width: 460px;
}

.toolbar a {
    color: var(--muted);
    font-weight: 800;
}

.toolbar-note {
    display: inline-block;
    margin-left: 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.table-wrap {
    overflow: auto;
    max-height: calc(100vh - 310px);
}

table {
    width: 100%;
    min-width: 980px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

th,
td {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 11px 12px;
    text-align: left;
    white-space: nowrap;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fafc;
    color: #334155;
    font-weight: 800;
}

td {
    background: #fff;
}

tr:hover td {
    background: #f0fdfa;
}

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

.duplicate-ip {
    background: #fef3c7 !important;
    color: #92400e;
    font-weight: 800;
}

.user-agent-cell {
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inline-delete {
    display: inline-flex;
    margin: 0;
}

.icon-danger {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 0;
    background: #fff1f2;
    color: var(--error);
    font-family: "Inter", system-ui, sans-serif;
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
}

.icon-danger:hover {
    background: #fee2e2;
    color: #7f1d1d;
}

.directors-table {
    min-width: 680px;
}

.rtl-cell {
    font-family: "Noto Naskh Arabic", "Inter", system-ui, sans-serif;
    font-size: 15px;
    text-align: right;
}

@media (max-width: 720px) {
    .auth-card,
    .form-panel {
        padding: 22px;
        border-radius: 14px;
    }

    .form-shell {
        align-items: start;
        padding: 16px 8px;
    }

    .form-page .form-panel {
        width: min(100%, 420px);
        padding: 22px 14px 14px;
        border-radius: 10px;
    }

    .form-heading {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 16px;
        padding-bottom: 14px;
    }

    .form-title-block {
        grid-column: 1;
    }

    .form-heading > .pill {
        grid-column: 1;
        justify-self: stretch;
        order: 2;
        padding: 9px 12px;
    }

    .form-logo {
        width: 76px;
        height: 76px;
    }

    h1 {
        font-size: 24px;
    }

    .form-title-block h1 {
        font-size: 19px;
    }

    .grid-form,
    .stats-row {
        grid-template-columns: 1fr;
    }

    .grid-form {
        gap: 12px;
    }

    .polling-center-preview {
        grid-template-columns: 1fr;
    }

    label {
        font-size: 12px;
    }

    input,
    select {
        min-height: 44px;
        border-radius: 8px;
    }

    .searchable-select-trigger {
        min-height: 44px;
        border-radius: 8px;
    }

    .searchable-select-panel {
        position: absolute;
        inset: auto 0 auto 0;
        top: calc(100% + 8px);
        max-height: min(54vh, 420px);
        border-radius: 14px;
        padding: 12px;
    }

    .searchable-select-list {
        max-height: calc(min(54vh, 420px) - 72px);
    }

    .searchable-select-option {
        min-height: 46px;
        font-size: 14px;
    }

    .grid-form button {
        border-radius: 8px;
    }

    .panel-heading,
    .admin-topbar,
    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .admin-tabs {
        flex-direction: column;
        border-bottom: 0;
    }

    .admin-tabs a {
        border: 1px solid var(--line);
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.74);
    }

    .admin-shell {
        padding: 18px;
    }
}
