/*
  Direction: a freight-office filing system. The current folder is always shown
  on a highway guide sign (green, white inset border, wide Archivo caps-height
  type). Everything else stays quiet: tinted paper, hairlines, dense rows.
  Reflective yellow is reserved for the single primary action.
*/

:root {
  --ink: #15201b;
  --ink-2: #47534d;
  --ink-3: #6b766f;
  --paper: #eef1ec;
  --panel: #f8faf6;
  --side: #e2e7e1;
  --line: #c8d0c9;
  --line-2: #dae0da;
  --sign: #0b5a3e;
  --sign-deep: #06402b;
  --sign-ink: #f6f8f3;
  --signal: #ffc20e;
  --signal-deep: #e9ae00;
  --danger: #b3261e;
  --r: 10px;
  --display: 'Archivo', system-ui, sans-serif;
  --body: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
::selection { background: var(--signal); color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

/* ---------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); font-weight: 600; white-space: nowrap;
  transition: background-color .12s, border-color .12s;
}
.btn:hover { background: #fff; border-color: #aeb8b0; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(21, 32, 27, .06); border-color: var(--line); }
.btn.primary { background: var(--signal); border-color: var(--signal-deep); color: var(--ink); }
.btn.primary:hover { background: #ffcd3a; border-color: var(--signal-deep); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13.5px; }
.btn.wide { width: 100%; height: 44px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink-2);
  text-decoration: none; list-style: none;
}
.icon-btn:hover { background: rgba(21, 32, 27, .08); color: var(--ink); }
summary.icon-btn::-webkit-details-marker { display: none; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], select {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fcfdfb;
}
input:focus, select:focus { border-color: var(--sign); outline: 2px solid rgba(11, 90, 62, .35); outline-offset: 0; }
.form-err { min-height: 1.4em; margin: 0 0 10px; color: var(--danger); font-size: 14px; }
.fine { color: var(--ink-3); font-size: 13.5px; margin: 14px 0 0; }

/* ------------------------------------------------------------------- login */

.login { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); min-height: 100dvh; }
.login-sign { display: flex; align-items: center; justify-content: center; padding: 16px; background: #034a33; }
.login-sign img { display: block; width: 100%; height: auto; max-height: calc(100dvh - 32px); object-fit: contain; border-radius: 14px; }
.login-form { align-self: center; width: min(100%, 400px); margin: 0 auto; padding: 32px 24px; }
.login-form h2 { margin: 0 0 22px; font: 700 1.6rem/1.1 var(--display); font-variation-settings: 'wdth' 112; }

@media (max-width: 800px) {
  .login { grid-template-columns: 1fr; min-height: 0; }
  .login-sign { padding: 0; }
  .login-sign img { border-radius: 0; }
  .login-form { padding: 20px 20px 40px; }
}

/* ------------------------------------------------------------------- shell */

.shell { display: grid; grid-template-columns: 288px minmax(0, 1fr); min-height: 100dvh; }

.side {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--side); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.mark { width: 30px; height: 30px; flex: none; }
.wordmark { font: 700 1.05rem/1 var(--display); font-variation-settings: 'wdth' 118; letter-spacing: -.005em; }

.tree { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.node-wrap { display: flex; align-items: center; padding-left: calc(var(--d, 0) * 16px); }
.caret {
  flex: none; width: 24px; height: 34px; display: grid; place-items: center;
  border: 0; background: none; color: var(--ink-3); border-radius: 6px;
}
.caret:disabled { visibility: hidden; }
.caret svg { transition: transform .14s; }
.caret[aria-expanded="true"] svg { transform: rotate(90deg); }
.node {
  flex: 1; min-width: 0; height: 34px; padding: 0 10px 0 6px;
  display: flex; align-items: center; gap: 8px; text-align: left;
  border: 0; border-radius: 8px; background: none; position: relative;
}
.node:hover { background: rgba(21, 32, 27, .07); }
.node.on { background: var(--sign); color: var(--sign-ink); font-weight: 600; }
.node .ico { flex: none; color: var(--ink-3); }
.node.on .ico { color: var(--signal); }
.node .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .ct { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.node.on .ct { color: rgba(246, 248, 243, .75); }
.node.root { margin: 0 0 4px; padding-left: 10px; }
.tree-empty { padding: 10px 14px; color: var(--ink-3); font-size: 13.5px; }

.side-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px; border-top: 1px solid var(--line);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.who { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 6px; border: 0; border-radius: 8px; background: none; text-align: left; }
.who:hover { background: rgba(21, 32, 27, .07); }
.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 14px;
}
.who-text { display: grid; min-width: 0; line-height: 1.25; }
.who-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.who-text small { color: var(--ink-3); font-size: 12.5px; }

.scrim { position: fixed; inset: 0; background: rgba(21, 32, 27, .45); z-index: 20; }

.main { min-width: 0; padding-bottom: 60px; }

/* --------------------------------------------------------------------- bar */

.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 24px; background: rgba(238, 241, 236, .92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line-2);
}
.menu-btn { display: none; }
.search { position: relative; flex: 1 1 260px; min-width: 0; display: block; }
.search svg { position: absolute; left: 12px; top: 12px; color: var(--ink-3); pointer-events: none; }
.search input { padding-left: 38px; }
.dates { display: flex; gap: 8px; }
.dates label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink-2); font-weight: 600; }
.dates input { width: 140px; height: 38px; font-size: 14px; }

/* -------------------------------------------------------------------- sign */

.sign-wrap { margin: 22px 24px 0; }
.sign {
  position: relative; display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
  padding: 28px 32px 26px; border-radius: 16px;
  background: var(--sign); color: var(--sign-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 7px 0 -2px var(--sign-deep), 0 16px 28px -16px rgba(6, 64, 43, .75);
}
.sign::before {
  content: ''; position: absolute; inset: 8px; border: 2px solid var(--sign-ink); border-radius: 10px;
  opacity: .92; pointer-events: none;
}
.sign-text { position: relative; min-width: 0; }
.sign h1 {
  margin: 0; font: 700 clamp(1.7rem, 4.2vw, 2.75rem)/1.06 var(--display);
  font-variation-settings: 'wdth' 125; letter-spacing: -.012em; overflow-wrap: anywhere; text-wrap: balance;
}
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin-top: 10px; font-size: 14px; color: rgba(246, 248, 243, .82); }
.crumbs button { padding: 0; border: 0; background: none; color: inherit; text-decoration: underline; text-decoration-color: rgba(246, 248, 243, .4); text-underline-offset: 3px; }
.crumbs button:hover { color: #fff; text-decoration-color: #fff; }
.crumbs button:focus-visible { outline-color: var(--sign-ink); }
.crumbs .sep { opacity: .5; }
.sign-count { position: relative; text-align: right; flex: none; }
.sign-count b {
  display: block; font: 800 clamp(2.1rem, 5vw, 3.4rem)/1 var(--display);
  font-variation-settings: 'wdth' 118; font-variant-numeric: tabular-nums;
}
.sign-count span { display: block; margin-top: 4px; font-size: 13.5px; color: rgba(246, 248, 243, .82); }

@keyframes sign-reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: no-preference) {
  .sign.reveal .sign-text { animation: sign-reveal .36s cubic-bezier(.2, .7, .2, 1) both; }
}

.sign-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* ----------------------------------------------------------------- uploads */

.uploads { display: grid; gap: 8px; margin: 14px 24px 0; }
.uploads:empty { display: none; }
.up { padding: 10px 14px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.up-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 600; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-pct { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.up-track { height: 6px; margin-top: 8px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.up-fill { height: 100%; width: 0; background: var(--sign); transition: width .15s linear; }
.up.err { border-color: var(--danger); }
.up.err .up-fill { background: var(--danger); }
.up-msg { margin: 6px 0 0; font-size: 13.5px; color: var(--danger); }

/* ----------------------------------------------------------------- content */

.content { margin: 18px 24px 0; transition: opacity .12s; }
.content.busy { opacity: .55; }
.group-title { margin: 22px 2px 8px; font: 700 1rem/1.2 var(--display); font-variation-settings: 'wdth' 112; color: var(--ink-2); }
.group-title:first-child { margin-top: 4px; }

.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.list > li:first-child { border-radius: 12px 12px 0 0; }
.list > li:last-child { border-radius: 0 0 12px 12px; }
.list > li:only-child { border-radius: 12px; }

.folder-row { border-top: 1px solid var(--line-2); }
.folder-row:first-child { border-top: 0; }
.folder-row button {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border: 0; background: none; text-align: left; border-radius: inherit;
}
.folder-row button:hover { background: rgba(11, 90, 62, .06); }
.folder-row .ico { color: var(--sign); flex: none; }
.folder-row .nm { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-row .sub { color: var(--ink-3); font-size: 13.5px; display: flex; gap: 14px; }

.doc, .doc-head {
  display: grid; grid-template-columns: minmax(0, 1fr) 150px 88px 128px 88px;
  align-items: center; column-gap: 12px; padding: 9px 14px;
}
.doc { border-top: 1px solid var(--line-2); }
.doc:hover { background: rgba(11, 90, 62, .045); }
.doc-head { padding-top: 8px; padding-bottom: 8px; background: var(--side); font-size: 13px; font-weight: 600; color: var(--ink-2); border-bottom: 1px solid var(--line); }
.doc-head button { padding: 4px 0; border: 0; background: none; font-weight: 600; color: inherit; text-align: left; display: inline-flex; gap: 4px; align-items: center; }
.doc-head button:hover { color: var(--ink); }
.doc-head button.on { color: var(--ink); }
.doc-head .r, .c-size { text-align: right; }
.doc-head .r { justify-self: end; }

.doc-name { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; padding: 4px 0; }
.doc-name:hover .t { text-decoration: underline; text-underline-offset: 3px; }
.doc-title { min-width: 0; display: grid; }
.doc-title .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.doc-title .where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--ink-3); }
.badge {
  flex: none; width: 40px; height: 28px; display: grid; place-items: center; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em; background: #e6e9e5; color: #3e4943;
}
.badge.pdf { background: #f6dcd6; color: #9a2f1b; }
.badge.word { background: #dbe5f4; color: #24518f; }
.badge.xls { background: #d6ebdf; color: #1b6842; }
.badge.img { background: #e7dff2; color: #5f4392; }
.badge.zip { background: #f1e6cf; color: #7a5a12; }

.c-by, .c-size, .c-date { font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-size, .c-date { font-variant-numeric: tabular-nums; }
.c-meta { display: contents; }
.c-act { display: flex; justify-content: flex-end; gap: 2px; }

.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; min-width: 150px; padding: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 24px -8px rgba(21, 32, 27, .28);
}
.menu-pop button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: none; text-align: left; }
.menu-pop button:hover { background: var(--paper); }
.menu-pop .danger { color: var(--danger); }

.empty { padding: 44px 24px; text-align: center; background: var(--panel); border: 1px dashed #aab5ac; border-radius: 12px; }
.empty h2 { margin: 0 0 6px; font: 700 1.2rem/1.2 var(--display); font-variation-settings: 'wdth' 112; }
.empty p { margin: 0 auto; max-width: 30rem; color: var(--ink-2); }
.notice { margin: 12px 2px 0; color: var(--ink-3); font-size: 13.5px; }

/* --------------------------------------------------------------- drop zone */

.drop {
  position: fixed; inset: 12px; z-index: 40; display: grid; place-items: center; pointer-events: none;
  border: 3px dashed var(--sign); border-radius: 18px; background: rgba(238, 241, 236, .9);
}
.drop p { margin: 0; padding: 14px 22px; background: var(--sign); color: var(--sign-ink); border-radius: 12px; font: 700 1.3rem/1.2 var(--display); font-variation-settings: 'wdth' 118; }

/* ------------------------------------------------------------- dialog, toast */

dialog {
  width: min(92vw, 460px); max-height: 88dvh; padding: 0; border: 0; border-radius: 16px;
  background: var(--panel); color: var(--ink); box-shadow: 0 24px 60px -12px rgba(21, 32, 27, .5);
}
dialog.wide { width: min(94vw, 580px); }
dialog::backdrop { background: rgba(21, 32, 27, .5); }
.dlg { padding: 22px 22px 18px; }
.dlg h2 { margin: 0 0 6px; font: 700 1.3rem/1.15 var(--display); font-variation-settings: 'wdth' 112; }
.dlg h3 { margin: 26px 0 10px; font: 700 1rem/1.2 var(--display); font-variation-settings: 'wdth' 112; }
.dlg .lead { margin: 0 0 16px; color: var(--ink-2); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dlg .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.pick { max-height: 46dvh; overflow-y: auto; margin: 0 0 14px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: #fcfdfb; }
.pick label {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px calc(10px + var(--d, 0) * 16px);
  border-radius: 7px; cursor: pointer;
}
.pick label:hover { background: var(--paper); }
.pick label.off { opacity: .4; cursor: not-allowed; }
.pick input { accent-color: var(--sign); width: 16px; height: 16px; }

.people { list-style: none; margin: 0 0 4px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: #fcfdfb; }
.people li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 9px 12px; border-top: 1px solid var(--line-2); }
.people li:first-child { border-top: 0; }
.people .p-main { flex: 1 1 12rem; min-width: 0; display: grid; line-height: 1.3; }
.people .p-main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .p-main small { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .role { font-size: 12.5px; padding: 2px 8px; border-radius: 99px; background: var(--side); color: var(--ink-2); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 60;
  max-width: min(92vw, 460px); padding: 11px 16px; border-radius: 10px;
  background: var(--ink); color: var(--paper); font-size: 14.5px; font-weight: 500;
  transform: translate(-50%, 24px); opacity: 0; pointer-events: none; transition: transform .2s, opacity .2s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.err { background: var(--danger); }

/* ------------------------------------------------------------------ mobile */

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; z-index: 30; width: min(86vw, 320px);
    transform: translateX(-104%); transition: transform .22s cubic-bezier(.2, .7, .2, 1);
    box-shadow: 0 0 40px rgba(21, 32, 27, .35);
  }
  .side.open { transform: none; }
  .menu-btn { display: inline-grid; margin-left: -6px; }
  .bar { padding: 10px 14px; gap: 8px; }
  .search { flex: 1 1 0; }
  .dates { order: 5; flex: 1 1 100%; }
  .dates label { flex: 1; }
  .dates input { flex: 1; width: 100%; min-width: 0; }
  #clearSearch { order: 6; }
  .sign-wrap { margin: 16px 14px 0; }
  .sign { flex-direction: column; align-items: flex-start; gap: 14px; padding: 22px 22px 20px; }
  .sign::before { inset: 6px; }
  .sign-count { text-align: left; display: flex; align-items: baseline; gap: 8px; }
  .sign-count span { margin: 0; }
  .uploads, .content { margin-left: 14px; margin-right: 14px; }

  .doc-head { display: none; }
  .list > li.doc:first-child { border-radius: 12px 12px 0 0; }
  .doc {
    grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name act" "meta act";
    row-gap: 0; padding: 8px 8px 8px 12px;
  }
  .doc-name { grid-area: name; }
  .c-by { display: none; }
  .c-meta { grid-area: meta; display: flex; gap: 12px; padding-left: 52px; margin-top: -2px; }
  .c-meta .c-size, .c-meta .c-date { font-size: 13px; color: var(--ink-3); text-align: left; }
  .c-act { grid-area: act; align-self: center; }
  .icon-btn { width: 40px; height: 40px; }
}

@media (max-width: 420px) {
  .dlg .grid2 { grid-template-columns: 1fr; }
  #uploadBtn { padding: 0 12px; }
}
