:root {
  --bg: #f4f6fb; --panel: #fff; --ink: #1f2937; --muted: #6b7280;
  --accent: #1f4e78; --accentB: #2e8b57; --line: #e5e7eb;
  --a: #2563eb; --b: #16a34a; --warn: #dc2626;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); }

/* login */
.login-page { display: grid; place-items: center; min-height: 100vh;
  background: linear-gradient(135deg, #1f4e78, #2e8b57); }
.login-card { background: #fff; padding: 34px 30px; border-radius: 14px;
  width: 340px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.login-card label { display: block; font-size: 13px; margin-bottom: 12px; color: #374151; }
.login-card input { width: 100%; padding: 10px; margin-top: 5px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 15px; }
.login-card button { width: 100%; padding: 11px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 15px; cursor: pointer; margin-top: 6px; }
.login-card button:hover { background: #17395a; }
.error { background: #fee2e2; color: #991b1b; padding: 9px 11px; border-radius: 8px;
  font-size: 13px; margin-bottom: 14px; }

/* app shell */
.topbar { display: flex; justify-content: space-between; align-items: center;
  background: var(--accent); color: #fff; padding: 12px 22px; }
.brand { font-weight: 600; }
.userbox { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.role { padding: 2px 9px; border-radius: 999px; font-size: 12px; text-transform: uppercase; }
.role-admin { background: #fde68a; color: #78350f; }
.role-user { background: #bbf7d0; color: #14532d; }
.role-viewer { background: #e5e7eb; color: #374151; }
.logout { color: #fff; text-decoration: underline; }
main { max-width: 1180px; margin: 0 auto; padding: 20px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr));
  gap: 14px; margin-bottom: 18px; }
.card { background: var(--panel); border-radius: 12px; padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card .k { font-size: 13px; color: var(--muted); }
.card .v { font-size: 26px; font-weight: 700; margin-top: 4px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.grain-tabs { display: flex; gap: 6px; }
.grain { border: 1px solid var(--line); background: #fff; padding: 8px 16px;
  border-radius: 8px; cursor: pointer; font-size: 14px; }
.grain.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.export-btn { background: var(--accentB); color: #fff; padding: 9px 16px; border-radius: 8px;
  text-decoration: none; font-size: 14px; }
.export-btn:hover { background: #256b45; }
.export-note { color: var(--muted); font-size: 13px; }

.panel { background: var(--panel); border-radius: 12px; padding: 16px 18px; margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.panel h2 { font-size: 15px; margin: 0 0 12px; }
.chart-wrap { position: relative; height: 320px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) { .grid2 { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: #f3f4f6; position: sticky; top: 0; }
tbody tr:hover { background: #f9fafb; }
.pill { padding: 1px 8px; border-radius: 999px; font-size: 11px; }
.pill.command { background: #dbeafe; color: #1e40af; }
.pill.dedicated { background: #dcfce7; color: #166534; }
