/* ============================================================
   TF ADMIN — dashboard styles (mirrors marketing site palette)
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--f-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 4px; }

body[data-view="loading"] #view-auth,
body[data-view="loading"] #view-app,
body[data-view="auth"]    #view-app,
body[data-view="auth"]    #view-loading,
body[data-view="app"]     #view-auth,
body[data-view="app"]     #view-loading { display: none; }

/* ---------- LOADING ---------- */
#view-loading {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
}
.boot-logo img {
  height: 64px; opacity: .9;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* ---------- AUTH ---------- */
#view-auth {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(800px 600px at 70% 30%, rgba(215,35,39,.14), transparent 60%),
    linear-gradient(135deg, #0A0A0C, #131418 60%, #1A0608);
  padding: 40px 20px;
}
.auth-card {
  width: 100%; max-width: 460px;
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 44px 40px 40px;
  backdrop-filter: blur(20px);
}
.auth-logo img { height: 44px; margin-bottom: 28px; }
.auth-card .eyebrow {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  display: flex; align-items: center; gap: 12px;
}
.auth-card .eyebrow::before {
  content: ''; width: 22px; height: 1px; background: var(--red);
}
.auth-card h1 {
  font-family: var(--f-display); font-size: 40px; font-weight: 700;
  letter-spacing: -.02em; margin: 14px 0 14px;
}
.auth-sub { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
#auth-form { display: flex; flex-direction: column; gap: 14px; }
#auth-form label { font-family: var(--f-mono); font-size: 11px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted); font-weight: 500; }
#auth-form input {
  padding: 14px 18px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  color: var(--fg); font-family: var(--f-body); font-size: 15px;
}
#auth-form input:focus { outline: none; border-color: var(--red); background: rgba(255,255,255,.06); }
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 24px;
  font-family: var(--f-body); font-weight: 500; font-size: 14px;
  border-radius: var(--r-pill); cursor: pointer;
  transition: background 200ms var(--ease), color 200ms var(--ease), transform 200ms var(--ease), border-color 200ms var(--ease);
}
.btn-primary { background: var(--red); color: var(--white); }
.btn-primary:hover { background: var(--red-dim); }
.btn-arrow::after { content: '→'; transition: transform 200ms var(--ease); }
.btn-arrow:hover::after { transform: translateX(4px); }
.btn-ghost { border: 1px solid var(--rule-strong); color: var(--fg); padding: 10px 18px; font-size: 13px; }
.btn-ghost:hover { background: var(--fg); color: var(--bg); }
.btn-sm { padding: 8px 14px; font-size: 12px; }
.btn-danger { background: rgba(215,35,39,.12); color: var(--red); border: 1px solid rgba(215,35,39,.3); padding: 10px 18px; font-size: 13px; }
.btn-danger:hover { background: var(--red); color: var(--white); }

.auth-hint { margin-top: 24px; font-family: var(--f-mono); font-size: 11px; color: var(--muted); }
.auth-hint code { background: rgba(255,255,255,.04); padding: 3px 8px; border-radius: 4px; }
.auth-demo { margin-top: 14px; font-family: var(--f-mono); font-size: 10px; color: var(--red); letter-spacing: .12em; }

/* ---------- APP LAYOUT ---------- */
#view-app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  background: #08080A;
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column;
  padding: 24px 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sb-logo {
  padding: 0 28px 24px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 18px;
}
.sb-logo img { height: 36px; }

.sb-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 0 16px; }
.sb-group-label {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted);
  padding: 18px 14px 8px; font-weight: 500;
}
.sb-item {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  color: var(--muted); font-size: 14px;
  cursor: pointer;
  transition: background 180ms var(--ease), color 180ms var(--ease);
  position: relative;
  width: 100%; text-align: left;
}
.sb-item:hover { background: rgba(255,255,255,.04); color: var(--fg); }
.sb-item.active {
  background: var(--red-soft);
  color: var(--fg);
}
.sb-item.active::before {
  content: ''; position: absolute; left: -16px; top: 6px; bottom: 6px;
  width: 3px; background: var(--red); border-radius: 0 2px 2px 0;
}
.sb-item .icon {
  width: 18px; height: 18px;
  display: grid; place-items: center; opacity: .9;
  flex-shrink: 0;
}
.sb-item .icon svg { width: 100%; height: 100%; }
.sb-item .badge {
  margin-left: auto;
  background: var(--red); color: var(--white);
  font-family: var(--f-mono); font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 999px;
  min-width: 20px; text-align: center;
}

.sb-foot {
  padding: 16px 16px 0;
  border-top: 1px solid var(--rule);
  margin: 20px 16px 0;
}
.sb-user { display: flex; align-items: center; gap: 12px; padding: 8px 4px; }
.sb-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--red); color: var(--white);
  display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.sb-user-name { font-size: 13px; font-weight: 500; }
.sb-user-role { font-family: var(--f-mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); }
.sb-signout {
  display: block; width: 100%;
  padding: 10px 14px; margin-top: 12px;
  border-radius: var(--r-md);
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted);
  text-align: left;
  transition: color 180ms var(--ease), background 180ms var(--ease);
}
.sb-signout:hover { color: var(--red); background: rgba(255,255,255,.03); }

/* ---------- MAIN ---------- */
.main { padding: 28px 36px 60px; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: end;
  padding-bottom: 28px; margin-bottom: 32px;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap; gap: 16px;
}
.topbar-eyebrow {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted); font-weight: 500; margin-bottom: 8px;
}
.topbar h1 {
  font-family: var(--f-display); font-size: clamp(28px, 3vw, 38px);
  font-weight: 700; letter-spacing: -.02em; margin: 0;
}
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- PANE COMMONS ---------- */
.pane { min-height: 300px; }

/* KPI cards */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 36px;
}
.kpi {
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 24px 24px 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.025), transparent);
}
.kpi .k {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
}
.kpi .v {
  font-family: var(--f-display); font-size: 36px;
  font-weight: 700; letter-spacing: -.02em;
  color: var(--fg); margin: 8px 0 4px; line-height: 1.05;
}
.kpi .d { font-family: var(--f-mono); font-size: 11px; color: var(--muted); font-weight: 500; }
.kpi .d.up   { color: #4ADE80; }
.kpi .d.down { color: var(--red); }
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

/* Filter bar */
.filter-bar {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px; padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
  align-items: center;
}
.filter-bar .search {
  flex: 1; min-width: 240px;
  padding: 10px 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  color: var(--fg); font-size: 13px;
}
.filter-bar .search:focus { outline: none; border-color: var(--red); }
.filter-bar select {
  padding: 10px 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  color: var(--fg); font-size: 13px; font-family: var(--f-body);
}
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .12em;
  padding: 7px 12px;
  border: 1px solid var(--rule); border-radius: var(--r-pill);
  color: var(--muted); cursor: pointer;
  transition: all 180ms var(--ease);
  text-transform: uppercase; font-weight: 500;
}
.chip:hover { color: var(--fg); border-color: var(--rule-strong); }
.chip.active { background: var(--red-soft); color: var(--red); border-color: var(--red); }

/* Tables */
.table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.table thead th {
  text-align: left; font-family: var(--f-mono); font-size: 10px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
  padding: 14px 18px;
  background: rgba(255,255,255,.025);
  border-bottom: 1px solid var(--rule);
  font-weight: 500;
}
.table tbody td {
  padding: 16px 18px; font-size: 14px;
  border-bottom: 1px solid var(--rule);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 120ms var(--ease); cursor: pointer; }
.table tbody tr:hover { background: rgba(255,255,255,.025); }
.table .muted { color: var(--muted); }
.table .num { font-family: var(--f-mono); }

/* Status badges */
.badge {
  display: inline-block;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; font-weight: 500;
  padding: 4px 10px; border-radius: var(--r-pill);
  border: 1px solid currentColor;
}
.badge.green  { color: #4ADE80; background: rgba(74,222,128,.08); }
.badge.amber  { color: #F59E0B; background: rgba(245,158,11,.08); }
.badge.red    { color: var(--red); background: var(--red-soft); }
.badge.blue   { color: #60A5FA; background: rgba(96,165,250,.08); }
.badge.gray   { color: var(--muted); background: rgba(255,255,255,.04); }

/* Cards / grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1080px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.card {
  border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,.025), transparent);
}
.card h3 { font-family: var(--f-display); font-weight: 600; font-size: 18px;
  letter-spacing: -.01em; margin: 0 0 16px; }

/* Empty state */
.empty {
  padding: 60px 24px; text-align: center;
  border: 1px dashed var(--rule);
  border-radius: var(--r-lg);
  color: var(--muted); font-size: 14px;
}

/* Detail panel (modal) */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(8px);
  display: grid; place-items: center;
  padding: 24px;
  animation: modalFade .25s var(--ease);
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #131418;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-lg);
  width: 100%; max-width: 720px;
  max-height: 84vh; overflow-y: auto;
  padding: 32px;
}
.modal h2 { font-family: var(--f-display); font-weight: 600; font-size: 24px;
  letter-spacing: -.01em; margin: 0 0 8px; }
.modal-sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.modal-row { display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--rule); }
.modal-row:last-child { border-bottom: 0; }
.modal-row .k { font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); font-weight: 500; }
.modal-row .v { color: var(--fg); text-align: right; font-size: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

/* Posts editor */
.posts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 980px) { .posts-grid { grid-template-columns: 1fr; } }
.post {
  border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 20px; cursor: pointer;
  transition: border-color 180ms var(--ease), transform 180ms var(--ease);
}
.post:hover { border-color: var(--red); transform: translateY(-2px); }
.post .meta { font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 8px; font-weight: 500; }
.post h4 { font-family: var(--f-display); font-weight: 600; font-size: 16px;
  letter-spacing: -.01em; margin: 0 0 8px; line-height: 1.3; }
.post .excerpt { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* Sparkline */
.spark {
  height: 60px; margin-top: 12px;
  display: flex; align-items: end; gap: 4px;
}
.spark .bar {
  flex: 1; background: linear-gradient(180deg, var(--red), rgba(215,35,39,.3));
  border-radius: 2px 2px 0 0;
  min-height: 4px;
}

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #15171C; color: var(--fg);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-md);
  padding: 12px 20px;
  font-size: 13px; box-shadow: 0 20px 50px rgba(0,0,0,.4);
  opacity: 0; pointer-events: none;
  z-index: 200;
  transition: opacity 280ms var(--ease), transform 280ms var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Photo gallery (warranty claims) */
.photo-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin: 14px 0;
}
.photo-grid img {
  aspect-ratio: 4/3; object-fit: cover; border-radius: var(--r-md);
}

/* ---------- VIEW TOGGLE (Table / Calendar) ---------- */
.view-toggle-row {
  display: flex; gap: 16px; align-items: center;
  flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--rule);
  margin-bottom: 18px;
}
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  padding: 3px;
  background: rgba(255,255,255,.03);
}
.vt-btn {
  padding: 8px 18px;
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  border-radius: var(--r-pill);
  color: var(--muted); font-weight: 500;
  transition: all 180ms var(--ease);
}
.vt-btn:hover { color: var(--fg); }
.vt-btn.active { background: var(--red); color: var(--white); }

/* ---------- CALENDAR ---------- */
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 16px; flex-wrap: wrap;
}
.cal-month {
  font-family: var(--f-display); font-weight: 600; font-size: 22px;
  letter-spacing: -.01em; margin: 0;
}
.cal-legend {
  display: flex; gap: 18px; font-family: var(--f-mono); font-size: 10px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
  font-weight: 500; margin-bottom: 16px; flex-wrap: wrap;
}
.cal-legend span { display: inline-flex; align-items: center; gap: 8px; }
.cal-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
}
.cal-dot.c-red    { background: var(--red); }
.cal-dot.c-blue   { background: #60A5FA; }
.cal-dot.c-green  { background: #4ADE80; }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.cal-dow {
  background: var(--ink);
  padding: 10px 12px;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  text-align: center;
}
.cal-cell {
  background: var(--bg);
  min-height: 108px;
  padding: 8px 8px 6px;
  display: flex; flex-direction: column; gap: 6px;
  transition: background 180ms var(--ease);
}
.cal-cell.pad { background: rgba(255,255,255,.015); }
.cal-cell.has { background: rgba(255,255,255,.02); }
.cal-cell.today { background: rgba(215,35,39,.06); }
.cal-cell.today .cal-num { color: var(--red); font-weight: 700; }
.cal-num {
  font-family: var(--f-mono); font-size: 13px; font-weight: 500;
  color: var(--muted);
}
.cal-chips { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.cal-chip {
  display: flex; gap: 6px; align-items: center;
  padding: 4px 6px; border-radius: var(--r-sm);
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: .04em; font-weight: 500;
  cursor: pointer;
  transition: transform 120ms var(--ease), filter 120ms var(--ease);
  border: 1px solid;
  overflow: hidden;
}
.cal-chip:hover { transform: translateX(2px); filter: brightness(1.15); }
.cal-chip .cc-t { flex-shrink: 0; }
.cal-chip .cc-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip.cc-red    { background: rgba(215,35,39,.16);  border-color: rgba(215,35,39,.45); color: #FBA9AB; }
.cal-chip.cc-blue   { background: rgba(96,165,250,.14); border-color: rgba(96,165,250,.4); color: #B6D4FF; }
.cal-chip.cc-green  { background: rgba(74,222,128,.12); border-color: rgba(74,222,128,.4); color: #A7F3D0; }
.cal-chip.cc-gray   { background: rgba(255,255,255,.04); border-color: var(--rule); color: var(--muted); }
.cal-more {
  font-family: var(--f-mono); font-size: 9px; color: var(--muted);
  padding: 2px 6px; font-weight: 500;
}

@media (max-width: 980px) {
  .cal-cell { min-height: 80px; padding: 6px; }
  .cal-chip { font-size: 9px; }
  .cal-chip .cc-name { display: none; }
}

/* Responsive */
@media (max-width: 880px) {
  #view-app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .main { padding: 20px 18px 60px; }
  .table thead { display: none; }
  .table tbody td { display: block; padding: 8px 14px; border-bottom: 0; }
  .table tbody tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--rule); }
}
