:root {
  --ink: #16233b;
  --ink-2: #22324f;
  --brass: #b08d57;
  --brass-soft: #f3ebdd;
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #6b7280;
  --line: #e5e1d8;
  --ok: #1f7a4d;   --ok-bg: #e5f3ec;
  --warn: #9a6100; --warn-bg: #fdf1dc;
  --danger: #b42318; --danger-bg: #fdecea;
  --info: #1f4f8a; --info-bg: #e7eef8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(22,35,59,.06), 0 4px 16px rgba(22,35,59,.05);
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--ink-2); text-decoration: none; }
a:hover { color: var(--brass); }
h1, h2, h3 { margin: 0; line-height: 1.3; color: var(--ink); }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; margin-bottom: .9rem; }
.ico { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.ico.big { width: 2.6rem; height: 2.6rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
small { display: block; color: var(--muted); font-size: .82rem; }
code { font-family: ui-monospace, Consolas, monospace; background: var(--brass-soft); padding: .1rem .4rem; border-radius: 6px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: .55rem 1rem; border-radius: 10px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: var(--brass); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-2); color: #fff; }
.btn.ghost { background: transparent; }
.btn.light { background: #fff; color: var(--ink); border-color: transparent; }
.btn.danger-ghost { color: var(--danger); background: transparent; border-color: transparent; }
.btn.danger-ghost:hover { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.btn.sm { padding: .3rem .65rem; font-size: .85rem; border-radius: 8px; }
.btn.block { width: 100%; padding: .75rem; }
.icon-btn { display: inline-grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 9px; border: 0; background: transparent; color: var(--ink); cursor: pointer; font-size: 1.4rem; }
.icon-btn:hover { background: var(--brass-soft); }
.icon-btn.wa { color: #128c7e; }
.link { background: none; border: 0; color: var(--ink-2); font: inherit; cursor: pointer; text-decoration: underline; }

/* Forms */
.field { display: flex; flex-direction: column; gap: .3rem; }
.field > span { font-size: .87rem; font-weight: 500; color: var(--ink-2); }
input, select, textarea { font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: .6rem .75rem; width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px rgba(176,141,87,.18); }
input:disabled { background: var(--bg); color: var(--muted); }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .92rem; }
.check input { width: auto; }
.check.toggle { background: var(--brass-soft); padding: .65rem .8rem; border-radius: 10px; margin-bottom: 1rem; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1rem; }
.grid-form .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: .3rem; }

/* Auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, 1fr) minmax(340px, 1.2fr); }
.auth-side { background: var(--ink); color: #e9e4d8; padding: 3rem; display: flex; flex-direction: column; justify-content: center; gap: 1.5rem; background-image: radial-gradient(circle at 20% 110%, rgba(176,141,87,.25), transparent 50%); }
.auth-pitch { font-size: 1.2rem; max-width: 26ch; color: #fff; margin: 0; }
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.auth-points li { display: flex; gap: .6rem; align-items: center; color: #d6cfbf; }
.auth-points .ico { color: var(--brass); }
.auth-main { display: flex; flex-direction: column; padding: 1.5rem; }
.auth-top { display: flex; justify-content: flex-end; }
.auth-card { width: 100%; max-width: 440px; margin: auto; padding: 1rem 0 2rem; }
.auth-card h1 { margin-bottom: 1.2rem; }
.auth-card p { margin: 1rem 0 0; }

.brand { display: flex; align-items: center; gap: .7rem; }
.brand .ico { width: 2rem; height: 2rem; color: var(--brass); }
.brand strong { display: block; font-size: 1.15rem; color: #fff; }
.brand span { display: block; font-size: .8rem; color: #b9b2a3; max-width: 15ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand.big .ico { width: 2.8rem; height: 2.8rem; }
.brand.big strong { font-size: 1.7rem; }
.brand.big span { max-width: none; font-size: .95rem; }
.lang-btn { display: inline-flex; align-items: center; gap: .5rem; background: none; border: 0; font: inherit; cursor: pointer; color: inherit; padding: .5rem .6rem; border-radius: 8px; }
.auth-top .lang-btn { color: var(--ink); }
.lang-btn:hover { background: rgba(176,141,87,.15); }

.splash { min-height: 100vh; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.splash .ico { color: var(--brass); }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 250px; flex: none; background: var(--ink); color: #d6cfbf; display: flex; flex-direction: column; padding: 1.3rem 1rem; position: sticky; top: 0; height: 100vh; }
.sidebar nav { display: flex; flex-direction: column; gap: .2rem; margin-top: 2rem; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: .75rem; padding: .65rem .8rem; border-radius: 10px; color: #cfc8b8; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: rgba(176,141,87,.18); color: #fff; box-shadow: inset 3px 0 0 var(--brass); }
[dir="rtl"] .sidebar nav a.active { box-shadow: inset -3px 0 0 var(--brass); }
.sidebar-foot { display: flex; flex-direction: column; gap: .2rem; border-top: 1px solid rgba(255,255,255,.1); padding-top: 1rem; }
.me { padding: 0 .6rem .5rem; }
.me strong { color: #fff; display: block; font-weight: 500; }
.me span { font-size: .8rem; color: #a8a192; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.view { padding: 2rem 2.2rem 4rem; max-width: 1200px; width: 100%; }
.loading { color: var(--muted); padding: 2rem 0; }
.scrim { display: none; }

/* Banners */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 2.2rem; font-size: .93rem; }
.banner p { margin: .2rem 0 0; font-size: .88rem; }
.banner.info { background: var(--info-bg); color: var(--info); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.danger { background: var(--danger); color: #fff; padding-top: 1rem; padding-bottom: 1rem; }
.banner.danger strong { font-size: 1.02rem; }

/* Page */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.3rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: .6rem; color: var(--muted); font-size: .9rem; }
.back::before { content: "→ "; }
[dir="ltr"] .back::before { content: "← "; }
.meta-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin: -.6rem 0 1.2rem; color: var(--muted); }
.toolbar { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input[type=search] { max-width: 320px; }
.seg { display: inline-flex; background: #ebe7de; border-radius: 10px; padding: 3px; }
.seg a { padding: .4rem .9rem; border-radius: 8px; color: var(--muted); font-size: .9rem; font-weight: 500; }
.seg a.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; overflow-x: auto; }
.tabs a { padding: .65rem 1rem; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--brass); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.card.flush { padding: 0; overflow: hidden; }
.card .pad { padding: 1.1rem 1.3rem 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.card-head h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; align-items: start; }
.two-col .card { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.4rem; }
.stats.four { grid-template-columns: repeat(4, 1fr); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .3rem; color: var(--text); }
.stat span { color: var(--muted); font-size: .9rem; }
.stat strong { font-size: 2rem; color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; }
.stat:hover { border-color: var(--brass); color: var(--text); }
.stat.warn strong { color: var(--warn); }
.stat.danger strong { color: var(--danger); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: .8rem; font-weight: 600; color: var(--muted); padding: .75rem 1rem; background: #faf8f4; border-bottom: 1px solid var(--line); }
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:hover td { background: #fbf9f5; }
.table td small { display: inline; }
.table select { width: auto; padding: .35rem .5rem; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li > a:not(.icon-btn) { display: flex; align-items: center; gap: .9rem; flex: 1; min-width: 0; color: var(--text); justify-content: space-between; }
.list li > a:not(.icon-btn) > div { flex: 1; min-width: 0; }
.list li > a:not(.icon-btn):hover strong { color: var(--brass); }
.list li.past { opacity: .62; }
.list .day-sep { font-size: .8rem; font-weight: 600; color: var(--brass); text-transform: capitalize; padding: .9rem 0 .3rem; border-bottom: 0; }
.list .time { flex: none; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 3.4rem; font-size: .9rem; }
.row-main { display: flex; align-items: center; gap: .9rem; flex: 1; min-width: 0; }
.row-actions { display: flex; gap: .3rem; align-items: center; flex: none; }
.result { margin: .35rem 0 0; font-size: .9rem; white-space: pre-wrap; background: #faf8f4; padding: .5rem .7rem; border-radius: 8px; }
.big-check { width: 1.2rem; height: 1.2rem; accent-color: var(--ink); }
.presets { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-bottom: .5rem; }
.hint { font-size: .82rem; color: var(--muted); margin: 0 0 .8rem; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.2rem; margin: 0 0 1rem; }
.dl dt { color: var(--muted); font-size: .88rem; }
.dl dd { margin: 0; white-space: pre-wrap; }

.pill { display: inline-block; padding: .15rem .6rem; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill.ok, .st-open { background: var(--ok-bg); color: var(--ok); }
.pill.warn, .st-appeal { background: var(--warn-bg); color: var(--warn); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }
.pill.info, .st-judged { background: var(--info-bg); color: var(--info); }
.pill.muted, .st-archived { background: #eeece7; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.empty .ico { color: #d3ccbd; }
.empty p { margin: .4rem 0 0; }

.notice { padding: 1rem 1.1rem; border-radius: 10px; display: flex; gap: .7rem; align-items: flex-start; margin-bottom: 1rem; }
.notice p { margin: 0; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.err { background: var(--danger-bg); color: var(--danger); }

/* Plans */
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.plan { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.plan.featured { border-color: var(--brass); background: var(--brass-soft); }
.plan h3 { font-size: 1rem; color: var(--muted); font-weight: 500; }
.plan .price { font-size: 1.6rem; font-weight: 700; color: var(--ink); }
.code-row { display: flex; gap: .8rem; align-items: center; }
.invite { font-size: 1.4rem; letter-spacing: .2em; padding: .4rem .9rem; direction: ltr; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(22,35,59,.45); display: grid; place-items: center; padding: 1rem; z-index: 50; animation: fade .15s; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 480px; max-height: calc(100vh - 2rem); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-wide { max-width: 760px; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.3rem; border-bottom: 1px solid var(--line); }
.modal-body { padding: 1.3rem; overflow-y: auto; }
@keyframes fade { from { opacity: 0; } }

/* Toasts */
#toasts { position: fixed; bottom: 1.2rem; inset-inline-start: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 60; pointer-events: none; }
[dir="rtl"] #toasts { transform: translateX(50%); }
.toast { background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: all .25s; max-width: 90vw; }
.toast.show { opacity: 1; transform: none; }
.toast-err { background: var(--danger); }

/* Responsive */
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 1.6rem 1.2rem; gap: .8rem; }
  .auth-points { display: none; }
  .auth-pitch { font-size: 1rem; max-width: none; }
  .two-col, .plans { grid-template-columns: 1fr; }
  .stats.four { grid-template-columns: repeat(2, 1fr); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; transform: translateX(-105%); transition: transform .2s; }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  .nav-open .sidebar { transform: none !important; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }
  .topbar { display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .brand-mini { display: flex; align-items: center; gap: .4rem; font-weight: 700; color: var(--ink); }
  .brand-mini .ico { color: var(--brass); }
  .view { padding: 1.2rem 1rem 3rem; }
  .banner { padding: .7rem 1rem; flex-wrap: wrap; }
  h1 { font-size: 1.3rem; }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; gap: .7rem; }
  .stats .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat strong { font-size: 1.6rem; }
  .grid-form { grid-template-columns: 1fr; }
  .toolbar input[type=search] { max-width: none; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
  .table td { padding: .15rem 0; border: 0; display: flex; justify-content: space-between; gap: 1rem; }
  .table td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: .8rem; flex: none; }
  .table td:first-child::before { display: none; }
  .list li { flex-wrap: wrap; }
  .row-actions { width: 100%; justify-content: flex-end; }
  .dl { grid-template-columns: 1fr; gap: .1rem; }
  .dl dd { margin-bottom: .5rem; }
}
