/*
  App shell dashboard template. MIT licensed.
  CSS grid layout, custom properties, system fonts, no external dependencies.
  Sidebar collapses under 820px.
*/
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --sidebar-bg: #0f172a;
  --sidebar-ink: #cbd5e1;
  --sidebar-active: #1e293b;
  --ok: #15803d;
  --wait: #b45309;
  --off: #64748b;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  z-index: 20;
}

.skip-link:focus {
  left: 0.5rem;
}

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar content";
  min-height: 100vh;
}

.sidebar {
  grid-area: sidebar;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  padding: 1.25rem 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 1.5rem;
  padding: 0 0.25rem;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.nav-list a {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--sidebar-ink);
  text-decoration: none;
  font-size: 0.95rem;
}

.nav-list a:hover {
  background: var(--sidebar-active);
  color: #fff;
}

.nav-list a[aria-current="page"] {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
}

.topbar-title {
  font-size: 1.15rem;
  margin: 0;
  flex: 1;
}

.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
}

.menu-btn span,
.menu-btn span::before,
.menu-btn span::after {
  content: "";
  position: absolute;
  left: 9px;
  width: 20px;
  height: 2px;
  background: var(--ink);
}

.menu-btn span { top: 19px; }
.menu-btn span::before { top: -6px; }
.menu-btn span::after { top: 6px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.search input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font: inherit;
  background: var(--bg);
  min-width: 0;
  width: 180px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
}

.content {
  grid-area: content;
  padding: 1.75rem 1.5rem;
  display: grid;
  gap: 1.5rem;
  align-content: start;
}

.stats {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-label {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-value {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  font-weight: 700;
}

.stat-trend {
  margin: 0;
  font-size: 0.85rem;
}

.stat-trend.up { color: var(--ok); }
.stat-trend.down { color: var(--wait); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.panel-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

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

thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: none;
}

.pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.pill-ok { background: #dcfce7; color: var(--ok); }
.pill-wait { background: #fef3c7; color: var(--wait); }
.pill-off { background: #e2e8f0; color: var(--off); }

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "content";
  }
  .sidebar {
    display: none;
  }
  .menu-btn {
    display: block;
  }
}
