/* Layout: a sticky desk header with tabs; single centered column; the ticket list is one hairline-ruled surface, reports are a stack of plain sections. */
:root {
  color-scheme: light;
  --bg: #f9f4e8;
  --surface: #fffdf8;
  --ink: #3a2e1a;
  --ink2: #6a5a40;
  --muted: #8f7f64;
  --line: #eadfc6;
  --line-strong: #d6c49a;
  --soft: #f4ecd8;
  --accent: #a87a12;
  --accent-ink: #ffffff;
  --accent-soft: #f8ebc6;
  --danger: #b0332f;
  --head: #fff9ea;
  --head-ink: #3a2e1a;
  --head-hi: #c99a2e;
  --sev1: #0ca30c;
  --sev2: #fab219;
  --sev3: #ec835a;
  --sev4: #d03b3b;
  --st-new: #1f5fbf;
  --st-progress: #6250d6;
  --st-waiting: #727c88;
  --st-resolved: #0a7a0a;
  --font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  padding-block: 0 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 40;
  background: var(--head);
}
.app { max-width: 1040px; margin: 0 auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.code { font-family: var(--mono); font-size: 12.5px; letter-spacing: .02em; color: var(--ink2); direction: ltr; unicode-bidi: isolate; }

/* header */
.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 30;
  background: var(--head);
  color: var(--head-ink);
  box-shadow: 0 0 0 100vmax var(--head), 0 1px 0 100vmax var(--line-strong);
  clip-path: inset(0 -100vmax -1px -100vmax);
  padding-top: 14px;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  font-family: var(--mono); font-weight: 500; font-size: 15px; letter-spacing: .04em;
  background: var(--head-hi); color: var(--head);
  padding: 6px 9px; border-radius: 4px; direction: ltr; font-weight: 700;
}
.brand-name { font-weight: 700; font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
.brand-sub { color: color-mix(in srgb, var(--head-ink) 66%, transparent); font-size: 13px; line-height: 1.3; }
.live { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 3px 10px; border: 1px solid color-mix(in srgb, var(--head-ink) 22%, transparent); border-radius: 999px; background: color-mix(in srgb, var(--head-ink) 9%, transparent); color: var(--head-ink); white-space: nowrap; }
.pill b { font-family: var(--mono); font-weight: 500; }
.pill.warn { border-color: #d6746f; background: color-mix(in srgb, #d03b3b 14%, transparent); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-inline: -4px; padding-inline: 4px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: none; border: 0; padding: 10px 16px; color: color-mix(in srgb, var(--head-ink) 72%, transparent); font-weight: 500; white-space: nowrap; border-bottom: 3px solid transparent; border-radius: 4px 4px 0 0; }
.tab:hover { color: var(--head-ink); background: color-mix(in srgb, var(--head-ink) 9%, transparent); }
.tab[aria-selected="true"] { color: var(--head-ink); border-bottom-color: var(--head-hi); font-weight: 700; }
.tab:focus-visible { outline-color: var(--head-hi); }

.banner { margin-top: 16px; padding: 10px 14px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; color: var(--ink2); }
main { padding-top: 22px; display: block; }
.panel[hidden] { display: none !important; }
h2 { font-size: 22px; line-height: 1.35; margin: 0 0 4px; font-weight: 700; }
h3 { font-size: 15px; margin: 0 0 12px; font-weight: 700; }
.lead { color: var(--ink2); margin: 0 0 18px; max-width: 62ch; }

/* forms */
.form { max-width: 720px; display: grid; gap: 18px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .lbl, .legend { font-weight: 600; font-size: 14px; }
.opt { font-weight: 400; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-width: 0; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 9px 12px; line-height: 1.5;
}
.textarea { min-height: 120px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input[dir="ltr"] { text-align: left; }
.err { color: var(--danger); font-size: 13px; min-height: 0; }
.err:empty { display: none; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.sevgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 6px; }
.sevopt { position: relative; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); cursor: pointer; }
.sevopt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.sevopt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.sevopt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.sevopt .t { font-weight: 600; line-height: 1.3; }
.sevopt .d { grid-column: 2; color: var(--muted); font-size: 13px; line-height: 1.4; }
.sevicon { flex: none; display: block; }
.sevicon .on { fill: var(--c); }
.sevicon .off { fill: var(--line-strong); }
.drop { border: 1.5px dashed var(--line-strong); border-radius: 8px; padding: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); }
.drop.disabled { opacity: .6; }
.preview { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.preview img { width: 120px; height: 84px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.btn { border: 1px solid var(--line-strong); background: var(--surface); padding: 8px 18px; border-radius: 6px; font-weight: 600; line-height: 1.4; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* filters */
.filters { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); gap: 10px; align-items: center; margin-bottom: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.count { color: var(--muted); font-size: 13px; margin: 0 0 8px; }

/* ticket list */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; box-shadow: 0 1px 0 var(--line); }
.tk + .tk { border-top: 1px solid var(--line); }
.tk-head { width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: start; background: none; border: 0; padding: 12px 14px; }
.tk-head:hover { background: var(--soft); }
.tk-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.tk-meta { display: block; color: var(--muted); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.tk-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; padding: 1px 9px; border-radius: 999px; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--ink); }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip.late { --c: var(--sev4); }
.chip.late::before { border-radius: 2px; }
.tk-body { padding: 4px 14px 16px; display: grid; gap: 14px; border-top: 1px dashed var(--line); background: var(--surface); }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; margin: 10px 0 0; }
.kv { display: flex; gap: 8px 18px; flex-wrap: wrap; font-size: 14px; color: var(--ink2); }
.kv a { color: var(--accent); overflow-wrap: anywhere; }
.shot { display: block; max-width: 100%; max-height: 300px; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.note { border-inline-start: 3px solid var(--line-strong); padding: 2px 12px; color: var(--ink2); white-space: pre-wrap; overflow-wrap: anywhere; }
.adm { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 12px; }
.adm .row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.empty { padding: 36px 18px; text-align: center; color: var(--ink2); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.more { display: flex; justify-content: center; padding: 12px; border-top: 1px solid var(--line); }

/* reports */
.rcontrols { display: grid; gap: 12px; margin-bottom: 18px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.preset { border: 1px solid var(--line-strong); background: var(--surface); padding: 5px 12px; border-radius: 999px; font-size: 14px; }
.preset[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.range { display: flex; gap: 10px 14px; align-items: end; flex-wrap: wrap; }
.range .field { width: 170px; max-width: 100%; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 22px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }
.kpi .n { font-size: 30px; font-weight: 700; line-height: 1.2; color: var(--accent); }
.kpi .l { color: var(--ink2); font-size: 13px; }
.kpi .s { color: var(--muted); font-size: 12.5px; }
.sec { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 6px; padding: 16px; margin-bottom: 14px; min-width: 0; }
.sec .sub { color: var(--muted); font-size: 13px; margin: -8px 0 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid2 .sec { margin-bottom: 0; }
.bl { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.bl-row { display: grid; grid-template-columns: minmax(96px, 38%) minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.bl-label { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.bl-track { height: 12px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.bl-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bl-val { font-family: var(--mono); font-size: 13px; min-width: 56px; text-align: end; direction: ltr; }
.bl-val i { color: var(--muted); font-style: normal; }
.scroll-x { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 10px; text-align: center; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: start; }
th { font-weight: 600; color: var(--ink2); font-size: 13px; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.chartwrap { position: relative; }
.tschart { display: block; width: 100%; height: auto; overflow: visible; }
.tschart .grid { stroke: var(--line); stroke-width: 1; }
.tschart .axis { stroke: var(--line-strong); stroke-width: 1; }
.tschart .tick { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.tschart .bar { fill: var(--accent); }
.tschart .bar.hot { fill: var(--ink); }
.tschart .hit { cursor: pointer; }
.tip { position: absolute; top: 0; transform: translate(-50%, -4px); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 10px; font-size: 13px; line-height: 1.5; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.14); white-space: nowrap; display: grid; z-index: 5; }
.tip[hidden] { display: none; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--ink2); font-size: 14px; }

/* admin */
.admgrid { display: grid; gap: 14px; max-width: 760px; }
.trow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.trow:last-of-type { border-bottom: 0; }
.addrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 10px; }
pre.cfg { margin: 0; padding: 12px 14px; background: var(--soft); border-radius: 8px; overflow-x: auto; direction: ltr; text-align: left; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.codehint li { margin: 3px 0; }

.toast { position: fixed; inset-inline: 0; bottom: max(20px, env(safe-area-inset-bottom, 0px)); display: flex; justify-content: center; pointer-events: none; z-index: 60; padding-inline: 16px; }
.toast > div { background: #3a2e1a; color: #fff9ea; padding: 9px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 560px; }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(8, 10, 14, .86); display: flex; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

@media (max-width: 760px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .q { grid-column: 1 / -1; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .adm .row3 { grid-template-columns: minmax(0, 1fr); }
  .tk-head { grid-template-columns: auto minmax(0, 1fr); }
  .tk-side { grid-column: 2; flex-direction: row; flex-wrap: wrap; align-items: center; }
}
@media (max-width: 520px) {
  .row2, .sevgrid { grid-template-columns: minmax(0, 1fr); }
  .bl-row { grid-template-columns: minmax(0, 1fr) auto; }
  .bl-track { grid-column: 1 / -1; grid-row: 2; }
}
@media (prefers-reduced-motion: no-preference) {
  .bl-fill { transition: width .35s ease; }
  .btn, .tab, .preset { transition: background-color .15s, border-color .15s, color .15s; }
}

/* مشروع مستقل: عناصر إضافية */
.foot { margin-top: 40px; text-align: center; font-size: 13px; }
.foot a { color: var(--muted); }
.foot a:hover { color: var(--accent); }
.hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; overflow: hidden; }
.loginbox { max-width: 380px; }
