:root {
  --bg: #f4f5f7; --card: #fff; --ink: #14171f; --muted: #6b7280; --line: #e3e5ea;
  --brand: #0f766e; --brand-ink: #fff; --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --info: #1d4ed8; --frozen: #0e7490;
  --r: 10px; --pad: 16px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", sans-serif; line-height: 1.4; }
[dir="rtl"] body, html[dir="rtl"] { font-family: system-ui, "Segoe UI", "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 14px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }
.inline { display: inline; }
.num { text-align: end; font-variant-numeric: tabular-nums; }

/* header */
.top { display: flex; align-items: center; gap: 14px; padding: 8px var(--pad); background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font-size: .8rem; letter-spacing: .5px; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--ink); font-weight: 500; }
.nav a.on { background: #e6f4f2; color: var(--brand); }
.tools { margin-inline-start: auto; display: flex; align-items: center; gap: 12px; }
.lang { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-weight: 600; }
.who { font-weight: 600; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }

.flash { margin: 10px var(--pad) 0; padding: 10px 14px; border-radius: var(--r); background: #dcfce7; color: #14532d; font-weight: 500; }
.flash.warn { background: #fef3c7; color: #78350f; }
.main { padding: var(--pad); max-width: 1180px; margin: 0 auto; }

/* cards & forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: var(--pad); margin-bottom: 14px; }
.card.empty { text-align: center; padding: 40px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
input, select { font: inherit; padding: 10px 12px; border: 1px solid #cfd3da; border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
button, .btn { font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 8px; border: 1px solid #cfd3da; background: #fff; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { text-decoration: none; }
button.primary, .btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
button.warn { background: var(--warn); color: #fff; border-color: var(--warn); }
button.ghost, .btn.ghost { background: transparent; }
.big { padding: 14px 22px; font-size: 1.05rem; }
.small-btn { padding: 6px 10px; font-size: .85rem; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radios { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.radios legend { font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
.radios label { flex-direction: row; align-items: center; color: var(--ink); }
.radios input { width: auto; }
.error { color: var(--bad); font-weight: 600; }
.warn-box { background: #fef3c7; color: #78350f; padding: 8px 12px; border-radius: 8px; margin: 0; font-weight: 600; }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: #eef0f3; color: var(--muted); }
.badge.big { font-size: .95rem; padding: 6px 14px; }
.badge.active { background: #dcfce7; color: var(--ok); }
.badge.expiring { background: #fef3c7; color: var(--warn); }
.badge.expired, .badge.none { background: #fee2e2; color: var(--bad); }
.badge.frozen { background: #cffafe; color: var(--frozen); }
.badge.due { background: #fee2e2; color: var(--bad); }
.badge.inactive { background: #e0e7ff; color: var(--info); }
.count { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 999px; background: #eef0f3; color: var(--muted); font-size: .8rem; text-align: center; vertical-align: middle; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #eef0f3; }

/* login */
.login { max-width: 360px; margin: 8vh auto; text-align: center; }
.login h1 { font-size: 1.6rem; }
.login input { text-align: center; font-size: 1.6rem; letter-spacing: .4em; }

/* reception */
.reception-grid { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 16px; align-items: start; }
.search { display: flex; gap: 8px; }
.search input { font-size: 1.1rem; }
.search .btn { white-space: nowrap; }
.results { list-style: none; margin: 8px 0 0; padding: 0; }
.results li a { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: 6px; color: var(--ink); }
.results li a:hover, .results li a:focus { border-color: var(--brand); text-decoration: none; outline: none; }
.results .rname { font-weight: 600; }
.results .rphone { color: var(--muted); font-size: .85rem; grid-row: 2; }
.results .badge { grid-column: 2; grid-row: 1; justify-self: end; }
.results .badge.due { grid-row: 2; }
.member-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.mname { font-size: 1.5rem; margin: 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 14px; }
.facts div { background: #f8f9fb; border-radius: 8px; padding: 8px 10px; }
.facts dt { font-size: .78rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.facts .hl { background: #e6f4f2; }
.primary-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: stretch; }
.checkin-form { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; align-items: center; }
.checkin-form input { flex: 1; min-width: 200px; }
.panel { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.panel summary { padding: 10px 14px; cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
.panel summary::after { content: "+"; color: var(--muted); }
.panel[open] summary::after { content: "−"; }
.panel form { padding: 4px 14px 14px; }

/* tables */
.tbl { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
th { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr.bad td { background: #fff7ed; }
table.compact th, table.compact td { padding: 6px 6px; }

/* shift */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
#diff { font-size: 1.1rem; }
#diff.neg { color: var(--bad); }
#diff.pos { color: var(--ok); }
.plain { list-style: none; padding: 0; margin: 0; }

/* worklist */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.tabs a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; margin-inline-end: 6px; color: var(--ink); }
.tabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tasks .task { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 12px 14px; }
.task-main { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.tname { font-weight: 600; color: var(--ink); }
.tphone { color: var(--muted); }
.task-ctl { display: flex; gap: 6px; }
.task-ctl select { width: auto; padding: 7px 8px; }
.task-ctl button { padding: 7px 12px; }

/* owner (phone-first) */
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: #f8f9fb; border-radius: 8px; padding: 10px; display: flex; flex-direction: column; }
.kpi .k { font-size: .75rem; color: var(--muted); }
.kpi .v { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi.total { background: #e6f4f2; }
.kpi.total .v { color: var(--brand); }
.card details > summary { cursor: pointer; padding: 6px 0; font-weight: 600; }
.card details > summary h2 { display: inline; }
.list { list-style: none; margin: 8px 0 0; padding: 0; }
.list li { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li a { font-weight: 600; }
.list li .small { grid-column: 1; }
.list li > strong, .list li > span:last-child { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.list.audit li { grid-template-columns: auto 1fr; }
.list.audit .what { font-weight: 600; }
.list.audit .why { grid-column: 2; }
.list.audit .who-when { grid-column: 2; }
.list.audit .badge { grid-row: 1 / span 3; align-self: start; }

@media (max-width: 800px) {
  .reception-grid, .two-col { grid-template-columns: 1fr; }
  .tasks .task { grid-template-columns: 1fr; }
  .task-ctl { flex-wrap: wrap; }
  .task-ctl select { flex: 1; }
}
@media (max-width: 520px) {
  html { font-size: 15px; }
  .brand-name { display: none; }
  .top { gap: 8px; }
  .nav a { padding: 6px 8px; }
  .who { display: none; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .row2 { grid-template-columns: 1fr; }
  .mname { font-size: 1.25rem; }
  .facts { grid-template-columns: 1fr 1fr; }
  .main { padding: 12px; }
}
