/* ==========================================================================
   Desain visual CRM Catering. Palet warna & token mengikuti pedoman data-viz
   internal (kontras cukup, warna kategorikal konsisten). Ubah nilai di :root
   kalau owner ingin ganti warna brand.
   ========================================================================== */

:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  --brand: #2a78d6;
  --brand-dark: #184f95;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgba(11,11,11,0.06), 0 1px 1px rgba(11,11,11,0.04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  font-weight: 700;
  font-size: 16px;
  padding: 4px 10px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-brand .logo-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand);
  display: inline-block;
}
.nav-group { margin-bottom: 18px; }
.nav-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); padding: 0 10px 6px; font-weight: 600;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
}
.nav-link:hover { background: var(--page); text-decoration: none; }
.nav-link.active { background: rgba(42,120,214,0.10); color: var(--brand-dark); }
.sidebar-user {
  margin-top: 20px; padding: 12px 10px; border-top: 1px solid var(--border);
}
.sidebar-user .name { font-weight: 600; font-size: 13.5px; }
.sidebar-user .role { font-size: 12px; color: var(--text-muted); text-transform: capitalize; }
.sidebar-user form { margin-top: 8px; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}
.topbar h1 { font-size: 18px; margin: 0; }
.content { padding: 24px 28px 60px; max-width: 1180px; }

/* ---------- Cards / tiles ---------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 18px 20px;
}
.card + .card { margin-top: 16px; }
.card h2, .card h3 { margin-top: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-1);
}
.stat-tile .label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-tile .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-tile .sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-primary); font-size: 13.5px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--page); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--status-critical); border-color: var(--status-critical); background: transparent; }
.btn-danger:hover { background: rgba(208,59,59,0.08); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin: 12px 0 5px; }
label:first-child { margin-top: 0; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--baseline); font-size: 14px; font-family: inherit;
  background: #fff; color: var(--text-primary);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand);
}
textarea { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--gridline);
}
td { padding: 10px 10px; border-bottom: 1px solid var(--gridline); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(11,11,11,0.015); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  color: #fff;
}
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--page), #f2efe8);
}
.login-card {
  width: 380px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-1); padding: 30px 28px;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p.sub { color: var(--text-secondary); font-size: 13.5px; margin: 0 0 20px; }
.login-hint {
  margin-top: 18px; padding: 10px 12px; background: var(--page);
  border-radius: var(--radius-sm); font-size: 12.5px; color: var(--text-secondary);
}

/* ---------- Alerts ---------- */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px;
  border: 1px solid;
}
.alert-success { background: rgba(12,163,12,0.08); border-color: rgba(12,163,12,0.3); color: #0a5c0a; }
.alert-error { background: rgba(208,59,59,0.08); border-color: rgba(208,59,59,0.3); color: #8f2323; }

/* ---------- Misc ---------- */
.muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-16 { margin-top: 16px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  padding: 10px 0; border-bottom: 1px solid var(--gridline);
  display: flex; gap: 12px; align-items: flex-start;
}
.timeline li:last-child { border-bottom: none; }
.timeline .type-chip {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  color: var(--brand-dark); background: rgba(42,120,214,0.10);
  padding: 3px 8px; border-radius: 999px; flex-shrink: 0; margin-top: 1px;
}
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.progress-bar { height: 8px; border-radius: 999px; background: var(--gridline); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; border-radius: 999px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-secondary); margin-top: 8px; }
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }

.chart-tooltip {
  position: absolute; pointer-events: none; background: var(--text-primary); color: #fff;
  font-size: 12px; padding: 6px 9px; border-radius: 6px; transform: translate(-50%, -110%);
  white-space: nowrap; z-index: 20; box-shadow: var(--shadow-1); opacity: 0; transition: opacity .08s;
}
.chart-wrap { position: relative; }

@media (max-width: 780px) {
  .sidebar { position: fixed; left: -240px; z-index: 30; transition: left .15s; box-shadow: 0 0 0 9999px rgba(0,0,0,0); }
  .sidebar.open { left: 0; box-shadow: 4px 0 24px rgba(0,0,0,0.15); }
  .content { padding: 18px 16px 60px; }
  .topbar { padding: 14px 16px; }
}
