/* ------------------------------------------------------------------ base */
:root {
  --green-900: #0b3d2e;
  --green-700: #0f6b4f;
  --green-600: #13845f;
  --green-100: #e3f2ec;
  --green-50: #f1f8f5;
  --gold: #c98a12;
  --gold-100: #fbf0d9;
  --red: #c0392b;
  --red-100: #fbe6e3;
  --amber: #b7791f;
  --amber-100: #fdf3dc;
  --ink: #1d2a26;
  --ink-2: #4c5a55;
  --ink-3: #7b8883;
  --line: #dfe6e3;
  --bg: #f4f7f5;
  --card: #fff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 40, 32, .06), 0 4px 16px rgba(16, 40, 32, .06);
  --side-w: 248px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --urdu: "Jameel Noori Nastaleeq", "Noto Nastaliq Urdu", "Urdu Typesetting", "Segoe UI", serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--green-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }
img { max-width: 100%; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
[hidden] { display: none !important; }
.ic { width: 20px; height: 20px; flex: none; }
.urdu { font-family: var(--urdu); direction: rtl; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ shell */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.side {
  width: var(--side-w); background: var(--green-900); color: #d6e9e1; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; height: 100dvh; flex: none; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.brand img { border-radius: 9px; }
.brand b { display: block; color: #fff; font-size: 1rem; }
.brand small { color: #9fc7b8; }
.side nav { flex: 1; overflow: auto; padding: 6px 10px; }
.side nav a, .side-foot a, .side-foot button {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; color: #cfe5dc;
  font: inherit; background: none; border: 0; width: 100%; cursor: pointer; text-align: left;
}
.side nav a:hover, .side-foot a:hover, .side-foot button:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.side nav a.on { background: var(--green-700); color: #fff; }
.side-foot { padding: 8px 10px 14px; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot form { margin: 0; }
.side .side-close { display: none; margin-left: auto; color: #fff; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; gap: 10px; padding: 12px 24px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.top h1 { font-size: 1.15rem; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0;
  background: transparent; color: var(--ink-2); cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--green-50); color: var(--green-700); }
.bell .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--red);
  color: #fff; font: 700 10px/16px var(--font); font-style: normal; padding: 0 4px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--green-100); color: var(--green-900); display: grid;
  place-items: center; font-weight: 700; font-size: .85rem; text-decoration: none !important; }
.content { padding: 24px; max-width: 1200px; width: 100%; }
.scrim { display: none; }
.tabbar { display: none; }

/* ------------------------------------------------------------------ components */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card > h2:first-child, .card-head h2 { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat b { display: block; font-size: 1.6rem; color: var(--green-900); line-height: 1.2; }
.stat span { color: var(--ink-3); font-size: .85rem; }
.stat.warn b { color: var(--red); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; min-height: 42px;
  border-radius: 10px; border: 1px solid transparent; font: 600 .93rem var(--font); cursor: pointer;
  background: var(--green-700); color: #fff; text-decoration: none !important; white-space: nowrap;
}
.btn:hover { background: var(--green-600); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-light { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-light:hover { background: var(--green-50); }
.btn-gold { background: var(--gold); }
.btn-gold:hover { background: #b37a0f; }
.btn-red { background: var(--red); }
.btn-red:hover { background: #a93226; }
.btn-ghost { background: transparent; color: var(--green-700); }
.btn-ghost:hover { background: var(--green-50); }
.btn-sm { padding: 6px 11px; min-height: 34px; font-size: .85rem; border-radius: 8px; }
.btn-lg { padding: 14px 22px; min-height: 52px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.b-ok { background: var(--green-100); color: var(--green-900); }
.b-bad { background: var(--red-100); color: var(--red); }
.b-warn { background: var(--amber-100); color: var(--amber); }
.b-muted { background: #eceff0; color: var(--ink-2); }
.b-live { background: var(--red); color: #fff; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .65; } }

.flash { margin: 16px 24px 0; padding: 12px 16px; border-radius: 10px; background: var(--green-100); color: var(--green-900); font-weight: 600; }
.flash-error { background: var(--red-100); color: var(--red); }
.toasts { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 200; width: min(92vw, 420px); }
.toast { background: var(--green-900); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.2); font-weight: 600; animation: toastIn .2s ease-out; }
.toast.err { background: var(--red); }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

.live-banner { margin: 16px 24px 0; padding: 14px 18px; border-radius: 12px; background: linear-gradient(90deg, var(--green-900), var(--green-700)); color: #fff;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; box-shadow: var(--shadow); }
.live-banner b { font-size: 1.05rem; }
.live-banner .btn { margin-left: auto; background: var(--gold); }

/* forms */
.form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
label.f { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
label.f small { font-weight: 400; color: var(--ink-3); }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number], input[type=time], input[type=date],
input[type=month], input[type=url], input[type=search], select, textarea {
  width: 100%; font: 15px var(--font); color: var(--ink); background: #fff; border: 1px solid #cfd8d4; border-radius: 9px;
  padding: 10px 12px; min-height: 42px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 107, 79, .25); border-color: var(--green-700); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; }
.check input { width: 18px; height: 18px; accent-color: var(--green-700); }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { display: flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: .88rem; cursor: pointer; }
.days input { accent-color: var(--green-700); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters label.f { min-width: 150px; }

/* tables: become cards on narrow screens */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.t th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.t td { padding: 11px 10px; border-bottom: 1px solid #edf1ef; vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.act { text-align: right; white-space: nowrap; }
.empty { text-align: center; padding: 28px 12px; color: var(--ink-3); }
.empty .ic { width: 36px; height: 36px; color: #b9c7c1; margin-bottom: 6px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 8px 14px; border-radius: 99px; background: var(--card); color: var(--ink-2); font-weight: 600; font-size: .9rem; box-shadow: var(--shadow); text-decoration: none; }
.tabs a.on { background: var(--green-700); color: #fff; }

.list { display: grid; gap: 10px; }
.item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; flex-wrap: wrap; }
.item .who { flex: 1; min-width: 160px; }
.item .who b { display: block; }
.item .when { font-weight: 700; color: var(--green-900); min-width: 76px; }
.person { display: flex; align-items: center; gap: 10px; }
.person .avatar { width: 34px; height: 34px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 600; }

dialog.modal { border: 0; border-radius: 14px; padding: 0; width: min(560px, 94vw); max-height: 88vh; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog.modal::backdrop { background: rgba(10, 30, 24, .45); }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; flex: 1; }
.modal-body { padding: 18px; overflow: auto; max-height: calc(88vh - 60px); }

/* login */
body.bare { background: radial-gradient(1200px 600px at 80% -10%, #1a5c46 0, var(--green-900) 55%); min-height: 100vh; }
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card { background: #fff; border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 32px 28px; width: min(420px, 100%); }
.auth-card .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-card .logo img { border-radius: 12px; }
.auth-card .logo b { font-size: 1.25rem; display: block; color: var(--green-900); }
.auth-err { background: var(--red-100); color: var(--red); padding: 10px 12px; border-radius: 9px; font-weight: 600; }
.auth-foot { color: #9fc7b8; text-align: center; margin-top: 16px; font-size: .85rem; }

/* dashboard */
.hero { background: linear-gradient(120deg, var(--green-900), var(--green-700)); color: #fff; border-radius: 16px; padding: 22px 24px; margin-bottom: 20px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.hero h2 { color: #fff; font-size: 1.35rem; margin: 0 0 4px; }
.hero p { margin: 0; color: #cfe5dc; }
.hero .btn { margin-left: auto; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.quick a { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 8px; color: var(--ink); font-weight: 600; text-decoration: none; }
.quick a:hover { border-color: var(--green-700); background: var(--green-50); }
.quick .ic { width: 28px; height: 28px; color: var(--green-700); }
.note { background: var(--gold-100); border-radius: 10px; padding: 12px 14px; }
.note b { color: #7a5408; }

.audio-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); display: inline-block; animation: pulse 1s infinite; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1000px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .side { position: fixed; left: 0; top: 0; transform: translateX(-105%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .side .side-close { display: inline-grid; }
  .menu-btn { display: inline-grid; }
  .top { padding: 10px 12px; }
  .content { padding: 16px 14px calc(84px + var(--safe-b)); }
  .flash, .live-banner { margin: 12px 14px 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + var(--safe-b)); z-index: 30; box-shadow: 0 -4px 16px rgba(0,0,0,.05);
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font: 600 .7rem var(--font); color: var(--ink-3);
    background: none; border: 0; padding: 4px 2px; text-decoration: none; cursor: pointer; min-width: 0;
  }
  .tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar .on { color: var(--green-700); }
  .tabbar .ic { width: 22px; height: 22px; }
  table.t.stack thead { display: none; }
  table.t.stack, table.t.stack tbody, table.t.stack tr, table.t.stack td { display: block; width: 100%; }
  table.t.stack tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; background: #fff; }
  table.t.stack td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.t.stack td::before { content: attr(data-l); color: var(--ink-3); font-size: .8rem; font-weight: 600; text-align: left; }
  table.t.stack td.act { justify-content: flex-end; }
  table.t.stack td.act::before { content: none; }
  .hero { padding: 18px; }
  .hero .btn { margin-left: 0; width: 100%; }
  .live-banner .btn { margin-left: 0; width: 100%; }
}
