:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --panel-2: #fafaf9;
  --line: #e7e5e4;
  --line-2: #d6d3d1;
  --text: #1c1917;
  --muted: #78716c;
  --soft: #a8a29e;
  --accent: #18181b;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.14);
  --side: 248px;

  --s-brief: #a8a29e;
  --s-in_progress: #3b82f6;
  --s-internal_review: #8b5cf6;
  --s-client_review: #f59e0b;
  --s-changes_requested: #ef4444;
  --s-approved: #10b981;
  --s-delivered: #0f766e;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--panel-2); border-color: var(--soft); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.ok { background: #059669; border-color: #059669; color: #fff; }
.btn.warn { background: #fff; border-color: #f59e0b; color: #b45309; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 8px; border: 0; background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: rgba(0,0,0,.06); color: var(--text); }

label.field { display: block; }
label.field > span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.input, select.input, textarea.input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 14px 0 4px; }
.auth-logo { height: 40px; max-width: 180px; object-fit: contain; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-head { padding: 16px 16px 12px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.side-head img { height: 28px; max-width: 120px; object-fit: contain; }
.side-head .name { font-weight: 600; }
.side-scroll { flex: 1; overflow: auto; padding: 10px 8px; }
.side-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--soft); padding: 12px 10px 6px; display: flex; justify-content: space-between; align-items: center; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: #44403c; cursor: pointer; }
.nav-item:hover { background: #f5f5f4; }
.nav-item.active { background: #f0efed; color: var(--text); font-weight: 500; }
.nav-item .count { margin-left: auto; font-size: 11px; color: var(--muted); background: #f5f5f4; border-radius: 99px; padding: 0 7px; }
.nav-item.active .count { background: #fff; }
.client-thumb { width: 24px; height: 24px; border-radius: 6px; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 600; color: #fff; overflow: hidden; background: var(--c, #18181b); }
.client-thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.client-thumb.lg { width: 48px; height: 48px; border-radius: 10px; font-size: 18px; border: 1px solid var(--line); }
.side-foot { border-top: 1px solid var(--line); padding: 10px; display: flex; align-items: center; gap: 8px; }
.avatar { width: 28px; height: 28px; border-radius: 99px; background: #e7e5e4; display: grid; place-items: center; font-size: 11px; font-weight: 600; flex: none; color: #44403c; }

.main { min-width: 0; }
.topbar { display: none; }
.page { padding: 24px 32px 48px; max-width: 1400px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .meta { font-size: 13px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tab { padding: 9px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-color: var(--accent); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.card-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.kpi { padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi.alert .v { color: #dc2626; }
.kpi.wait .v { color: #b45309; }
.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }

/* ---------- status / pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; background: color-mix(in srgb, var(--c) 12%, #fff); color: color-mix(in srgb, var(--c) 80%, #000); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 99px; background: var(--c); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11px; font-weight: 500; background: #f5f5f4; color: #57534e; white-space: nowrap; }
.tag.high { background: #fef3c7; color: #92400e; }
.tag.urgent { background: #fee2e2; color: #991b1b; }
.tag.internal { background: #fef9c3; color: #854d0e; }
.tag.hiddenfromclient { background: #f1f5f9; color: #475569; }
.due.over { color: #dc2626; font-weight: 500; }
.due.soon { color: #b45309; }

/* ---------- table ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .input { width: auto; }
.toolbar .search { width: 240px; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
.t td { padding: 10px 12px; border-bottom: 1px solid #f0efed; vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover { background: #fafaf9; }
.t .ref { font-size: 12px; color: var(--soft); font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* ---------- board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: #efeeec; border-radius: 12px; padding: 8px; min-height: 120px; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 8px; }
.col-head .n { font-size: 12px; color: var(--muted); }
.dcard { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.dcard:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.dcard.dragging { opacity: .4; }
.dcard .t1 { font-weight: 500; margin: 2px 0 6px; }
.dcard .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }

/* ---------- list items ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid #f0efed; cursor: pointer; text-decoration: none; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: #fafaf9; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.activity { padding: 4px 16px 10px; }
.act { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f5f5f4; font-size: 13px; }
.act:last-child { border-bottom: 0; }

/* ---------- drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(28,25,23,.35); z-index: 50; animation: fade .15s ease; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(1180px, 100%); background: var(--bg); z-index: 51; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slide .2s cubic-bezier(.2,.8,.2,1); }
@keyframes fade { from { opacity: 0 } }
@keyframes slide { from { transform: translateX(24px); opacity: 0 } }
.drawer-head { padding: 14px 20px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.drawer-body { flex: 1; overflow: auto; display: grid; grid-template-columns: 1fr 380px; gap: 0; }
.drawer-main { padding: 20px; min-width: 0; }
.drawer-side { border-left: 1px solid var(--line); background: #fff; padding: 20px; overflow: auto; }

.viewer { background: #0c0a09; border-radius: 12px; overflow: hidden; aspect-ratio: 16/9; position: relative; }
.viewer iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.viewer .ph { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #a8a29e; padding: 24px; }
.viewer .ph b { color: #fff; display: block; margin-bottom: 6px; font-size: 15px; }
.viewer-bar { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; flex-wrap: wrap; }
.vchip { height: 28px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line-2); background: #fff; cursor: pointer; font-size: 12px; font-weight: 500; }
.vchip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.frameio-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

.decision { border: 1px solid #fcd34d; background: #fffbeb; border-radius: 12px; padding: 14px 16px; margin: 16px 0; }
.decision.done { border-color: #a7f3d0; background: #ecfdf5; }

.comments { display: flex; flex-direction: column; gap: 10px; }
.comment { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.comment.internal { background: #fefce8; border-color: #fde68a; }
.comment.client { border-left: 3px solid var(--accent); }
.comment .who { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.comment .who b { color: var(--text); font-weight: 600; }
.comment .body { white-space: pre-wrap; word-wrap: break-word; }
.composer { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.composer textarea { border: 0; box-shadow: none !important; min-height: 60px; padding: 4px 6px; }

dl.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- modal ---------- */
.modal { position: fixed; z-index: 61; left: 50%; top: 8vh; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); max-height: 84vh; overflow: auto; background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); animation: fade .15s ease; }
.modal.wide { width: min(760px, calc(100% - 32px)); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: var(--panel-2); border-radius: 0 0 14px 14px; }
#modal-root .overlay { z-index: 60; }

.logo-drop { display: flex; align-items: center; gap: 14px; }
.logo-box { width: 88px; height: 88px; border-radius: 12px; border: 1px dashed var(--line-2); display: grid; place-items: center; overflow: hidden; background: #fff; color: var(--soft); font-size: 12px; text-align: center; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }

.secret { font-family: ui-monospace, Consolas, monospace; background: #f5f5f4; border: 1px solid var(--line); padding: 10px 12px; border-radius: 8px; user-select: all; overflow-wrap: anywhere; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 99; }
#toast .t { background: #1c1917; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); margin-top: 8px; animation: fade .2s; }
#toast .t.bad { background: #b91c1c; }

/* ---------- client portal ---------- */
.portal-top { background: #fff; border-bottom: 1px solid var(--line); }
.portal-top .in { max-width: 1180px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; gap: 14px; }
.portal-top img.logo { height: 48px; max-width: 260px; object-fit: contain; display: block; }
.portal-hero { max-width: 1180px; margin: 0 auto; padding: 28px 24px 8px; }
.portal-body { max-width: 1180px; margin: 0 auto; padding: 8px 24px 60px; }
.preview-bar { background: var(--accent); color: var(--accent-ink); font-size: 13px; padding: 8px 16px; display: flex; justify-content: center; align-items: center; gap: 12px; }
.preview-bar .btn { height: 26px; font-size: 12px; background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.3); color: inherit; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.review-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.review-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.review-card .thumb { aspect-ratio: 16/9; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 85%, #000), color-mix(in srgb, var(--accent) 55%, #fff)); display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.review-card .in { padding: 12px 14px; }
.section-title { display: flex; align-items: baseline; gap: 8px; margin: 26px 0 12px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .drawer-body { grid-template-columns: 1fr; }
  .drawer-side { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; width: 280px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .app.nav-open .side { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .page { padding: 18px 16px 40px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .toolbar .search { width: 100%; }
  .portal-top .in, .portal-hero, .portal-body { padding-left: 16px; padding-right: 16px; }
  .drawer-head { padding: 12px 16px; }
  .drawer-main, .drawer-side { padding: 16px; }
}
