/* Cairo (SIL Open Font License 1.1), self-hosted so no third party sees visitor IPs. */
@font-face {
    font-family: "Cairo";
    font-style: normal;
    font-display: swap;
    font-weight: 200 1000;
    src: url("../fonts/cairo-arabic-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

@font-face {
    font-family: "Cairo";
    font-style: normal;
    font-display: swap;
    font-weight: 200 1000;
    src: url("../fonts/cairo-latin-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --bg: #f3f6f7;
    --surface: #ffffff;
    --surface-quiet: #eef3f4;
    --text: #15252b;
    --muted: #546870;
    --border: #d7e0e3;
    --primary: #0d6b70;
    --primary-hover: #0a5559;
    --on-primary: #ffffff;
    --focus: #2a8cf0;
    --ok: #1b7348;
    --ok-bg: #e5f3eb;
    --info: #1f4e8c;
    --info-bg: #e7eefa;
    --warn: #8a5300;
    --warn-bg: #fdf3df;
    --danger: #b3261e;
    --danger-hover: #8f1e18;
    --danger-bg: #fcebea;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgb(16 40 48 / 6%), 0 4px 16px rgb(16 40 48 / 5%);
    --font: "Cairo", "Geeza Pro", "Segoe UI", Tahoma, system-ui, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1719;
        --surface: #172226;
        --surface-quiet: #142024;
        --text: #e4ecee;
        --muted: #9fb2b8;
        --border: #2a3a3f;
        --primary: #3bb3b0;
        --primary-hover: #57c6c3;
        --on-primary: #06201f;
        --focus: #6ab4ff;
        --ok: #6fd3a0;
        --ok-bg: #143327;
        --info: #9cc0f5;
        --info-bg: #172a45;
        --warn: #f2c26b;
        --warn-bg: #3a2c12;
        --danger: #ff8a80;
        --danger-hover: #ffa69e;
        --danger-bg: #3d1a18;
        --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.75;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    padding-block: 2rem 3rem;
}

h1,
h2 {
    line-height: 1.35;
    margin: 0 0 .75rem;
}

h1 {
    font-size: clamp(1.6rem, 4vw, 2.25rem);
    font-weight: 800;
}

h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

p {
    margin: 0 0 .75rem;
}

a {
    color: var(--primary);
    text-underline-offset: 3px;
}

a:hover {
    color: var(--primary-hover);
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

.container {
    width: 100%;
    max-width: 1040px;
    margin-inline: auto;
    padding-inline: 1rem;
}

.container-wide {
    max-width: 1320px;
}

.muted {
    color: var(--muted);
}

.mono {
    font-family: var(--mono);
    font-size: .9em;
}

.nowrap {
    white-space: nowrap;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    inset-inline-start: 1rem;
    top: -3rem;
    background: var(--primary);
    color: var(--on-primary);
    padding: .5rem 1rem;
    border-radius: var(--radius-sm);
    z-index: 10;
}

.skip-link:focus {
    top: 1rem;
}

/* Header & footer */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem 1.5rem;
    min-height: 64px;
    padding-block: .5rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    color: var(--text);
    font-weight: 800;
    font-size: 1.1rem;
    text-decoration: none;
}

.brand:hover {
    color: var(--text);
}

.brand-icon {
    color: var(--primary);
    flex: none;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem 1.25rem;
}

.site-nav a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
    color: var(--primary);
}

.site-nav a[aria-current="page"] {
    text-decoration: underline;
    text-decoration-thickness: 2px;
}

.site-footer {
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .9rem;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .5rem 1.5rem;
    padding-block: 1.25rem;
}

.footer-inner p {
    margin: 0;
}

/* Hero & status */

.hero {
    margin-bottom: 1.75rem;
}

.lead {
    font-size: 1.1rem;
    color: var(--muted);
    max-width: 62ch;
}

.status-bar {
    list-style: none;
    margin: 1.25rem 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .9rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: .95rem;
}

.status-dot {
    width: .6rem;
    height: .6rem;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.status-ok {
    background: var(--ok-bg);
    color: var(--ok);
}

.status-info {
    background: var(--info-bg);
    color: var(--info);
}

/* Cards & layout */

.layout-grid {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

@media (min-width: 860px) {
    .layout-grid {
        grid-template-columns: 1.1fr 1fr;
        align-items: start;
    }
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.card-quiet {
    background: var(--surface-quiet);
    box-shadow: none;
}

.card-quiet p:last-child {
    margin-bottom: 0;
}

.tips {
    margin: 0;
    padding-inline-start: 1.25rem;
    display: grid;
    gap: .9rem;
}

.tips li::marker {
    color: var(--primary);
    font-weight: 700;
}

.tips strong {
    display: block;
}

.optional {
    color: var(--muted);
    font-weight: 400;
    font-size: .9em;
}

.prose {
    max-width: 780px;
}

.prose h2 {
    margin-top: 1.75rem;
}

.prose ul {
    padding-inline-start: 1.25rem;
    margin: 0 0 .75rem;
}

/* Forms */

.form {
    display: grid;
    gap: 1.1rem;
}

.field {
    display: grid;
    gap: .35rem;
}

.field label {
    font-weight: 600;
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .6rem .8rem;
    min-height: 44px;
}

input[dir="ltr"] {
    text-align: left;
}

input::placeholder {
    color: var(--muted);
    opacity: .7;
}

input:focus,
select:focus {
    border-color: var(--primary);
    outline: 3px solid color-mix(in srgb, var(--primary) 25%, transparent);
    outline-offset: 0;
}

input[aria-invalid="true"] {
    border-color: var(--danger);
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    font-weight: 400 !important;
    cursor: pointer;
}

.checkbox input {
    width: 1.2rem;
    height: 1.2rem;
    margin-top: .35rem;
    accent-color: var(--primary);
    flex: none;
}

.hint {
    margin: 0;
    color: var(--muted);
    font-size: .9rem;
}

.field-error {
    margin: 0;
    color: var(--danger);
    font-size: .9rem;
    font-weight: 600;
}

.form-note {
    margin: 0;
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--warn-bg);
    color: var(--warn);
    font-size: .92rem;
}

/* Honeypot: hidden from people, visible to naive bots. */
.hp {
    position: absolute;
    inset-inline-start: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 44px;
    padding: .55rem 1.2rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}

.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: var(--on-primary);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-link {
    background: none;
    border: 0;
    padding: .25rem .25rem;
    min-height: 0;
    color: var(--muted);
    font-weight: 600;
}

.btn-link:hover {
    color: var(--primary);
}

.btn-danger-text {
    color: var(--danger);
}

.btn-danger-text:hover {
    color: var(--danger-hover);
}

.btn-block {
    width: 100%;
}

.btn.is-disabled {
    opacity: .5;
    pointer-events: none;
}

.btn[disabled] {
    cursor: progress;
    opacity: .8;
}

.form .btn-primary {
    justify-self: start;
}

.form .btn-block {
    justify-self: stretch;
}

.spinner,
.btn-loading-label {
    display: none;
}

.spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-inline-end-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.is-loading .spinner,
.is-loading .btn-loading-label {
    display: inline-block;
}

.is-loading .btn-label {
    display: none;
}

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

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 2s;
    }
}

/* Alerts */

.alert {
    border-radius: var(--radius-sm);
    padding: .8rem 1rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.alert ul {
    margin: 0;
    padding-inline-start: 1.25rem;
    font-weight: 400;
}

.alert p {
    margin-bottom: .35rem;
}

.alert-success {
    background: var(--ok-bg);
    color: var(--ok);
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
}

.notice {
    background: var(--info-bg);
    color: var(--info);
    border-radius: var(--radius-sm);
    padding: .8rem 1rem;
    font-size: .95rem;
}

/* Error pages */

.error-page {
    text-align: center;
    max-width: 560px;
    margin: 2rem auto;
}

.error-code {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0;
    line-height: 1.2;
}

/* Admin */

.auth-card {
    max-width: 420px;
    margin: 2rem auto;
}

.page-head {
    margin-bottom: 1.25rem;
}

.page-head p {
    margin: 0;
}

.stats {
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: .75rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    display: grid;
    gap: .15rem;
}

.stat-label {
    color: var(--muted);
    font-size: .9rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.filters {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
    margin-bottom: 1rem;
    padding: 1.1rem;
}

.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

.table th,
.table td {
    padding: .65rem .9rem;
    text-align: start;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table td[dir="ltr"] {
    text-align: end;
}

.table th {
    background: var(--surface-quiet);
    font-weight: 700;
    white-space: nowrap;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table .truncate {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table .empty {
    text-align: center;
    color: var(--muted);
    padding: 2rem;
}

.badge {
    display: inline-block;
    padding: .1rem .55rem;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.badge-ok {
    background: var(--ok-bg);
    color: var(--ok);
}

.badge-warn {
    background: var(--warn-bg);
    color: var(--warn);
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.danger-zone {
    border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}

.inline-form {
    display: inline;
    margin: 0;
}

.inline-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
}

.input-short {
    width: 6.5rem !important;
}
