:root {
  --navy:        #1a1a2e;
  --navy-dark:   #0f0f20;
  --gold:        #c9a84c;
  --gold-light:  #e8c96d;
  --surface:     rgba(255,255,255,0.07);
  --surface-2:   rgba(255,255,255,0.08);
  --text:        rgba(255,255,255,0.88);
  --text-muted:  rgba(255,255,255,0.48);
  --body-bg:     #f4f5f7;
  --card-bg:     #ffffff;
  --card-border: #e4e8ee;
  --text-dark:   #1e293b;
  --text-mid:    #64748b;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.08);
  --danger:      #dc2626;
  --success:     #16a34a;
  --warning:     #d97706;
  --radius:      10px;
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --app-primary: #0d9488; /* kitchen teal — D5 */
}

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

body {
  background: var(--body-bg);
  color: var(--text-dark);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

/* ─── App shell ─────────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.sidebar {
  grid-column: 1;
  grid-row: 1 / -1;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--surface);
}

.sidebar-nav {
  flex: 1;
  padding: 8px 8px;
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  margin-top: 4px;
}

.sidebar-section-label {
  padding: 8px 10px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover { background: var(--surface); color: var(--text); }
.sidebar-nav a.active { background: rgba(201,168,76,0.15); color: var(--gold); }

.sidebar-user {
  padding: 12px 16px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Top bar (mobile fallback) ─────────────────────────────────────────── */
.top-bar { display: none; }

.page-content {
  grid-column: 2;
  grid-row: 1 / -1;
  min-width: 0;
  padding: 24px;
  background: var(--body-bg);
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body { padding: 20px; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary  { background: var(--gold); color: var(--navy); }
.btn-primary:hover:not(:disabled) { background: var(--gold-light); }
.btn-secondary { background: var(--navy); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--navy-dark); }
.btn-outline { background: transparent; color: var(--text-dark); border: 1px solid var(--card-border); }
.btn-outline:hover:not(:disabled) { background: var(--body-bg); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { opacity: 0.85; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
input, select, textarea {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text-dark);
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-info    { background: #dbeafe; color: #2563eb; }
.badge-neutral { background: #f1f5f9; color: #64748b; }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 8px 12px; background: #f8fafc; border-bottom: 1px solid var(--card-border); font-weight: 600; color: var(--text-mid); white-space: nowrap; }
td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; color: var(--text-dark); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ─── Page header ────────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 16px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--text-dark); }
.page-subtitle { font-size: 13px; color: var(--text-mid); margin-top: 2px; }

/* ─── Sub-nav tabs ───────────────────────────────────────────────────────── */
.sub-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--card-border); margin-bottom: 24px; overflow-x: auto; }
.sub-nav-item { padding: 8px 14px; font-size: 13px; font-weight: 500; color: var(--text-mid); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; background: none; border-left: none; border-right: none; border-top: none; transition: color 0.15s, border-color 0.15s; }
.sub-nav-item:hover { color: var(--text-dark); }
.sub-nav-item.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ─── Status + spinner ───────────────────────────────────────────────────── */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.green  { background: var(--success); }
.status-dot.yellow { background: var(--warning); }
.status-dot.red    { background: var(--danger); }
.status-dot.grey   { background: #94a3b8; }

.spinner { width: 20px; height: 20px; border: 2px solid var(--card-border); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 60px 20px; color: var(--text-mid); font-size: 13px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-mid); font-size: 13px; }

/* ─── Grid helpers ───────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ─── Stat card ──────────────────────────────────────────────────────────── */
.stat-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow-sm); }
.stat-label { font-size: 12px; color: var(--text-mid); margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text-dark); }
.stat-delta { font-size: 12px; margin-top: 4px; }
.stat-delta.positive { color: var(--success); }
.stat-delta.negative { color: var(--danger); }
.stat-delta.neutral  { color: var(--text-mid); }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { display: none; }
  .top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--navy);
    padding: 0 16px;
    height: 52px;
    grid-column: 1;
    grid-row: 1;
    overflow-x: auto;
  }
  .top-bar-title { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; margin-right: 8px; }
  .top-bar-nav { display: flex; gap: 4px; }
  .top-bar-nav a { color: var(--text-muted); text-decoration: none; font-size: 12.5px; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
  .top-bar-nav a:hover { color: var(--text); background: var(--surface); }
  .top-bar-nav a.active { color: var(--gold); }
  .page-content { grid-column: 1; grid-row: 2; padding: 16px; }
}

/* ─── Sidebar scrollbar ──────────────────────────────────────────────────── */
.sidebar::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track,
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.35); border-radius: 2px; }
.sidebar::-webkit-scrollbar-thumb:hover,
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(201,168,76,0.65); }
.sidebar, .sidebar-nav { scrollbar-width: thin; scrollbar-color: rgba(201,168,76,0.35) transparent; }
