/* MURTII â€” Oromia Justice IS â€” judicial palette: deep navy + gold + parchment */
:root {
  --navy:      #0b1d3a;
  --navy-2:    #15315a;
  --gold:      #d4af37;
  --gold-dim:  #b8962b;
  --parchment: #f7f3e9;
  --ink:       #1c1c1c;
  --muted:     #6b6f76;
  --line:      #e2dfd4;
  --green:     #2f7d32;
  --red:       #b3261e;
  --amber:     #b67500;
  --bg:        #f4f1e8;
  --card:      #ffffff;
  --shadow:    0 1px 3px rgba(11,29,58,.08), 0 4px 12px rgba(11,29,58,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Ethiopic",
               Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* â”€â”€â”€â”€â”€ Boot screen â”€â”€â”€â”€â”€ */
.boot {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; color: var(--navy);
}
.boot-emblem { font-size: 64px; color: var(--gold); margin-bottom: 12px; }

/* â”€â”€â”€â”€â”€ Header / nav â”€â”€â”€â”€â”€ */
.topbar {
  background: var(--navy);
  color: var(--parchment);
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 50;
}
.topbar .brand { font-family: Georgia, serif; font-size: 20px; font-weight: 700; }
.topbar .brand .gold { color: var(--gold); }
.topbar .tag { color: #d6dbe5; font-size: 12px; margin-left: 6px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: #d6dbe5; }
.topbar .who b { color: var(--gold); }
.topbar button.linkbtn {
  background: transparent; border: 1px solid #2c4773; color: #d6dbe5;
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.topbar button.linkbtn:hover { background: #15315a; }
.topbar a.linkbtn {
  text-decoration: none; background: transparent; border: 1px solid #2c4773;
  color: #d6dbe5; padding: 6px 12px; border-radius: 6px; font-size: 13px;
}
.topbar a.linkbtn:hover { background: #15315a; }
.langswitch { display: flex; gap: 4px; margin-right: 12px; }
.langswitch .langbtn {
  background: transparent; border: 1px solid #2c4773; color: #d6dbe5;
  padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px;
  font-weight: 600; min-width: 36px;
}
.langswitch .langbtn:hover { background: #15315a; }
.langswitch .langbtn.active { background: var(--gold); color: var(--navy); border-color: var(--gold); }

/* Single-select language picker (matches the mobile launcher's bottom-sheet
 * style). Renders as a compact gold-bordered chip in the topbar. */
.langsel {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background: transparent; color: var(--gold);
  border: 1px solid var(--gold); border-radius: 14px;
  padding: 4px 26px 4px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; line-height: 1.2;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23d4af37' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 8px 5px;
}
.langsel:focus { outline: none; box-shadow: 0 0 0 2px rgba(212,175,55,.35); }
.langsel option { color: var(--ink); background: white; }

.tabs {
  display: flex; background: var(--navy-2); padding: 0 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tabs a {
  color: #c9d2e3; text-decoration: none; padding: 12px 16px;
  font-size: 14px; border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs a.active { color: var(--gold); border-bottom-color: var(--gold); }

/* â”€â”€â”€â”€â”€ Layout â”€â”€â”€â”€â”€ */
.shell { max-width: 1280px; margin: 0 auto; padding: 16px; }
.row   { display: flex; gap: 16px; flex-wrap: wrap; }
.col   { flex: 1 1 320px; min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card h2 {
  margin: 0 0 12px 0; font-family: Georgia, serif; color: var(--navy);
  font-size: 18px; font-weight: 600; border-bottom: 2px solid var(--gold);
  padding-bottom: 6px; display: inline-block;
}

.muted { color: var(--muted); font-size: 13px; }
.right { float: right; }

/* â”€â”€â”€â”€â”€ Buttons â”€â”€â”€â”€â”€ */
button, .btn {
  font: inherit;
  background: var(--navy); color: white;
  border: none; padding: 10px 18px; border-radius: 6px;
  cursor: pointer; font-weight: 500;
}
button:hover, .btn:hover { background: var(--navy-2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.gold, .btn.gold { background: var(--gold); color: var(--navy); }
button.gold:hover { background: var(--gold-dim); }
button.ghost { background: transparent; color: var(--navy); border: 1px solid var(--navy); }
button.ghost:hover { background: var(--navy); color: white; }
button.danger { background: var(--red); }
button.small { padding: 6px 10px; font-size: 13px; }

/* â”€â”€â”€â”€â”€ Forms â”€â”€â”€â”€â”€ */
label { display: block; font-size: 13px; color: var(--muted);
        margin-bottom: 4px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 10px; border: 1px solid var(--line);
  border-radius: 6px; font: inherit; background: white;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(11,29,58,.1);
}
.field { margin-bottom: 12px; }
.fields-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .fields-grid { grid-template-columns: 1fr; } }

/* â”€â”€â”€â”€â”€ Tables â”€â”€â”€â”€â”€ */
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th {
  text-align: left; padding: 10px 8px; background: var(--parchment);
  color: var(--navy); border-bottom: 2px solid var(--gold); font-weight: 600;
}
table.list td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
table.list tr:hover td { background: #faf8f1; cursor: pointer; }
.docket { font-family: "Courier New", monospace; color: var(--navy); font-weight: 700; }

/* â”€â”€â”€â”€â”€ Status pills â”€â”€â”€â”€â”€ */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.4px;
}
.pill.filed       { background: #e3eafa; color: var(--navy); }
.pill.in_hearings { background: #fff4d4; color: var(--amber); }
.pill.judged      { background: #d8ecd9; color: var(--green); }
.pill.appealed    { background: #fde2df; color: var(--red); }

/* â”€â”€â”€â”€â”€ Login â”€â”€â”€â”€â”€ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  padding: 16px;
}
.login-card {
  background: var(--parchment); border-radius: 12px; padding: 32px;
  width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.login-card h1 {
  text-align: center; font-family: Georgia, serif; color: var(--navy);
  margin: 0 0 4px 0;
}
.login-card .crest { text-align: center; font-size: 56px; color: var(--gold); margin-bottom: 8px; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 20px; font-size: 14px; }
.login-card button { width: 100%; margin-top: 8px; }
.login-card .demo { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
                    font-size: 12px; color: var(--muted); }
.login-card .demo b { color: var(--navy); }
.alert { padding: 10px; border-radius: 6px; margin-bottom: 12px; font-size: 14px; }
.alert.error   { background: #fde2df; color: var(--red); border: 1px solid #f5b7b1; }
.alert.success { background: #d8ecd9; color: var(--green); border: 1px solid #a4d8a8; }
.alert.info    { background: #e3eafa; color: var(--navy); border: 1px solid #b4c5e9; }

/* â”€â”€â”€â”€â”€ Document grid â”€â”€â”€â”€â”€ */
.doc-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.doc-tile {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  background: white; text-align: center; cursor: pointer; transition: transform .1s;
}
.doc-tile:hover { transform: translateY(-2px); border-color: var(--gold); }
.doc-tile .icon { font-size: 36px; color: var(--navy); margin-bottom: 6px; }
.doc-tile .name { font-size: 12px; word-break: break-word; }
.doc-tile .meta { font-size: 10px; color: var(--muted); margin-top: 4px; }
.doc-tile.has-text .icon { color: var(--green); }

/* â”€â”€â”€â”€â”€ Capture / scan â”€â”€â”€â”€â”€ */
.scan-zone {
  border: 2px dashed var(--gold); border-radius: 10px; padding: 18px;
  text-align: center; background: #fffaef; margin-bottom: 12px;
}
.scan-zone.dragover { background: #fff0c4; border-color: var(--navy); }
.scan-zone .scan-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.scan-zone label.btn { display: inline-block; }

/* â”€â”€â”€â”€â”€ Hearing / judgment cards â”€â”€â”€â”€â”€ */
.event-row {
  border-left: 3px solid var(--gold); padding: 10px 14px;
  background: #fffaef; margin-bottom: 8px; border-radius: 0 6px 6px 0;
}
.event-row .when { font-weight: 600; color: var(--navy); }
.event-row .who  { font-size: 12px; color: var(--muted); }

.appeal-chain { background: #f9f6e9; border: 1px solid var(--gold); border-radius: 8px; padding: 12px; }
.appeal-chain .step { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.appeal-chain .step:last-child { border-bottom: none; }
.appeal-chain .arrow { color: var(--gold); margin: 0 6px; }

/* â”€â”€â”€â”€â”€ Modal â”€â”€â”€â”€â”€ */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: white; border-radius: 10px; max-width: 720px; width: 100%;
  max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.modal-head {
  padding: 14px 18px; background: var(--navy); color: white;
  display: flex; align-items: center; border-radius: 10px 10px 0 0;
}
.modal-head h3 { margin: 0; flex: 1; font-family: Georgia, serif; font-size: 17px; }
.modal-head .x { background: transparent; color: var(--gold); font-size: 20px; padding: 0 6px; }
.modal-body { padding: 18px; }
.viewer-img { max-width: 100%; height: auto; border: 1px solid var(--line); }
.viewer-text {
  background: var(--parchment); border: 1px solid var(--line); border-radius: 6px;
  padding: 12px; font-family: "Courier New", monospace; font-size: 12px;
  white-space: pre-wrap; max-height: 60vh; overflow: auto;
}

/* â”€â”€â”€â”€â”€ Responsive bits â”€â”€â”€â”€â”€ */
@media (max-width: 700px) {
  .topbar .tag { display: none; }
  .topbar .who { display: none; }
  .card { padding: 14px; }
}

/* â”€â”€â”€â”€â”€ Mobile fit / no-overflow safety net â”€â”€â”€â”€â”€
 * The Flutter shell hosts this app inside a WebView at typical phone widths
 * (320â€“430 CSS px). These rules guarantee that no card, table, code block,
 * or judgment-signature string can push the layout wider than the viewport
 * (which would otherwise produce a horizontal scrollbar and feel "cut off").
 */
html, body { overflow-x: hidden; max-width: 100vw; }
img, svg, video, canvas { max-width: 100%; height: auto; }
pre, code, .docket { overflow-wrap: anywhere; word-break: break-word; }
.muted, .alert, .event-row, .appeal-chain { overflow-wrap: anywhere; }

/* Tables get a horizontal scroller so the page itself never overflows. */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 480px) {
  body         { font-size: 14px; }
  .shell       { padding: 10px; }
  .card        { padding: 12px; margin-bottom: 12px; border-radius: 8px; }
  .card h2     { font-size: 16px; }
  .row         { gap: 10px; }
  .col         { flex-basis: 100%; }
  .topbar      { padding: 8px 10px; gap: 8px; }
  .topbar .brand { font-size: 17px; }
  .langswitch  { margin-right: 4px; }
  .langswitch .langbtn { padding: 3px 7px; font-size: 11px; min-width: 30px; }
  .topbar .linkbtn, .topbar a.linkbtn { padding: 5px 9px; font-size: 12px; }
  .tabs a      { padding: 10px 12px; font-size: 13px; }
  table.list   { font-size: 13px; display: block; overflow-x: auto;
                 -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .doc-grid    { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .login-card  { padding: 22px; }
  .login-card h1 { font-size: 26px; }
  .modal       { max-height: 92vh; border-radius: 8px; }
  .modal-body  { padding: 14px; }
  /* Long single-token strings (judgment SHA-256, dockets) must wrap. */
  .viewer-text, .event-row .muted { word-break: break-all; }
}

/* -------------------------------------------------------------------
   Dark mode — auto via prefers-color-scheme, force via [data-theme].
   ------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0a1226;
    --card:      #11203f;
    --parchment: #11203f;
    --ink:       #ecedf2;
    --muted:     #9aa3b8;
    --line:      #233866;
    --shadow:    0 1px 3px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  --bg:        #0a1226;
  --card:      #11203f;
  --parchment: #11203f;
  --ink:       #ecedf2;
  --muted:     #9aa3b8;
  --line:      #233866;
  --shadow:    0 1px 3px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.35);
}

/* Surface contrast tweaks shared by both auto-dark + forced-dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) input,
  :root:not([data-theme="light"]) select,
  :root:not([data-theme="light"]) textarea {
    background: #0d1a36; color: var(--ink); border-color: var(--line);
  }
  :root:not([data-theme="light"]) .langsel option { background: #0d1a36; color: var(--ink); }
  :root:not([data-theme="light"]) .btn.ghost { color: var(--gold); border-color: var(--gold); }
  :root:not([data-theme="light"]) table th { background: #15295a; color: var(--ink); }
  :root:not([data-theme="light"]) table td { border-color: var(--line); }
  :root:not([data-theme="light"]) .modal-content { background: var(--card); color: var(--ink); }
  :root:not([data-theme="light"]) a { color: #ffd76b; }
}
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: #0d1a36; color: var(--ink); border-color: var(--line);
}
:root[data-theme="dark"] .langsel option { background: #0d1a36; color: var(--ink); }
:root[data-theme="dark"] .btn.ghost { color: var(--gold); border-color: var(--gold); }
:root[data-theme="dark"] table th { background: #15295a; color: var(--ink); }
:root[data-theme="dark"] table td { border-color: var(--line); }
:root[data-theme="dark"] .modal-content { background: var(--card); color: var(--ink); }
:root[data-theme="dark"] a { color: #ffd76b; }

/* ----- Audit log ----- */
.audit-list { width: 100%; font-size: 13px; }
.audit-list th { background: var(--navy); color: white; text-align: left; padding: 8px 10px; }
.audit-list td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.audit-list tr:hover td { background: rgba(212, 175, 55, 0.08); }
.audit-list code { background: rgba(11, 29, 58, 0.06); padding: 1px 5px; border-radius: 3px; }
.audit-list .when { white-space: nowrap; color: var(--muted); font-size: 12px; }
:root[data-theme="dark"] .audit-list code { background: rgba(255, 215, 107, 0.12); color: var(--ink); }
