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

:root {
  --bg: #faf9f7;
  --fg: #1a1814;
  --card: #ffffff;
  --border: #e8e4de;
  --muted: #f0ece6;
  --muted-fg: #6b6560;
  --accent: #2d6a4f;
  --accent-fg: #ffffff;
  --accent-light: #f0fdf4;
  --accent-border: #86efac;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── layout ── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

.sidebar-logo { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.sidebar-group { font-size: 12px; color: var(--muted-fg); margin-bottom: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--fg);
  transition: background 0.1s;
}
.nav a:hover, .nav a.active { background: var(--muted); }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.sidebar-user { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.sidebar-role { font-size: 12px; color: var(--muted-fg); margin-bottom: 10px; }

.main-content {
  margin-left: 220px;
  flex: 1;
  padding: 32px 40px;
  max-width: 1000px;
}

/* ── cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card + .card { margin-top: 16px; }

/* ── badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f3f4f6; color: #374151; }
.badge-blue   { background: #dbeafe; color: #1e40af; }

/* ── buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.1s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: var(--accent-fg); }
.btn-ghost    { background: var(--muted); color: var(--fg); }
.btn-danger   { background: var(--danger-bg); color: var(--danger); }
.btn-sm       { padding: 5px 12px; font-size: 13px; }

/* ── forms ── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted-fg); text-transform: uppercase; letter-spacing: 0.05em; }
.input, .select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--muted);
  font-size: 14px;
  color: var(--fg);
  outline: none;
  transition: border-color 0.15s;
}
.input:focus, .select:focus { border-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }

/* ── tables ── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted-fg); padding-bottom: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
td { padding: 12px 0; border-top: 1px solid var(--border); vertical-align: middle; }
tr:first-child td { border-top: none; }

/* ── stat tiles ── */
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 20px; }
.stat-tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-tile.warn { border-color: var(--warn); background: var(--warn-bg); }
.stat-label { font-size: 12px; color: var(--muted-fg); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-tile.warn .stat-value { color: var(--warn); }

/* ── summary banner ── */
.summary-banner {
  background: var(--muted);
  border-radius: var(--radius);
  padding: 18px 22px;
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 20px;
}

/* ── progress bar ── */
.progress-bar { background: var(--border); border-radius: 99px; height: 6px; overflow: hidden; margin-top: 8px; }
.progress-fill { background: var(--accent); height: 100%; border-radius: 99px; transition: width 0.3s; }

/* ── auth pages ── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-box { width: 100%; max-width: 420px; padding: 16px; }
.auth-logo { font-size: 20px; font-weight: 700; margin-bottom: 28px; display: block; }
.auth-box .card { padding: 32px; }

/* ── landing ── */
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 20px 40px; max-width: 1100px; margin: 0 auto; }
.landing-hero { max-width: 700px; margin: 60px auto 0; padding: 0 40px; }
.landing-hero h1 { font-size: clamp(36px, 5vw, 56px); font-weight: 800; line-height: 1.1; margin-bottom: 20px; letter-spacing: -0.02em; }
.landing-hero p { font-size: 17px; color: var(--muted-fg); line-height: 1.7; margin-bottom: 12px; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 32px 0 72px; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; max-width: 1000px; margin: 0 auto; padding: 0 40px 80px; }
.feature-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.feature-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.feature-card p { font-size: 13px; color: var(--muted-fg); line-height: 1.6; }
.legal-note { text-align: center; font-size: 12px; color: var(--muted-fg); padding: 24px 40px 48px; }

/* ── chat ── */
.chat-wrap { max-width: 680px; }
.chat-messages { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; min-height: 200px; }
.msg { padding: 14px 18px; border-radius: var(--radius); font-size: 14px; line-height: 1.6; max-width: 86%; }
.msg-user { background: var(--accent); color: var(--accent-fg); align-self: flex-end; }
.msg-ai { background: var(--card); border: 1px solid var(--border); align-self: flex-start; }
.chat-input-row { display: flex; gap: 10px; }
.chat-input-row input { flex: 1; }
.quick-qs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.quick-q { background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 7px 16px; font-size: 13px; cursor: pointer; transition: background 0.1s; }
.quick-q:hover { background: var(--muted); }

/* ── upload zone ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  font-size: 14px;
  color: var(--muted-fg);
  cursor: pointer;
  transition: border-color 0.15s;
}
.upload-zone:hover { border-color: var(--accent); }

/* ── alerts ── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.alert-err { background: var(--danger-bg); color: var(--danger); }
.alert-ok  { background: #d1fae5; color: #065f46; }
.alert-warn { background: var(--warn-bg); color: var(--warn); }

/* ── misc ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--muted-fg); }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.hidden { display: none !important; }

/* ── responsive ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 20px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .landing-hero, .landing-nav, .features-grid, .legal-note { padding-left: 20px; padding-right: 20px; }
}
