:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --ink: #1d1f23;
  --muted: #6b6e76;
  --line: #e3e1db;
  --accent: #1f5eff;
  --accent-ink: #ffffff;
  --approve: #137a4b;
  --approve-bg: #e3f4ea;
  --changes: #a6510b;
  --changes-bg: #fdeedd;
  --pending: #3b4bb8;
  --pending-bg: #e8eafb;
  --danger: #b42318;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .06), 0 4px 16px rgba(20, 20, 30, .04);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.5; font-size: 15px; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
code { background: #efeee9; padding: 1px 6px; border-radius: 4px; font-size: .9em; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.empty { color: var(--muted); padding: 18px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--muted); margin: 0 0 .2rem; font-weight: 600; }

/* Top bar */
.topbar { background: var(--ink); color: #fff; margin-bottom: 28px; }
.mode-client .topbar { background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; flex-wrap: wrap; }
.brand { color: inherit; text-decoration: none; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.brand-sub { font-weight: 400; opacity: .7; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), #8f5bff); }
.topnav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.topnav a, .linkish { color: #d8dae0; text-decoration: none; font-size: .92rem; background: none; border: 0; cursor: pointer; padding: 0; font: inherit; }
.topnav a:hover, .linkish:hover { color: #fff; }
.inline { display: inline; margin: 0; }
.mode-auth .topbar { background: transparent; color: var(--ink); }
.footer { color: var(--muted); font-size: .8rem; padding: 40px 16px; }

/* Cards & layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card.highlight { border-color: #c9d6ff; }
.card.narrow { max-width: 480px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: .2rem 0 0; }
.crumbs { margin: 0 0 8px; font-size: .9rem; }
.crumbs a { text-decoration: none; color: var(--muted); }
details > summary { cursor: pointer; padding: 4px 0; }
details[open] > summary { margin-bottom: 12px; }

/* Forms */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; font-weight: 400; }
input[type=text], input:not([type]), input[type=password], textarea, input[type=file] {
  font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid #cfccc4; border-radius: 8px; background: #fff; width: 100%; color: var(--ink);
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[readonly] { background: #f8f7f4; }
textarea { resize: vertical; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; align-items: end; margin-top: 12px; }
.form-actions { display: flex; }
.inline-form { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.inline-form input { flex: 1 1 200px; width: auto; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }

.btn { font: inherit; font-weight: 600; font-size: .92rem; border-radius: 8px; padding: 10px 16px; border: 1px solid #cfccc4; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: #f4f3ef; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #164ad1; }
.btn-approve { background: var(--approve); border-color: var(--approve); color: #fff; }
.btn-approve:hover { background: #0e623c; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: #f0c4bf; background: #fff; }
.btn-danger:hover { background: #fdf0ee; }
.decision-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Flash */
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--approve-bg); color: #0d5233; border: 1px solid #bfe3cd; }
.flash-error { background: #fdecea; color: #8a1c13; border-color: #f4c3bd; }
.flash-info { background: var(--pending-bg); color: #28308a; border-color: #cdd2f6; }

/* Auth */
.auth-card { max-width: 420px; margin: 40px auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: .4rem; }

/* Badges */
.badge { display: inline-block; font-size: .76rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #eceae4; color: var(--muted); white-space: nowrap; }
.badge-pending { background: var(--pending-bg); color: var(--pending); }
.badge-approved { background: var(--approve-bg); color: var(--approve); }
.badge-changes { background: var(--changes-bg); color: var(--changes); }
.badge-removed, .badge-replaced { background: #eceae4; color: var(--muted); }
.count { font-size: .8rem; color: var(--muted); background: #eceae4; border-radius: 999px; padding: 1px 8px; vertical-align: middle; }

/* Project list */
.project-list { display: flex; flex-direction: column; gap: 10px; }
.project-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-decoration: none; color: inherit; margin: 0; flex-wrap: wrap; }
.project-row:hover { border-color: #bfbcb3; }
.project-main { display: flex; flex-direction: column; }
.project-stats { display: flex; gap: 6px; flex-wrap: wrap; }

/* Share box */
.share-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 8px; }
.share textarea { margin-bottom: 8px; font-size: .9rem; }

/* Upload */
.upload-form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.dropzone { width: 100%; border: 2px dashed #c8c5bc; border-radius: var(--radius); padding: 22px; text-align: center; font-weight: 400; position: relative; background: #fbfaf8; cursor: pointer; }
.dropzone:hover { border-color: var(--accent); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.preview { display: flex; gap: 10px; flex-wrap: wrap; }
.preview:empty { display: none; }
.preview-item { width: 110px; font-size: .75rem; color: var(--muted); }
.preview-item img { width: 110px; height: 80px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.preview-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Design grid */
.design-section { margin: 28px 0; }
.design-section > summary { list-style: none; }
.design-section > summary::after { content: "Show"; font-size: .85rem; color: var(--accent); margin-left: 10px; }
.design-section[open] > summary::after { content: "Hide"; }
.inline-h { display: inline; }
.design-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.design-grid.faded { opacity: .75; }
.design-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.design-card:hover { transform: translateY(-2px); border-color: #bfbcb3; }
.thumb { display: block; aspect-ratio: 4 / 3; background: #ecebe6 repeating-conic-gradient(#e4e2dc 0 25%, #ecebe6 0 50%) 0 0 / 16px 16px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.design-meta { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.snippet { font-size: .85rem; color: var(--changes); background: var(--changes-bg); padding: 6px 8px; border-radius: 6px; margin-top: 4px; }
.cta-text { color: var(--accent); font-weight: 600; font-size: .9rem; }

/* Design detail */
.design-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
.viewer { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.viewer img { max-width: 100%; max-height: 78vh; display: block; margin: 0 auto; background: repeating-conic-gradient(#eeede8 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.viewer figcaption { text-align: center; margin-top: 8px; }
.side { position: sticky; top: 16px; }
.thread { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { border-radius: 8px; padding: 10px 12px; background: #f7f6f2; border: 1px solid var(--line); }
.msg-client { background: var(--changes-bg); border-color: #f4d6b5; }
.msg-client.msg-approval { background: var(--approve-bg); border-color: #bfe3cd; }
.msg-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.msg-body { white-space: normal; word-wrap: break-word; }
.approval-line { color: var(--approve); font-weight: 700; }
.danger-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.history { display: flex; flex-direction: column; gap: 10px; }
.history-item { display: flex; gap: 14px; align-items: flex-start; }
.history-item.compact { margin-bottom: 12px; }
.history-item p { margin: 4px 0 0; }
.small-thumb { width: 110px; flex: none; border-radius: 6px; }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.row-actions { text-align: right; }
.row-actions details { display: inline-block; text-align: left; }

@media (max-width: 860px) {
  .design-layout { grid-template-columns: 1fr; }
  .side { position: static; }
  .share-grid { grid-template-columns: 1fr; }
  .topbar { margin-bottom: 18px; }
}
@media (max-width: 480px) {
  .decision-buttons { grid-template-columns: 1fr; }
  .design-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .design-meta { padding: 10px; }
  h1 { font-size: 1.35rem; }
}
