:root {
  --brand: #17767e;
  --brand-dark: #0f585e;
  --brand-soft: #e7f3f3;
  --ink: #1d2733;
  --muted: #667085;
  --line: #e3e8ec;
  --bg: #f4f6f7;
  --card: #fff;
  --success: #147a3d;
  --success-soft: #e6f4ea;
  --warning: #9a5b00;
  --warning-soft: #fff4dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --info: #175cd3;
  --info-soft: #e8f0fe;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Cairo", system-ui, sans-serif; font-size: 15px; line-height: 1.7; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .6rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
.wrap { width: min(1100px, 100% - 32px); margin-inline: auto; }
.narrow { width: min(680px, 100%); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: right; }
span.ltr, a.ltr { display: inline-block; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row.between { justify-content: space-between; }

.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 68px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .7rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { height: 46px; width: auto; }
.brand strong { display: block; font-size: 1.05rem; }
.brand small { display: block; color: var(--muted); font-size: .8rem; margin-top: -4px; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.nav a, .nav button { padding: .35rem .7rem; border-radius: 8px; color: var(--ink); font: inherit; background: none; border: 0; cursor: pointer; }
.nav a:hover, .nav button:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav form { margin: 0; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: .35rem .45rem; color: var(--ink); cursor: pointer; line-height: 0; }
.menu { position: relative; }
.menu > summary { list-style: none; display: flex; align-items: center; gap: .35rem; padding: .35rem .7rem; border-radius: 8px; cursor: pointer; font-weight: 400; user-select: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover, .menu[open] > summary { background: var(--bg); }
.menu > summary.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.menu .chev { opacity: .7; flex-shrink: 0; }
.menu[open] .chev { transform: rotate(180deg); }
.menu-list { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 50; min-width: 230px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(16, 24, 40, .12); padding: .35rem; display: grid; gap: 2px; }
.nav .menu-list a, .nav .menu-list button { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; width: 100%; text-align: start; padding: .5rem .7rem; border-radius: 7px; }
.menu-list a small { flex-basis: 100%; color: var(--muted); font-size: .75rem; margin-top: -4px; font-weight: 400; }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: .3rem .2rem; }
.menu-list .danger { color: var(--danger); }
.menu-list .danger:hover { background: var(--danger-soft) !important; }
.menu-head { padding: .5rem .7rem .6rem; display: grid; gap: .1rem; border-bottom: 1px solid var(--line); margin-bottom: .25rem; }
.menu-head small { color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.menu-head .badge { justify-self: start; margin-top: .3rem; }
.count { background: var(--danger); color: #fff; border-radius: 999px; font-size: .7rem; font-weight: 700; padding: 0 .45rem; line-height: 1.6; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: .9rem; }
.user-menu { margin-inline-start: .5rem; padding-inline-start: .5rem; border-inline-start: 1px solid var(--line); }
.user-menu > summary { padding: .2rem .4rem; }
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 900px) {
  .admin-header .wrap { flex-wrap: wrap; }
  .nav-toggle { display: inline-block; }
  .admin-header .nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; padding-bottom: .75rem; }
  .admin-header .nav.open { display: flex; }
  .admin-header .nav > a, .menu > summary { padding: .55rem .7rem; }
  .menu-list { position: static; box-shadow: none; border: 0; border-inline-start: 2px solid var(--line); border-radius: 0; margin: .2rem .8rem .4rem 0; min-width: 0; padding: 0 .3rem; }
  .user-menu { margin: .4rem 0 0; padding: .4rem 0 0; border-inline-start: 0; border-top: 1px solid var(--line); }
  .user-name { max-width: none; }
  .menu .chev { margin-inline-start: auto; }
}
main { padding: 1.5rem 0 3rem; }
.site-footer { border-top: 1px solid var(--line); padding: 1rem 0 1.5rem; color: var(--muted); font-size: .85rem; text-align: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.card + .card { margin-top: 1rem; }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.card-title h2 { margin: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 760px) {
  .grid, .grid.three, .grid.four { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
}

.field { display: flex; flex-direction: column; gap: .3rem; }
.field label { font-weight: 600; font-size: .9rem; }
.field .hint { color: var(--muted); font-size: .8rem; }
.field .error { color: var(--danger); font-size: .82rem; }
input, select, textarea { font: inherit; color: inherit; width: 100%; padding: .55rem .75rem; border: 1px solid #cfd6dc; border-radius: 8px; background: #fff; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[dir="ltr"] { text-align: right; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.check input { width: auto; }
.is-invalid { border-color: var(--danger); }
.filters { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1.1rem; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff; line-height: 1.5; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-light { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-light:hover { background: var(--bg); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8f1c13; }
.btn-sm { padding: .25rem .65rem; font-size: .85rem; }
.btn-lg { padding: .8rem 1.4rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.inline { display: inline; margin: 0; }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: #bfe3cb; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #f5c2bd; }
.alert-info { background: var(--info-soft); color: var(--info); border-color: #c6d8fb; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: #f3dca4; }
.alert ul { margin: 0; padding-inline-start: 1.1rem; }

.badge { display: inline-block; padding: .05rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--bg); color: var(--muted); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand-dark); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .75rem; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f9fafb; font-size: .82rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { display: block; font-size: 1.4rem; }
.stat small { color: var(--muted); }

.hero { text-align: center; margin-bottom: 1.25rem; }
.hero p { color: var(--muted); }
.ref-box { text-align: center; padding: 1.25rem; border: 2px dashed var(--brand); border-radius: var(--radius); background: var(--brand-soft); }
.ref-box span { display: block; color: var(--brand-dark); }
.ref-box strong { display: block; font-size: 2rem; letter-spacing: 3px; direction: ltr; }
.status-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.status-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); flex: none; }
.status-dot.success { background: var(--success); }
.status-dot.warning { background: #e0a100; }
.status-dot.danger { background: var(--danger); }
.test-banner { background: #3b1f6e; color: #fff; text-align: center; padding: .4rem; font-weight: 600; }
.pagination { display: flex; flex-wrap: wrap; gap: .3rem; list-style: none; padding: 0; margin: 1rem 0 0; }
.pagination a, .pagination span { display: block; padding: .2rem .65rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pagination .active span { background: var(--brand); color: #fff; border-color: var(--brand); }
pre { direction: ltr; text-align: left; background: #0f172a; color: #e2e8f0; padding: 1rem; border-radius: 8px; overflow: auto; font-size: .8rem; max-height: 420px; }
details summary { cursor: pointer; font-weight: 600; }

@media print {
  .site-header nav, .nav-toggle, .site-footer, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  .card { border: 0; }
}

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chips a { padding: .25rem .75rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-size: .85rem; }
.chips a:hover { text-decoration: none; border-color: var(--brand); }
.chips a.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; justify-content: space-between; margin-bottom: 1rem; }
.toolbar form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.toolbar input, .toolbar select { width: auto; }
.delta { font-size: .8rem; font-weight: 600; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.bars { display: grid; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .75rem; font-size: .9rem; }
.bar-row .track { grid-column: 1 / -1; height: 8px; background: #edf1f3; border-radius: 4px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--brand); border-radius: 4px; }
.bar-row .value { white-space: nowrap; font-weight: 600; }
.chart svg { width: 100%; height: auto; display: block; direction: ltr; }
.chart-grid { stroke: #eef1f3; stroke-width: 1; }
.chart-axis { stroke: #cfd6dc; stroke-width: 1; }
.chart-mark { fill: var(--brand); }
.chart-hit { fill: transparent; }
.chart-bar:hover .chart-mark { fill: var(--brand-dark); }
.chart-bar:hover .chart-hit { fill: #f3f7f7; }
.chart-label { font-size: 11px; fill: var(--muted); font-family: inherit; }
.callout { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.toolbar select { max-width: 280px; }
@media (max-width: 760px) {
  .toolbar form, .toolbar form > * { width: 100%; max-width: 100%; }
  .page-head form { width: 100%; }
  .page-head form input { flex: 1; width: auto !important; }
}
.grid > * { min-width: 0; }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
