/* twekes admin · paper/clay design system
   Matches mobile palette so the brand reads consistently across surfaces. */

:root {
  --paper:        #F5EFE3;
  --cream:        #FAF6EC;
  --sand:         #EBE0CB;
  --ink:          #1A1614;
  --ink2:         #3A332C;
  --muted:        #7A7066;
  --line:         #D8CFBE;
  --line-strong:  #BDB29B;
  --clay:         #D14A1F;
  --clay2:        #A83712;
  --clay-soft:    rgba(209,74,31,0.12);
  --sea:          #2A5F8B;
  --olive:        #6B7A3F;
  --gold:         #C8901F;

  --font-display: 'Instrument Serif', serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

/* The `hidden` HTML attribute means display:none, but a stylesheet rule
   like `display: flex` on the SAME element overrides it because of
   specificity. We override the override here so `hidden` is respected
   on .login, .app, and .modal-host regardless of their display value. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  height: 100%;
}

body { min-height: 100vh; }

button { font-family: inherit; cursor: pointer; }
a { color: var(--clay); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Login screen ────────────────────────────────────────── */
.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(800px 600px at 100% 0%, rgba(209,74,31,0.08), transparent 50%),
    radial-gradient(800px 600px at 0% 100%, rgba(42,95,139,0.08), transparent 50%),
    var(--paper);
}
.login-card {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 30px 80px rgba(26,22,20,0.06);
}
.brand {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -1px;
  color: var(--ink);
}
.brand-dot { color: var(--clay); }
.kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 14px;
}
.login-h1 {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 56px;
  line-height: 1;
  letter-spacing: -2px;
  color: var(--ink);
  margin: 6px 0 0;
}
.dot { color: var(--clay); }
.login-tagline {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink2);
  line-height: 1.5;
  margin: 14px 0 26px;
  max-width: 360px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1.4px;
  text-transform: uppercase;
  font-weight: 600;
}
.field input, .field select, .field textarea {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--clay);
  box-shadow: 0 0 0 3px var(--clay-soft);
}
.btn-primary {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  height: 46px;
  border-radius: 100px;
  background: var(--clay);
  color: var(--paper);
  border: 0;
  margin-top: 8px;
}
.btn-primary:hover { background: var(--clay2); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  height: 38px;
  padding: 0 16px;
  border-radius: 100px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-secondary:hover { background: var(--cream); }
.btn-ghost {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 0;
}
.btn-ghost:hover { color: var(--clay); }
.btn-danger {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  height: 38px;
  padding: 0 14px;
  border-radius: 100px;
  background: transparent;
  border: 1px solid var(--clay);
  color: var(--clay);
}
.btn-danger:hover { background: var(--clay-soft); }
.login-error {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--clay);
  background: var(--clay-soft);
  padding: 10px 12px;
  border-radius: 10px;
  margin: 0;
}
.login-help {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
  text-align: center;
}

/* ─── App shell ────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--cream);
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 26px;
  letter-spacing: -1px;
  line-height: 1;
}
.sidebar-kicker {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 4px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  background: transparent;
  border: 0;
  text-align: left;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 500;
}
.nav-item:hover { background: var(--paper); }
.nav-item.active {
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.sidebar-user {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.3px;
  padding: 8px 10px;
  background: var(--paper);
  border-radius: 10px;
  border: 1px solid var(--line);
  word-break: break-all;
}

/* ─── Main column ─────────────────────────────────────────── */
.main { display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  background: rgba(245,239,227,0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 2;
}
.topbar-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 28px;
  letter-spacing: -1px;
  margin: 0;
  line-height: 1;
}
.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--clay2);
  background: var(--clay-soft);
  padding: 5px 10px;
  border-radius: 100px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.content { padding: 26px 28px 60px; }

/* ─── Stat tiles (dashboard) ──────────────────────────────── */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.tile {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}
.tile-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 700;
}
.tile-value {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 40px;
  letter-spacing: -1.5px;
  color: var(--ink);
  line-height: 1;
  margin-top: 6px;
}
.tile-value.warn  { color: var(--clay); }
.tile-value.ok    { color: var(--olive); }
.tile-section {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  letter-spacing: -0.6px;
  margin: 30px 0 14px;
}

/* ─── Toolbar (above tables) ──────────────────────────────── */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar input[type="search"] {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--cream);
  color: var(--ink);
  outline: none;
  min-width: 220px;
}
.toolbar input[type="search"]:focus {
  border-color: var(--clay);
}
.toolbar select {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--cream);
}
.spacer { flex: 1; }

/* ─── Table ───────────────────────────────────────────────── */
.table-wrap {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 12px 14px;
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}
tbody tr:hover { background: rgba(209,74,31,0.04); }
.cell-mono { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.cell-strong { font-weight: 600; color: var(--ink); }
.cell-truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-actions { white-space: nowrap; }
.cell-actions button {
  margin-left: 6px;
  font-size: 12px;
}

.pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--sand);
  color: var(--ink);
}
.pill.clay  { background: var(--clay-soft); color: var(--clay2); }
.pill.olive { background: rgba(107,122,63,0.16); color: var(--olive); }
.pill.gold  { background: rgba(200,144,31,0.16); color: var(--gold); }
.pill.sea   { background: rgba(42,95,139,0.16); color: var(--sea); }
.pill.muted { background: rgba(122,112,102,0.15); color: var(--muted); }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 14px;
}

/* ─── Forms (modal + inline) ───────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.form-grid .field.col2 { grid-column: span 2; }
.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}
textarea.field-textarea {
  min-height: 80px;
  resize: vertical;
}
.field-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.3px;
  margin-top: 4px;
}

/* ─── Modal ────────────────────────────────────────────────── */
.modal-host {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26,22,20,0.55);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  background: var(--cream);
  border-radius: 18px;
  border: 1px solid var(--line);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  letter-spacing: -0.6px;
}
.modal-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 20px;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
}

/* ─── Toasts ──────────────────────────────────────────────── */
.toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  box-shadow: 0 12px 30px rgba(26,22,20,0.18);
  max-width: 360px;
  animation: toastIn 0.18s ease-out;
}
.toast.success { background: var(--olive); }
.toast.error   { background: var(--clay); }
@keyframes toastIn {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ─── Mobile responsive ───────────────────────────────────── */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-foot { flex-direction: row; align-items: center; }
  .sidebar-user { flex: 1; }
}
