@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/public/fonts/inter-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/public/fonts/inter-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/public/fonts/inter-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/public/fonts/inter-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/public/fonts/inter-latin-800-normal.woff2') format('woff2');
}

:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #14181f;
  --muted: #6b7280;
  --muted-2: #9aa2b1;
  --border: #e5e8ee;
  --border-strong: #d7dbe3;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0fe;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, .08);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
/* Explicit base size so any element without its own font-size rule lands
   in scale with the rest of the UI (13-15.5px) instead of the browser's
   16px default, which was the root cause of some text looking oversized
   next to headers and section labels. */
body { font-size: 14.5px; padding-bottom: 76px; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; letter-spacing: -0.01em; font-size: 19px; }
p { line-height: 1.55; }
::selection { background: var(--primary-soft); }

/* ---------- Top bar & nav ---------- */
.topbar {
  display: flex; align-items: center; gap: 22px;
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 13px 20px; position: sticky; top: 0; z-index: 20;
  box-shadow: var(--shadow-sm);
}
.topbar .brand { font-weight: 800; color: var(--text); font-size: 16.5px; display: flex; align-items: center; gap: 8px; }
.topbar .brand .brand-dot { width: 9px; height: 9px; border-radius: 3px; background: linear-gradient(135deg, var(--primary), #818cf8); display: inline-block; }
.topnav { display: none; gap: 4px; flex: 1; }
.topnav a { color: var(--muted); font-weight: 600; padding: 8px 12px; border-radius: 999px; font-size: 14px; transition: background .15s, color .15s; }
.topnav a.active { color: var(--primary); background: var(--primary-soft); }
.topnav a:hover { color: var(--primary); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13.5px; color: var(--muted); }
.topbar-user .user-name { font-weight: 600; color: var(--text); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px;
}
.link-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13.5px; padding: 0; font-weight: 600; transition: color .15s; }
.link-btn:hover { color: var(--danger); }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 10px rgba(16,24,40,.05);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 7px; color: var(--muted-2); font-size: 11px; font-weight: 600;
  transition: color .15s;
}
.bottomnav a .icon { font-size: 19px; line-height: 1; }
.bottomnav a.active { color: var(--primary); }

@media (min-width: 900px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  body { padding-bottom: 20px; }
}

.container { max-width: 1100px; margin: 0 auto; padding: 18px; }
.container-narrow { max-width: 640px; margin: 0 auto; padding: 18px; }

.page-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.page-header h1 { font-size: 21px; }
.page-header .subtitle { font-size: 13.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow-sm); transition: background .15s, transform .1s, box-shadow .15s;
}
.btn:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px); }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border-strong); box-shadow: none; }
.btn-secondary:hover { background: #f7f8fa; box-shadow: none; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 7px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.filters select, .filters input[type=text] {
  padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: #fff; font-size: 14px;
}
.filters select:focus, .filters input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

.project-card { display: block; color: var(--text); transition: box-shadow .15s, transform .1s; }
.project-card:hover { box-shadow: var(--shadow-md); }
.project-card .row1 { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.project-card .title { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.project-card .brand { color: var(--muted); font-size: 13px; }
.project-card .meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 10px; font-size: 12.5px; color: var(--muted); }
.project-card .meta strong { color: var(--text); }

/* ---------- Brand card grid ---------- */
.brand-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .brand-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .brand-grid { grid-template-columns: repeat(3, 1fr); } }

.brand-card {
  display: block; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm); color: var(--text);
  transition: box-shadow .15s, border-color .15s, transform .1s;
}
.brand-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.brand-card-top { display: flex; align-items: flex-start; gap: 12px; }
.brand-card-avatar {
  flex: none; width: 42px; height: 42px; border-radius: 12px; background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px;
}
.brand-card-heading { flex: 1; min-width: 0; }
.brand-card-name { font-weight: 700; font-size: 15px; overflow-wrap: break-word; }
.brand-card-pic { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.brand-card-count {
  flex: none; font-size: 11px; font-weight: 700; color: var(--primary); background: var(--primary-soft);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap; margin-top: 2px;
}
.brand-card-contact {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted);
}
.brand-card-contact span { display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }

.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--text); }
.list-row-title { font-weight: 700; font-size: 14.5px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; letter-spacing: .01em;
}
select.status-select {
  width: auto; max-width: 165px; border: none; border-radius: 999px; padding: 5px 10px 5px 12px; font-size: 12px;
  font-weight: 700; color: #fff; cursor: pointer; text-align: center; text-align-last: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.12); transition: filter .15s;
}
select.status-select:hover { filter: brightness(.95); }
select.status-select.sm { font-size: 11.5px; padding: 3px 8px 3px 10px; max-width: 145px; }

.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-state .empty-icon { font-size: 34px; margin-bottom: 10px; opacity: .5; }
.empty-state p { margin-bottom: 16px; }

/* These are used both inside real <form> elements and in read-only views
   (e.g. the project detail deadlines block), so they're deliberately not
   scoped to "form ..." — that scoping was the cause of labels/hints/values
   silently falling back to the browser's unstyled 16px default outside of
   forms, ending up larger than headers and section titles around them. */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.field-value { font-size: 14.5px; color: var(--text); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password],
input[type=datetime-local], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 15px; background: #fff; color: var(--text); font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; min-height: 90px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* ---------- Spreadsheet / data table ---------- */
.table-wrap {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow-x: auto; box-shadow: var(--shadow-sm); margin-bottom: 16px; -webkit-overflow-scrolling: touch;
}
table.data-table { width: 100%; border-collapse: collapse; min-width: 860px; }
table.data-table th, table.data-table td { text-align: left; padding: 11px 14px; font-size: 13.5px; white-space: nowrap; }
table.data-table thead th {
  color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  background: #fafbfc; border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
table.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
table.data-table tbody tr:last-child { border-bottom: none; }
table.data-table tbody tr:hover { background: #fafbfe; }
table.data-table td.title-cell { white-space: normal; max-width: 260px; }
table.data-table td.title-cell a { font-weight: 700; color: var(--text); }
table.data-table td.title-cell a:hover { color: var(--primary); }
table.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data-table td.muted-cell { color: var(--muted); }

/* Column visibility toggle: table carries data-hide="key1 key2" and each
   toggleable th/td carries data-col="key" — hide with an attribute selector
   so no per-row JS work is needed when the user flips a checkbox. */
table.data-table[data-hide~="brand"] [data-col="brand"] { display: none; }
table.data-table[data-hide~="status"] [data-col="status"] { display: none; }
table.data-table[data-hide~="items"] [data-col="items"] { display: none; }
table.data-table[data-hide~="total"] [data-col="total"] { display: none; }
table.data-table[data-hide~="draft"] [data-col="draft"] { display: none; }
table.data-table[data-hide~="posting"] [data-col="posting"] { display: none; }

/* Keep the Project column visible while scrolling horizontally on small screens */
table.data-table th[data-col="project"], table.data-table td[data-col="project"] {
  position: sticky; left: 0; background: var(--card); z-index: 2;
}
table.data-table thead th[data-col="project"] { z-index: 3; background: #fafbfc; }
table.data-table tbody tr:hover td[data-col="project"] { background: #fafbfe; }

.col-toggle { position: relative; }
.col-toggle > summary { list-style: none; }
.col-toggle > summary::-webkit-details-marker { display: none; }
.col-toggle-panel {
  position: absolute; top: calc(100% + 6px); right: 0; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px;
  box-shadow: var(--shadow-md); z-index: 25; display: flex; flex-direction: column; gap: 8px;
  min-width: 175px;
}
.col-toggle-panel .col-toggle-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: 2px;
}
.col-toggle-panel label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; font-weight: 500; }
.col-toggle-panel input { width: auto; margin: 0; }

@media (max-width: 640px) {
  table.data-table th, table.data-table td { padding: 10px; font-size: 13px; }
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }

.item-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 12px; background: #fbfbfd; transition: border-color .15s; }
.item-card:focus-within { border-color: var(--border-strong); }
.item-card .item-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.item-card .item-price { font-weight: 700; white-space: nowrap; }
.storyline-box { position: relative; }
.storyline-box label { display: flex; justify-content: space-between; align-items: center; }
.storyline-status { font-size: 11.5px; color: var(--success); font-weight: 600; }
.storyline-expand-btn, .storyline-history-btn {
  background: none; border: 1px solid var(--border-strong); border-radius: 6px; color: var(--muted);
  cursor: pointer; font-size: 12px; font-weight: 600; padding: 3px 8px; line-height: 1.4; transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.storyline-expand-btn:hover, .storyline-history-btn:hover { color: var(--primary); border-color: var(--primary); }

.storyline-history-modal {
  display: none; position: fixed; inset: 0; z-index: 110; background: rgba(20, 24, 31, .45);
  align-items: center; justify-content: center; padding: 20px;
}
.storyline-history-modal.active { display: flex; }
.storyline-history-panel {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 540px; max-height: 82vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-md); overflow: hidden;
}
.storyline-history-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px 10px; font-weight: 700; font-size: 15px;
}
.storyline-history-list { overflow-y: auto; padding: 0 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.storyline-history-row {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: #fbfbfd;
}
.storyline-history-meta { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.storyline-history-preview { font-size: 13.5px; color: var(--text); line-height: 1.5; white-space: pre-wrap; margin-bottom: 10px; }

.storyline-fullscreen {
  display: none; position: fixed; inset: 0; z-index: 100; background: #fff;
  flex-direction: column;
}
.storyline-fullscreen.active { display: flex; }
.storyline-fullscreen-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.storyline-fullscreen-bar .storyline-fullscreen-title { font-weight: 700; font-size: 14.5px; }
.storyline-fullscreen-status { font-size: 12px; font-weight: 600; color: var(--success); margin-left: 6px; }
.storyline-fullscreen textarea {
  flex: 1; border: none; border-radius: 0; padding: 22px; font-size: 16px; line-height: 1.6;
  resize: none; min-height: 0;
}
.storyline-fullscreen textarea:focus { box-shadow: none; }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.alert-success { background: var(--success-soft); color: #166534; border-color: #bbf7d0; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #eef0fe 0%, #f2f4f7 55%); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 18px; padding: 32px 28px; border: 1px solid var(--border); box-shadow: var(--shadow-md); }
.login-card .login-logo { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, var(--primary), #818cf8); margin: 0 auto 16px; }
.login-card h1 { text-align: center; font-size: 19px; margin-bottom: 22px; }

.color-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.1); }

.section-title { font-size: 15.5px; font-weight: 700; margin: 26px 0 10px; }
.section-title:first-child { margin-top: 0; }

.summary-line { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; }
.summary-line.total { font-weight: 700; font-size: 16.5px; border-top: 1px solid var(--border); padding-top: 11px; margin-top: 6px; }

.tag-muted { font-size: 12px; color: var(--muted); }
.text-danger { color: var(--danger); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-size: 14px; color: var(--muted); font-weight: 600; white-space: nowrap; transition: color .15s; }
.tabs a.active { color: var(--primary); border-bottom: 2px solid var(--primary); }
.tabs a:hover { color: var(--primary); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.stat-box .stat-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; margin-bottom: 4px; }
.stat-box .stat-value { font-size: 19px; font-weight: 800; }
