:root {
  --ink: #0b1020;
  --text: #2b3247;
  --muted: #5d6680;
  --line: #e4e7ef;
  --bg: #f5f7fb;
  --card: #ffffff;
  --accent: #c6ff3d;
  --violet: #6c5cff;
  --danger: #b91c1c;
  --radius: 14px;
  --font-head: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font: 15px/1.55 var(--font-body); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--violet); }
h1, h2, h3 { font-family: var(--font-head); color: var(--ink); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; line-height: 1.2; }
h2 { font-size: 1rem; margin-bottom: 12px; }
h3 { font-size: .9rem; margin-bottom: 8px; }
p { margin: 0 0 6px; }
.muted { color: var(--muted); }
.mt { margin-top: 20px; }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: .7em 1.3em; border-radius: 999px; background: var(--accent); color: var(--ink); border: 2px solid var(--accent); font: 600 .95rem var(--font-body); text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-sm { padding: .5em 1.1em; font-size: .88rem; }
.btn-ghost { background: transparent; border-color: var(--ink); }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; font: 500 .9rem var(--font-body); color: var(--muted); cursor: pointer; padding: 8px; }
.link-btn:hover { color: var(--ink); }
.link-btn.danger { color: var(--danger); justify-self: start; }
input, textarea, select { font: 400 .95rem var(--font-body); color: var(--ink); padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; width: 100%; }
input:disabled { background: var(--bg); color: var(--muted); }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus, .btn:focus-visible, a:focus-visible, .chip:focus-visible { outline: 3px solid rgba(108, 92, 255, .35); outline-offset: 1px; border-color: var(--violet); }
label { display: grid; gap: 6px; font-weight: 600; font-size: .85rem; color: var(--ink); }
label.chk { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.chk input { width: 18px; height: 18px; accent-color: var(--violet); }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 500 1.05rem var(--font-head); }
.brand b { font-weight: 700; }
.brand em { font-style: normal; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--violet); margin-left: 6px; }
.brand-mark { width: 30px; height: 30px; color: var(--accent); flex: none; }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(700px 400px at 90% 0%, rgba(108, 92, 255, .16), transparent 60%), var(--bg); }
.login-card { width: min(400px, 100%); background: var(--card); border-radius: 20px; padding: 32px; box-shadow: 0 30px 60px -30px rgba(11, 16, 32, .35); }
.login-card h1 { margin: 24px 0 20px; font-size: 1.5rem; }
.login-card form { display: grid; gap: 16px; }
.form-error { color: var(--danger); font-weight: 600; min-height: 1.2em; margin: 0; }

/* Layout */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { width: min(1200px, 100% - 32px); margin: 0 auto; display: flex; align-items: center; gap: 24px; min-height: 64px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; margin-right: auto; }
.tabs a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: .92rem; padding: 8px 14px; border-radius: 999px; }
.tabs a:hover { color: var(--ink); background: var(--bg); }
.tabs a.active { color: var(--ink); background: var(--accent); }
.wrap { width: min(1200px, 100% - 32px); margin: 0 auto; padding: 28px 0 64px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 12px; text-decoration: none; font-weight: 600; font-size: .9rem; }

/* Stats & filters */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat strong { display: block; font: 700 1.8rem var(--font-head); color: var(--ink); line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
.toolbar { display: grid; gap: 12px; margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; font: 600 .85rem var(--font-body); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip-count { font-size: .75rem; background: var(--bg); color: var(--muted); border-radius: 999px; padding: 0 7px; }
.chip.active .chip-count { background: rgba(255, 255, 255, .15); color: var(--accent); }
.search { max-width: 460px; }

/* Tables */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table-wrap.flat { border: 0; border-radius: 0; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: 0; }
tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--violet); }
td small { display: block; color: var(--muted); font-size: .8rem; }
td.num { white-space: nowrap; }
.row-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.empty { background: var(--card); border: 1px dashed #cdd2e0; border-radius: var(--radius); padding: 48px 24px; text-align: center; color: var(--muted); }

/* Status badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.s-new { background: #ece9ff; color: #4c3fd6; }
.s-reviewing { background: #e0f2fe; color: #0369a1; }
.s-awaiting_payment { background: #fef3c7; color: #92400e; }
.s-building { background: #ffedd5; color: #c2410c; }
.s-draft_sent { background: #fae8ff; color: #a21caf; }
.s-live { background: #dcfce7; color: #15803d; }
.s-closed { background: #eef0f4; color: #5d6680; }

/* Detail pages */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.col-main, .col-side { display: grid; gap: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card.stack { display: grid; gap: 14px; }
.card.stack h2 { margin: 0; }
.card textarea { margin-bottom: 10px; }
.fields { margin: 0; display: grid; gap: 14px; }
.field dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.field dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.file-card { display: grid; gap: 4px; text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: #fff; }
.file-card:hover { border-color: var(--violet); }
.file-card img, .file-ext { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--bg); }
.file-ext { display: grid; place-items: center; font: 700 1rem var(--font-head); color: var(--violet); }
.file-name { font-size: .82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card small { color: var(--muted); font-size: .75rem; }
.client-name { font-weight: 700; font-size: 1.05rem; }
.mini-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: .9rem; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: .9rem; z-index: 100; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4); }
.toast-err { background: var(--danger); }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .topbar-inner { gap: 8px; padding: 10px 0; }
  .tabs { order: 3; width: 100%; }
  .brand em { display: none; }
  #logout { margin-left: auto; }
  th:nth-child(n+4), td:nth-child(n+4) { display: none; }
  .search { max-width: none; }
}

/* Status change panel & client emails */
.change-panel { margin-top: 12px; padding: 14px; border: 1.5px solid #dcd7ff; background: #f7f6ff; border-radius: 12px; display: grid; gap: 12px; }
.change-panel[hidden], .change-panel [hidden] { display: none; }
.change-title { margin: 0; font-weight: 600; color: var(--ink); }
.email-bits { display: grid; gap: 10px; }
.email-bits textarea { margin: 0; }
.preview { display: grid; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; max-height: 260px; overflow: auto; }
.preview-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.preview strong { color: var(--ink); font-size: .92rem; }
.preview-text { white-space: pre-wrap; font-size: .86rem; color: var(--text); overflow-wrap: anywhere; }
.change-actions { display: flex; align-items: center; gap: 8px; }
.small { font-size: .85rem; margin: 0; }
.email-log { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.email-log details { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.email-log summary { cursor: pointer; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.email-log summary small { color: var(--muted); }
.email-subject { font-weight: 600; color: var(--ink); }
.email-log .preview-text { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.email-error { color: var(--danger); font-size: .86rem; margin: 10px 0 0; }
