/* الأرشيف v3 — neutral palette, system Arabic font (spec §12). One signature element: the path rail. */
:root {
  --bg: #F5F6F7;
  --surface: #FFFFFF;
  --ink: #1D2430;
  --muted: #667085;
  --line: #DFE3E8;
  --accent: #2B4C7E;        /* slate blue: the only colour used for action */
  --accent-soft: #E8EEF6;
  --ok: #1E7B4F;
  --warn: #9A6700;
  --warn-soft: #FFF4D6;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --font: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 6px;
  --nav: 216px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12161C; --surface: #1A2028; --ink: #E7EAF0; --muted: #98A2B3; --line: #2C3440; --accent: #8FB3E8; --accent-soft: #1F2C40;
          --ok: #5CC596; --warn: #E3B341; --warn-soft: #33290F; --danger: #F0857A; --danger-soft: #3A1F1C; }
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.65; }
body { margin: 0; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; font-weight: 600; margin: 0; }
h2 { font-size: 1rem; font-weight: 600; margin: 1.6rem 0 .6rem; color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=password], input[type=date], input:not([type]), select, textarea {
  width: 100%; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
textarea { resize: vertical; }
textarea.code { font-family: var(--mono); font-size: .85rem; line-height: 1.5; text-align: left; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* shell */
.shell { display: grid; grid-template-columns: var(--nav) 1fr; min-height: 100vh; }
.nav { background: var(--surface); border-inline-end: 1px solid var(--line); padding: 1rem .6rem; display: flex; flex-direction: column; gap: .15rem; position: sticky; top: 0; height: 100vh; }
.nav .brand, .login .brand { font-size: 1.3rem; font-weight: 700; color: var(--ink); padding: .2rem .6rem 1rem; letter-spacing: 0; }
.nav a:not(.brand) { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .7rem; border-radius: var(--r); color: var(--ink); }
.nav a:not(.brand):hover { background: var(--bg); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .ext { font-style: normal; color: var(--muted); }
.nav .logout { margin-top: auto; padding: .5rem .7rem; }
.count { background: var(--accent); color: #fff; border-radius: 99px; font-size: .75rem; font-weight: 600; padding: 0 .5rem; min-width: 1.4rem; text-align: center; font-variant-numeric: tabular-nums; }
.count.warn { background: var(--warn); }
.main { padding: 1.2rem clamp(16px, 3vw, 2.2rem) 5rem; max-width: 1180px; width: 100%; }
.topline { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1.1rem; border-bottom: 1px solid var(--line); padding-bottom: .7rem; flex-wrap: wrap; }
.counts { margin: 0; color: var(--muted); font-size: .88rem; }
.counts a { color: var(--muted); } .counts b { color: var(--ink); }
.link { background: none; border: none; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: var(--r); padding: .5rem 1.05rem; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; }
@media (prefers-color-scheme: dark) { .btn { color: #0E1420; } }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn.sm { padding: .25rem .7rem; font-size: .86rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .8rem 0 .4rem; }
.inline { display: flex; gap: .5rem; align-items: end; margin: .6rem 0; }
.inline.big input { font-size: 1.1rem; padding: .7rem .9rem; }

/* messages */
.flash { background: var(--accent-soft); border-inline-start: 3px solid var(--accent); padding: .55rem .8rem; border-radius: var(--r); margin: 0 0 1rem; }
.flash.danger { background: var(--danger-soft); border-color: var(--danger); }
.flash.warn { background: var(--warn-soft); border-color: var(--warn); }
.hint { color: var(--muted); font-size: .9rem; margin: .3rem 0; }
.warnline, .question { color: var(--warn); background: var(--warn-soft); padding: .45rem .7rem; border-radius: var(--r); margin: 0 0 .7rem; }
.empty { color: var(--muted); margin: 1rem 0; }
.note { display: flex; gap: .8rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-inline-start: 3px solid var(--muted); border-radius: var(--r); padding: .55rem .8rem; margin-bottom: .5rem; }
.note.reminder { border-inline-start-color: var(--warn); }
.note p { margin: 0; flex: 1; white-space: pre-line; }
.ask { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem 1rem; margin-bottom: 1rem; }
.ask p { margin: 0 0 .6rem; font-weight: 600; }
.answer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem 1rem; white-space: pre-line; }

/* the path rail — signature */
.rail { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0; font-size: .92rem; vertical-align: middle; }
.rail .seg { background: var(--accent-soft); color: var(--accent); padding: .12rem .7rem .12rem .55rem; position: relative; margin-inline-end: .55rem; border-radius: 3px 0 0 3px; font-weight: 500; }
.rail .seg::after { content: ""; position: absolute; inset-block: 0; inset-inline-end: -.5rem; width: .5rem; background: inherit; clip-path: polygon(100% 0, 0 50%, 100% 100%); }
[dir=ltr] .rail .seg::after { clip-path: polygon(0 0, 100% 50%, 0 100%); }
.rail .seg.last { font-weight: 700; }
.rail.is-new .seg.last { background: transparent; color: var(--warn); outline: 1.5px dashed var(--warn); outline-offset: -1.5px; }
.rail.is-new .seg.last::after { display: none; }
.rail.none .seg { background: var(--danger-soft); color: var(--danger); }
.rail .lock { color: var(--warn); font-size: .82rem; margin-inline-start: .2rem; }
.rail .lock::before { content: "⚠ "; }

/* pills & chips */
.pill { display: inline-block; font-size: .74rem; padding: 0 .5rem; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); margin-inline-start: .35rem; vertical-align: middle; }
.pill.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.pill.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: .3rem 0 0; padding: 0; list-style: none; }
.chip { font-size: .8rem; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 .5rem; }
.chip.hit { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 45%, transparent); font-weight: 600; }
.chips.big .chip { font-size: .92rem; padding: .15rem .7rem; }

/* rows */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.row { display: flex; gap: .9rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .7rem .9rem; }
.row .num { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.3rem; font-weight: 600; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 1.02rem; color: var(--ink); }
.row-path { color: var(--muted); font-size: .84rem; }
.row-sum { margin: .2rem 0 0; font-size: .92rem; }
.row-act { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.row-act input { width: 11rem; }
.row.renew.late { border-inline-start: 3px solid var(--danger); }
.row.renew.soon { border-inline-start: 3px solid var(--warn); }
.days { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; align-self: center; }
.row.late .days { color: var(--danger); } .row.soon .days { color: var(--warn); }
.month { color: var(--muted); font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--line); padding-bottom: .2rem; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; margin-bottom: .6rem; }
.tiles.three { grid-template-columns: repeat(3, 1fr); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .9rem 1rem; display: grid; gap: .1rem; color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile b { font-size: 1.7rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: .88rem; }
.tile.warn b { color: var(--warn); }

/* inbox */
.upload { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .6rem .9rem; margin-bottom: 1rem; }
.upload summary { cursor: pointer; font-weight: 600; }
.drop { border: 1.5px dashed var(--line); border-radius: var(--r); padding: .8rem; margin-top: .6rem; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-label { display: block; text-align: center; padding: 1.1rem .5rem; cursor: pointer; }
.drop-label small { display: block; color: var(--muted); }
.bar { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .88rem; margin-bottom: .5rem; }
.split { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1rem; align-items: start; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
.item { display: grid; gap: 0; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); border-inline-start: 3px solid var(--line); }
.item:hover { text-decoration: none; border-color: var(--accent); }
.item b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item small { color: var(--muted); }
.item.on { border-color: var(--accent); background: var(--accent-soft); }
.item.st-proposed { border-inline-start-color: var(--accent); }
.item.st-folder_pending { border-inline-start-color: var(--warn); }
.item.st-failed { border-inline-start-color: var(--danger); }
/* the card needs the width: preview sits above it as a strip, and beside it only on wide screens */
.detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: .8rem; align-items: start; }
.preview { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: .15rem .8rem; align-items: start; }
.preview .thumb { grid-row: span 3; }
.preview.big { grid-template-columns: 1fr; }
@media (min-width: 1400px) {
  .detail { grid-template-columns: 220px minmax(0, 1fr); }
  .preview { grid-template-columns: 1fr; }
  .preview .thumb { grid-row: auto; }
}
.preview small, .fname { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; text-align: right; unicode-bidi: plaintext; }
.thumb { padding: 0; border: 1px solid var(--line); border-radius: 3px; background: #fff; cursor: zoom-in; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.1); aspect-ratio: 3 / 4; width: 100%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.preview.big .thumb { max-width: 340px; }
.cardbox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem; display: grid; gap: .6rem; }
.eyebrow { margin: 0; color: var(--muted); font-size: .82rem; font-weight: 600; letter-spacing: .02em; display: flex; justify-content: space-between; }
.conf { font-weight: 400; }
.f { display: grid; gap: .15rem; font-size: .84rem; color: var(--muted); }
.f > input, .f > select, .f > textarea { color: var(--ink); font-size: .98rem; }
.f.check { display: flex; align-items: center; gap: .4rem; color: var(--ink); font-size: .95rem; align-self: end; padding-bottom: .45rem; }
.f.note { align-self: end; padding-bottom: .45rem; margin: 0; }
.f input[name=title] { font-size: 1.12rem; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem; }
.folderbox { border: 1px solid var(--line); border-radius: var(--r); padding: .7rem .8rem; background: var(--bg); }
.folderbox.is-new { border: 1.5px dashed var(--warn); background: var(--warn-soft); }
.f-label { margin: 0 0 .3rem; font-size: .84rem; color: var(--muted); }
.rejectbox { border-top: 1px solid var(--line); padding-top: .6rem; display: grid; gap: .4rem; }
.rejectbox[hidden] { display: none; }

/* document page */
.docgrid { display: grid; grid-template-columns: 340px 1fr; gap: 1.4rem; align-items: start; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: .2rem 1rem; margin: 0; }
.meta dt { color: var(--muted); } .meta dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.timeline li { display: flex; gap: .6rem; align-items: center; border-inline-start: 2px solid var(--line); padding-inline-start: .7rem; font-variant-numeric: tabular-nums; }
.timeline li.st-sent, .timeline li.st-overdue { border-inline-start-color: var(--warn); }
.timeline li.st-done { border-inline-start-color: var(--ok); }
.history { list-style: none; margin: 0; padding: 0; font-size: .86rem; color: var(--muted); display: grid; gap: .1rem; }
.history b { color: var(--ink); font-weight: 500; font-family: var(--mono); font-size: .8rem; }

/* search */
.searchbox { margin-bottom: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; }
.filters label { display: grid; gap: .1rem; font-size: .8rem; color: var(--muted); min-width: 8rem; }
.filters label.check { display: flex; align-items: center; gap: .35rem; min-width: 0; color: var(--ink); padding-bottom: .5rem; }
.searchgrid { display: grid; grid-template-columns: 1fr 230px; gap: 1.2rem; align-items: start; }
.saved ul { list-style: none; padding: 0; margin: 0 0 .6rem; display: grid; gap: .25rem; }
.saved li { display: flex; justify-content: space-between; gap: .5rem; }
.saved h2 { margin-top: 0; }

/* files explorer — list by default, grid on demand; the breadcrumb is the same path rail used everywhere */
.x-bar { display: flex; flex-wrap: wrap; gap: .7rem 1rem; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.rail.crumbs a.seg { text-decoration: none; }
.rail.crumbs a.seg:hover { filter: brightness(.95); }
.x-tools { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.x-filter { width: 15rem !important; }
.seg-toggle { display: flex; }
.seg-toggle .btn { border-radius: 0; }
.seg-toggle .btn:first-child { border-start-start-radius: var(--r); border-end-start-radius: var(--r); }
.seg-toggle .btn:last-child { border-start-end-radius: var(--r); border-end-end-radius: var(--r); border-inline-start: 0; }
.seg-toggle .btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.x-upload { margin: 0; }
.x-split { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1rem; align-items: start; }
.x-main { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.x-head, .x-link { display: grid; grid-template-columns: 2.4rem minmax(0, 1fr) 5.6rem 4.4rem 5.6rem; gap: .6rem; align-items: center; }
.x-head { padding: .45rem .8rem; font-size: .8rem; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--bg); }
.x-head span:first-child { grid-column: 1 / 3; }
.x-items { list-style: none; margin: 0; padding: 0; }
.x-row { border-bottom: 1px solid var(--line); }
.x-row:last-child { border-bottom: 0; }
.x-row[hidden] { display: none; }
.x-link { width: 100%; padding: .5rem .8rem; background: transparent; border: 0; color: var(--ink); text-align: start; cursor: pointer; text-decoration: none; font: inherit; }
.x-link:hover { background: var(--bg); text-decoration: none; }
.x-row.selected .x-link { background: var(--accent-soft); }
.x-name { min-width: 0; overflow: hidden; font-weight: 500; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.x-name small { display: block; color: var(--muted); font-weight: 400; font-size: .78rem; overflow: hidden; text-overflow: ellipsis; text-align: right; unicode-bidi: plaintext; }
.x-row.folder .x-name { font-weight: 600; }
.x-mod, .x-size, .x-exp { color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.x-row.waiting .x-name { color: var(--warn); }
.x-foot { margin: 0; padding: .4rem .8rem; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); background: var(--bg); }
.ico { width: 2.2rem; height: 2.2rem; display: grid; place-items: center; border-radius: 4px; font-size: .62rem; font-weight: 700; text-transform: uppercase; color: #fff; letter-spacing: .02em; }
.ico.folder { background: #E0B450; border-radius: 3px 8px 4px 4px; position: relative; height: 1.7rem; margin-top: .3rem; }
.ico.folder::before { content: ""; position: absolute; top: -.3rem; inset-inline-start: 0; width: 45%; height: .4rem; background: #C99A35; border-radius: 3px 3px 0 0; }
.ico.folder.inbox { background: var(--accent); } .ico.folder.inbox::before { background: color-mix(in srgb, var(--accent) 75%, black); }
.ico.up::before { content: "↑"; color: var(--muted); font-size: 1.1rem; font-weight: 400; }
.ico.kind-pdf { background: #C8382D; } .ico.kind-doc { background: #2B579A; } .ico.kind-xls { background: #217346; }
.ico.kind-ppt { background: #C43E1C; } .ico.kind-img { background: #7A5AA6; } .ico.kind-file { background: var(--muted); }
.ico.thumb { background: #fff; border: 1px solid var(--line); overflow: hidden; border-radius: 2px; }
.ico.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.x-info { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .9rem 1rem; position: sticky; top: 1rem; }
.x-info h2 { margin-top: 0; font-size: .84rem; color: var(--muted); }
.x-info h3 { margin: .5rem 0 .1rem; font-size: 1.08rem; }
.x-info .thumb { max-width: 150px; }
.x-info .meta { font-size: .9rem; margin-top: .6rem; }
/* grid view */
.explorer.as-grid .x-head { display: none; }
.explorer.as-grid .x-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: .4rem; padding: .6rem; }
.explorer.as-grid .x-row { border: 1px solid transparent; border-radius: var(--r); }
.explorer.as-grid .x-row.selected { border-color: var(--accent); }
.explorer.as-grid .x-link { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: .35rem; padding: .7rem .4rem; }
.explorer.as-grid .ico { width: 4.4rem; height: 5.6rem; font-size: .8rem; }
.explorer.as-grid .ico.folder { height: 3.4rem; margin-top: .9rem; margin-bottom: 1.3rem; }
.explorer.as-grid .ico.up { height: 3.4rem; }
.explorer.as-grid .x-name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: .88rem; }
.explorer.as-grid .x-name small, .explorer.as-grid .x-mod, .explorer.as-grid .x-exp { display: none; }
.explorer.as-grid .x-size { font-size: .74rem; }
@media (max-width: 860px) {
  .x-split { grid-template-columns: 1fr; }
  .x-info { position: static; }
  .x-head { display: none; }
  .x-link { grid-template-columns: 2.4rem minmax(0, 1fr) auto; }
  .x-mod, .x-exp { display: none; }
  .x-filter { width: 100% !important; }
  .x-tools { width: 100%; }
}

/* folders outline, settings */
.outline { list-style: none; margin: 0; padding: 0; }
.outline li { padding: .2rem 0; padding-inline-start: calc(var(--d) * 1.4rem); display: flex; gap: .5rem; align-items: center; }
.outline .seg { border-inline-start: 2px solid var(--accent); padding-inline-start: .6rem; }
.tabs { display: flex; gap: .2rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .4rem .8rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 1rem; font-size: .92rem; }
.table th, .table td { text-align: start; padding: .45rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .82rem; }
.table tr.pending { background: var(--warn-soft); }

/* viewer */
.viewer { position: fixed; inset: 0; background: rgba(15, 20, 28, .72); display: grid; place-items: center; padding: 12px; z-index: 50; }
.viewer[hidden] { display: none; }
.viewer-box { width: min(1100px, 100%); height: min(92vh, 100%); background: var(--surface); border-radius: 8px; display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
.viewer-box header { display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem; border-bottom: 1px solid var(--line); }
#viewer-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
#viewer-frame { width: 100%; height: 100%; border: 0; background: #525659; }
body.viewing { overflow: hidden; }

/* login */
.login-body { display: grid; place-items: center; padding: 16px; }
.login { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.6rem; }
.login form { display: grid; gap: .8rem; }
.login label { display: grid; gap: .2rem; font-size: .86rem; color: var(--muted); }
.login .brand { padding: 0 0 1rem; margin: 0; }

/* phone: bottom tab bar, one card at a time */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; padding: .25rem .3rem calc(.25rem + env(safe-area-inset-bottom)); border-inline-end: 0; border-top: 1px solid var(--line); z-index: 20; gap: 0; overflow-x: auto; }
  .nav .brand, .nav .logout { display: none; }
  .nav a:not(.brand) { flex: 1 0 auto; flex-direction: column; gap: 0; padding: .3rem .55rem; font-size: .78rem; text-align: center; position: relative; }
  .nav .count { position: absolute; top: 0; inset-inline-end: .1rem; font-size: .65rem; min-width: 1.1rem; padding: 0 .3rem; }
  .nav .ext { display: none; }
  .main { padding: 1rem 16px 5.5rem; }
  .split, .detail, .docgrid, .searchgrid { grid-template-columns: 1fr; }
  .list { position: static; max-height: none; grid-auto-flow: column; grid-auto-columns: 78%; overflow-x: auto; padding-bottom: .3rem; scroll-snap-type: x mandatory; }
  .list li { scroll-snap-align: start; }
  .preview { grid-template-columns: 88px minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .row { flex-wrap: wrap; }
  .row-act { width: 100%; justify-content: flex-start; }
  .inline { flex-wrap: wrap; }
  .viewer { padding: 0; } .viewer-box { height: 100%; border-radius: 0; }
  .table { display: block; overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* a similar document already exists: shown side by side, he decides */
.simbox { border: 1.5px solid var(--warn); background: var(--warn-soft); border-radius: var(--r); padding: .7rem .8rem; display: grid; gap: .5rem; }
.sim-head { margin: 0; font-weight: 700; color: var(--warn); }
.sim-advice { margin: 0; font-size: .9rem; }
.sim-cmp { width: 100%; border-collapse: collapse; font-size: .86rem; background: var(--surface); border-radius: var(--r); overflow: hidden; }
.sim-cmp th, .sim-cmp td { text-align: start; padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.sim-cmp th { color: var(--muted); font-weight: 500; font-size: .78rem; }
.sim-cmp tr:last-child td { border-bottom: 0; }
.sim-cmp td:first-child { color: var(--muted); white-space: nowrap; }
@media (max-width: 640px) { .sim-cmp th:nth-child(5), .sim-cmp td:nth-child(5) { display: none; } }
.sim-cmp td:nth-child(3), .sim-cmp td:nth-child(4) { white-space: nowrap; }
.btn.danger:not(.ghost) { background: var(--danger); border-color: var(--danger); color: #fff; }
