/* Complaints Desk — one stylesheet, works for LTR and RTL (logical properties only) */
:root {
  --paper: #eef1f4;
  --surface: #ffffff;
  --ink: #17222e;
  --muted: #5b6876;
  --line: #d6dde4;
  --primary: #1d4e89;
  --primary-dark: #163d6b;
  --focus: #f0b429;

  --st-new: #2563a8;       --st-new-bg: #e3edf8;
  --st-prog: #8a5a00;      --st-prog-bg: #fbf0d9;
  --st-res: #1d7a4f;       --st-res-bg: #def2e7;
  --st-closed: #5b6876;    --st-closed-bg: #e7eaee;

  --p-high: #c0392b;
  --p-medium: #d9930d;
  --p-low: #9aa6b2;

  --radius: 6px;
  --font: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}
[dir="rtl"] { --font: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif; }

* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); line-height: 1.5; }
[dir="rtl"] body { line-height: 1.7; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.6rem; font-weight: 600; margin: 0; line-height: 1.25; }
h2 { font-size: 1rem; font-weight: 600; margin: 0 0 .9rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* Top bar */
.topbar { background: var(--ink); color: #fff; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: .6rem 1.25rem; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 600; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: .25rem; }
.mainnav a { color: #c6d0da; padding: .4rem .75rem; border-radius: var(--radius); }
.mainnav a:hover { color: #fff; text-decoration: none; background: rgba(255,255,255,.08); }
.mainnav a.active { color: #fff; background: rgba(255,255,255,.14); }
.usermenu { margin-inline-start: auto; display: flex; align-items: center; gap: 1rem; font-size: .9rem; }
.usermenu .who small { color: #9fb0c0; margin-inline-start: .3rem; }
.langlink { color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: var(--radius); padding: .15rem .6rem; }
.langlink:hover { text-decoration: none; background: rgba(255,255,255,.1); }
.topbar .linkbtn { color: #c6d0da; }
.btn-new { background: #fff; color: var(--ink); }
.btn-new:hover { background: #e5ebf1; }

/* Layout */
.page { max-width: 1240px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head p { margin: .25rem 0 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.two-col .panel { margin-bottom: 0; }

/* Buttons */
.btn { display: inline-block; font: inherit; font-weight: 500; font-size: .92rem; border: 1px solid transparent; border-radius: var(--radius); padding: .5rem 1rem; cursor: pointer; line-height: 1.3; text-align: center; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); color: var(--primary); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--primary); }
.btn-block { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }

/* Flash */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem; border-inline-start: 4px solid; }
.flash-ok { background: var(--st-res-bg); border-color: var(--st-res); }
.flash-bad { background: #fbe5e2; border-color: var(--p-high); }

/* Forms */
label { display: block; font-size: .88rem; font-weight: 500; color: var(--ink); }
input, select, textarea { display: block; width: 100%; margin-top: .3rem; font: inherit; font-size: .95rem; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .65rem; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(29,78,137,.18); }
.stack > * + * { margin-top: .85rem; }
.divided { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1.1rem; }
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; max-width: 960px; }
fieldset { border: 0; padding: 0; margin: 0 0 1.5rem; }
fieldset > label { margin-top: 1rem; }
legend { font-weight: 600; font-size: 1rem; margin-bottom: .9rem; padding: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.narrow { max-width: 320px; }
.req { font-style: normal; font-weight: 400; font-size: .75rem; color: var(--muted); margin-inline-start: .3rem; }
.form-actions { display: flex; gap: 1.25rem; align-items: center; }
.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; white-space: nowrap; }
.check input { width: auto; margin: 0; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.filters input[type="search"] { flex: 1 1 260px; margin: 0; }
.filters select { width: auto; margin: 0; }

/* Dashboard figures: one band, divided, not separate cards */
.figures { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1.25rem; }
.figure { display: flex; flex-direction: column; padding: 1.1rem 1.25rem; color: var(--ink); }
.figure + .figure { border-inline-start: 1px solid var(--line); }
a.figure:hover { text-decoration: none; background: #f7f9fb; }
.figure-n { font-size: 2rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.figure-l { color: var(--muted); font-size: .9rem; margin-top: .2rem; }
.figure-bad .figure-n { color: var(--p-high); }

/* Status strip */
.strip { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; background: var(--paper); }
.strip-seg { display: block; min-width: 6px; }
.legend { list-style: none; padding: 0; margin: .9rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; font-size: .9rem; }
.legend li { display: flex; align-items: center; gap: .4rem; }
.legend a { color: var(--ink); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.strip-seg.st-new, .dot.st-new { background: var(--st-new); }
.strip-seg.st-in_progress, .dot.st-in_progress { background: var(--p-medium); }
.strip-seg.st-resolved, .dot.st-resolved { background: var(--st-res); }
.strip-seg.st-closed, .dot.st-closed { background: var(--p-low); }

/* Category bars */
.bars { list-style: none; padding: 0; margin: 0; }
.bars li { display: grid; grid-template-columns: 9.5rem 1fr 2rem; align-items: center; gap: .75rem; padding: .35rem 0; font-size: .9rem; }
.bars a { color: var(--ink); }
.bar { height: 8px; background: var(--paper); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.bars b { text-align: end; font-variant-numeric: tabular-nums; }

/* Recent list */
.recent { list-style: none; padding: 0; margin: 0 0 .75rem; }
.recent li + li { border-top: 1px solid var(--line); }
.recent a { display: flex; flex-direction: column; padding: .6rem .75rem; color: var(--ink); }
.recent a:hover { background: #f7f9fb; text-decoration: none; }
.recent-top { display: flex; justify-content: space-between; align-items: center; }
.recent-subj { font-weight: 500; margin: .1rem 0; text-align: start; }
.recent .small { display: flex; gap: .8rem; }
.morelink { font-size: .9rem; }

/* Priority edge — the one strong visual cue across the app */
.prio-edge { border-inline-start: 4px solid transparent; }
.prio-edge.prio-high { border-inline-start-color: var(--p-high); }
.prio-edge.prio-medium { border-inline-start-color: var(--p-medium); }
.prio-edge.prio-low { border-inline-start-color: var(--p-low); }

/* Badges */
.badge { display: inline-block; font-size: .78rem; font-weight: 500; padding: .12rem .55rem; border-radius: 999px; white-space: nowrap; }
.badge.st-new { color: var(--st-new); background: var(--st-new-bg); }
.badge.st-in_progress { color: var(--st-prog); background: var(--st-prog-bg); }
.badge.st-resolved { color: var(--st-res); background: var(--st-res-bg); }
.badge.st-closed { color: var(--st-closed); background: var(--st-closed-bg); }
.prio { font-size: .85rem; font-weight: 500; white-space: nowrap; }
.prio::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-inline-end: .4rem; vertical-align: middle; }
.prio-high::before { background: var(--p-high); }
.prio-medium::before { background: var(--p-medium); }
.prio-low::before { background: var(--p-low); }
.sla { font-size: .85rem; font-weight: 500; white-space: nowrap; }
.sla-ok { color: var(--st-res); }
.sla-warn { color: var(--st-prog); }
.sla-bad { color: var(--p-high); }
.ref { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 500; font-size: .88rem; letter-spacing: .01em; }
.ref.big { color: var(--muted); margin: 0 0 .2rem; font-size: .95rem; }

/* Table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: start; font-weight: 500; color: var(--muted); font-size: .82rem; padding: .7rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .7rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f7f9fb; }
.table .subj { max-width: 320px; }
.table .subj a { color: var(--ink); }

/* Detail page */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.head-badges { display: flex; gap: .9rem; align-items: center; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem 1.5rem; margin: 0 0 1.25rem; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: .1rem 0 0; font-weight: 500; overflow-wrap: anywhere; }
[dir="rtl"] .facts dd[dir="ltr"], [dir="rtl"] td[dir="ltr"] { text-align: right; }
.desc { white-space: pre-wrap; margin: 0; max-width: 72ch; }
.sla-panel { display: flex; justify-content: space-between; align-items: center; border-inline-start: 4px solid; }
.sla-panel strong { font-size: 1.15rem; }
.sla-panel.sla-ok { border-inline-start-color: var(--st-res); }
.sla-panel.sla-warn { border-inline-start-color: var(--p-medium); }
.sla-panel.sla-bad { border-inline-start-color: var(--p-high); }
.sla-panel span { color: var(--muted); }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding-inline-start: 1.4rem; padding-bottom: 1rem; border-inline-start: 2px solid var(--line); margin-inline-start: .4rem; }
.timeline li:last-child { border-inline-start-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: -7px; top: .35rem; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.tl-head { display: flex; flex-wrap: wrap; gap: .35rem .6rem; align-items: baseline; }
.tl-head time { margin-inline-start: auto; }
.tl-note { margin: .35rem 0 0; background: var(--paper); padding: .5rem .75rem; border-radius: var(--radius); white-space: pre-wrap; max-width: 72ch; }

/* Empty + auth */
.empty { text-align: center; padding: 3rem 1rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty p { margin: 0 0 1rem; color: var(--muted); }
.empty h1 { margin-bottom: 1.25rem; font-size: 1.3rem; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--ink); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 10px; padding: 2rem; position: relative; }
.auth-title { font-size: 1.7rem; }
.auth-card > .muted { margin: .3rem 0 1.5rem; }
.auth-lang { position: absolute; inset-inline-end: 1.25rem; top: 1.25rem; font-size: .9rem; }
.demo-box { margin-top: 1.5rem; font-size: .85rem; background: var(--paper); padding: .8rem 1rem; border-radius: var(--radius); }
.demo-box ul { margin: .4rem 0 0; padding-inline-start: 1.1rem; color: var(--muted); }

/* Responsive */
@media (max-width: 900px) {
  .two-col, .detail { grid-template-columns: 1fr; }
  .figures { grid-template-columns: repeat(2, 1fr); }
  .figure:nth-child(3) { border-inline-start: 0; }
  .figure:nth-child(n+3) { border-top: 1px solid var(--line); }
  .grid-3, .facts { grid-template-columns: 1fr 1fr; }
  .usermenu .who { display: none; }
}
@media (max-width: 560px) {
  .grid-3, .facts { grid-template-columns: 1fr; }
  .bars li { grid-template-columns: 7rem 1fr 2rem; }
  .topbar-inner { gap: .75rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
