/* Trunkline brand: charcoal #313131, orange #CD7A36 (clay #A8591F for readable text/buttons) */
:root {
  --bg: #FAF9F7; --panel: #FFFFFF; --text: #1F1F1F; --muted: #5F5F5F; --line: #ECE9E5;
  --accent: #A8591F; --accent-soft: #FBEBDD; --on-accent: #FFFFFF; --brand: #CD7A36;
  --danger: #B3261E; --ok: #1E6B30; --warn: #8A5A00; --lock: #8A8580;
  --side-bg: #313131; --side-text: #EDEDED; --side-muted: #A9A9A9; --side-hover: #3D3D3D; --side-line: #444;
  --side-active-bg: rgba(205,122,54,.22); --side-active-text: #F3B27A;
  --radius: 10px; --shadow: 0 1px 2px rgba(49,49,49,.06), 0 4px 16px rgba(49,49,49,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1A1A1A; --panel: #242424; --text: #ECECEC; --muted: #A6A6A6; --line: #353535;
    --accent: #E08A45; --accent-soft: #3A2A1C; --on-accent: #1A1A1A;
    --danger: #EF6B5F; --ok: #5DBB7A; --warn: #E0A040; --lock: #7A7570;
    --side-bg: #121212; --side-hover: #222; --side-line: #2E2E2E;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.small { padding: 3px 9px; font-size: 13px; }
a > button { color: var(--text); }
button.link { border: none; background: none; padding: 0; color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-weight: 500; margin: 12px 0 4px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 360px; background: var(--panel); padding: 28px; border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); border-top: 4px solid var(--brand); }
.login .logo { width: 200px; height: auto; margin: 4px 0 18px; }
.login h1 { margin: 0 0 4px; font-size: 20px; }
/* Show one wordmark: charcoal on light backgrounds, white on dark */
img.logo.logo-light { display: block; }
img.logo.logo-dark { display: none; }
@media (prefers-color-scheme: dark) { img.logo.logo-light { display: none; } img.logo.logo-dark { display: block; } }
.login button { width: 100%; margin-top: 18px; }
.error { color: var(--danger); margin-top: 10px; min-height: 1.4em; }

/* Shell */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100%; }
.side { background: var(--side-bg); color: var(--side-text); padding: 18px 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.brand { padding: 2px 10px 18px; }
.brand img { display: block; width: 150px; height: auto; }
.brand .sub { color: var(--side-muted); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; margin-top: 8px; }
.nav-head { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); padding: 16px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--side-text); border-left: 3px solid transparent; }
.nav a:hover { background: var(--side-hover); }
.nav a.active { background: var(--side-active-bg); color: var(--side-active-text); font-weight: 600; border-left-color: var(--brand); }
.badge { margin-left: auto; background: var(--brand); color: #1F1F1F; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.side .who { margin-top: auto; border-top: 1px solid var(--side-line); padding: 12px 10px 0; font-size: 13px; }
.side .who .muted { color: var(--side-muted); }
.side .who a, .side .who button.link { color: var(--side-active-text); }
.main { padding: 22px 28px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.topbar h2 { margin: 0; font-size: 20px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 18px; font-weight: 600; }
.crumbs a { color: var(--muted); font-weight: 500; }
.crumbs .sep { color: var(--muted); }
.menu-btn { display: none; }

/* Table */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--bg); }
tr:last-child td { border-bottom: none; }
tbody tr.item:hover { background: var(--bg); }
td.name { display: flex; align-items: center; gap: 10px; min-width: 0; }
td.name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.name button.link { color: var(--text); text-align: left; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.name button.link:hover { color: var(--accent); }
tr.locked td.name .nm, tr.locked td.name button.link { color: var(--muted); }
td.actions { text-align: right; white-space: nowrap; }
td.actions > * { margin-left: 4px; }
.ico { width: 20px; height: 20px; flex: none; }
.ico.folder { color: var(--brand); }
.ico.file { color: var(--muted); }
.ico.lock { width: 14px; height: 14px; color: var(--lock); }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.pending { color: var(--warn); border-color: currentColor; }
.pill.approved, .pill.open { color: var(--ok); border-color: currentColor; }
.pill.denied { color: var(--danger); border-color: currentColor; }
.pill.edit { color: var(--accent); border-color: currentColor; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.banner { background: var(--accent-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.drop-hint { outline: 2px dashed var(--accent); outline-offset: -6px; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* Modal */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--panel); color: var(--text); width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog.wide { width: min(1000px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10,14,22,.45); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-content { padding: 4px 18px 18px; max-height: 70vh; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.preview { background: var(--bg); display: grid; place-items: center; min-height: 300px; }
.preview iframe { width: 100%; height: 72vh; border: 0; background: #fff; }
.preview img, .preview video { max-width: 100%; max-height: 72vh; }
.levels { font-size: 12px; color: var(--muted); margin: 10px 0; }
.levels b { color: var(--text); }

#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; }
.toast.err { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: inline-block; }
  .main { padding: 16px; }
  .hide-sm { display: none; }
  th, td { padding: 9px 10px; }
}
