:root {
  /* Home Golden View identity: olive green + gold */
  --orange: #15311b; --orange-d: #0e2213; --orange-l: #fff4d1; --gold: #fcbf0f; --on-primary: #ffffff;
  --bg: #faf7f4; --card: #ffffff; --ink: #1c1917; --muted: #78716c; --line: #ece7e2;
  --green: #16a34a; --red: #dc2626; --amber: #d97706;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1a0f; --card: #13261a; --ink: #f2f5ef; --muted: #a3ad9f; --line: #22392a; --orange: #fcbf0f; --orange-d: #e0a800; --orange-l: #233d29; --on-primary: #0e2213; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 "IBM Plex Sans Arabic", system-ui, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 1.4em; margin: 6px 0 0; }
a { color: var(--orange-d); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 28px; text-align: center; }
.login-card label { text-align: start; }
.logo { font-weight: 700; font-size: 28px; color: var(--orange); letter-spacing: .5px; direction: ltr; }

/* shell */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--card); border-inline-end: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--green); box-shadow: 0 0 0 4px #16a34a22; }
.dot.bad { background: var(--red); }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
nav button { all: unset; cursor: pointer; padding: 9px 12px; border-radius: 10px; color: var(--ink); display: flex; gap: 10px; align-items: center; }
nav button:hover { background: var(--orange-l); }
nav button.active { background: var(--orange); color: var(--on-primary); font-weight: 600; box-shadow: inset -4px 0 0 var(--gold); }
.main { padding: 22px clamp(16px, 3vw, 36px) 60px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.top h1 { margin: 0; font-size: 22px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
  .brand { padding: 0 6px; }
  nav { flex-direction: row; overflow-x: auto; flex-wrap: nowrap; order: 3; width: 100%; }
  nav button { white-space: nowrap; }
  #logoutBtn { width: auto; margin-inline-start: auto; }
}

/* cards & tables */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .n { font-size: 30px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.panel > h3 { margin: 0; padding: 14px 16px; font-size: 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { font-size: 12.5px; color: var(--muted); font-weight: 500; background: color-mix(in srgb, var(--bg) 60%, var(--card)); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 2px 10px; border-radius: 99px; background: var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { background: #16a34a1f; color: var(--green); }
.pill.bad { background: #dc26261a; color: var(--red); }
.pill.warn { background: #d977061f; color: var(--amber); }
.pill.or { background: var(--orange-l); color: var(--orange-d); }

/* buttons & inputs */
.btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 7px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--orange); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: var(--on-primary); font-weight: 600; }
.btn.primary:hover { background: var(--orange-d); }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.wide { width: 100%; padding: 11px; }
.btn:disabled { opacity: .5; cursor: default; }
label { display: block; font-size: 13.5px; color: var(--muted); margin: 0 0 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 5px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: -1px; }
input[type=checkbox] { display: inline; width: auto; margin: 0 0 0 8px; accent-color: var(--orange); }
.check { display: flex; align-items: center; color: var(--ink); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.ltr { direction: ltr; text-align: left; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .two { grid-template-columns: 1fr; } }

/* toggle switch */
.sw { position: relative; width: 42px; height: 24px; display: inline-block; }
.sw input { opacity: 0; width: 0; height: 0; position: absolute; }
.sw span { position: absolute; inset: 0; background: #d6d3d1; border-radius: 99px; transition: .2s; cursor: pointer; }
.sw span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.sw input:checked + span { background: var(--green); }
.sw input:checked + span::after { inset-inline-start: 21px; }

/* modal */
.modal { position: fixed; inset: 0; background: #0007; display: grid; place-items: center; padding: 14px; z-index: 50; }
.modal-card { background: var(--card); border-radius: 18px; width: min(620px, 100%); max-height: 92vh; display: flex; flex-direction: column; }
.modal-card header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-card h2 { margin: 0; font-size: 18px; }
.modal-card .x { all: unset; cursor: pointer; font-size: 24px; color: var(--muted); padding: 0 6px; }
#modalBody { padding: 18px; overflow: auto; }
#modalFoot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-start; flex-wrap: wrap; }
#modalFoot:empty { display: none; }

.opt-row { display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.opt-row input, .opt-row select { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.chip { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); padding: 4px 12px; border-radius: 99px; cursor: pointer; }
.chip:hover { border-color: var(--orange); color: var(--orange-d); }
.multi { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; max-height: 180px; overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.multi label { margin: 0; color: var(--ink); display: flex; align-items: center; }
.cred { font-family: ui-monospace, monospace; background: var(--bg); border: 1px dashed var(--line); padding: 12px; border-radius: 10px; direction: ltr; text-align: left; white-space: pre-wrap; }
audio { width: 100%; height: 36px; }
.say-btn { background: var(--gold); color: #15311b; border-color: var(--gold); font-weight: 600; }

#toasts { position: fixed; bottom: 18px; inset-inline-start: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-size: 14px; box-shadow: 0 6px 24px #0003; }
.toast.bad { background: var(--red); color: #fff; }
.toast.ok { background: var(--green); color: #fff; }

.brand-full { margin: 2px 0 0; font-weight: 600; direction: ltr; }
.brand-sub { display: block; white-space: nowrap; font-size: 11px; color: var(--muted); direction: ltr; text-align: start; line-height: 1.2; }

/* brand logo */
.login-logo { background: #15311b; border-radius: 18px; padding: 22px 28px; margin: -6px -6px 14px; }
.login-logo img { width: 72%; max-width: 260px; display: block; margin: 0 auto; }
.side-logo { display: flex; align-items: center; gap: 10px; }
.side-logo img { width: 38px; height: auto; background: #15311b; border-radius: 10px; padding: 5px; }
.side-logo .logo { color: var(--orange); font-size: 22px; }
@media (prefers-color-scheme: dark) { .side-logo .logo { color: var(--gold); } }

h4.sec { margin: 22px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 15px; color: var(--orange); }
h4.sec:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
