:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1f2430;
  --text-muted: #6b7280;
  --accent: #3d5af1;
  --accent-soft: #e8ecfe;
  --danger: #e5484d;
  --success: #19a96b;
  --warning: #f5a623;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  flex-shrink: 0;
}

.sidebar .brand {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  padding: 0 8px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.sidebar nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}

.sidebar nav a:hover { background: var(--bg); }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.sidebar .user-box {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar .logout-btn {
  margin-top: 8px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
}

.main {
  flex: 1;
  padding: 24px 28px;
  min-width: 0;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.stat-card .label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 700; }
.stat-card .value.danger { color: var(--danger); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th { color: var(--text-muted); font-weight: 600; background: var(--bg); }

tbody tr:hover { background: var(--bg); }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-ghost { background: var(--panel); border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: #fff; border: 1px solid var(--danger); color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.warn { background: #fdecea; color: var(--danger); }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,22,30,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}

.modal {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 22px;
  width: 480px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
}

.modal h3 { margin: 0 0 14px; font-size: 16px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.error-text { color: var(--danger); font-size: 13px; margin: 8px 0 0; }

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 360px;
  max-width: 90vw;
}

.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p.sub { font-size: 13px; color: var(--text-muted); margin: 0 0 22px; }

.chart-row { display: flex; align-items: flex-end; gap: 10px; height: 160px; }
.chart-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart-bar { width: 100%; max-width: 46px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.chart-bar-label { font-size: 11px; color: var(--text-muted); margin-top: 6px; text-align: center; }
.chart-bar-value { font-size: 11px; font-weight: 700; margin-bottom: 4px; }
