/* aivideo dashboard — fintech-admin-style skin on top of Pico.css reset.
   Plain CSS, no build step. Mobile breakpoints: 900px (sidebar -> drawer),
   700px (widget grid -> single column). Verified against a 375px viewport
   (iPhone SE class) — no fixed widths wider than that, everything flexes
   or wraps. */

:root {
  --grey-bg: #eef0f4;
  --card-bg: #ffffff;
  --shell-bg: #fbfbfd;
  --border-soft: #eef0f4;
  --shadow-card: 0 10px 30px -14px rgba(15, 23, 42, 0.18), 0 2px 8px -2px rgba(15, 23, 42, 0.08);
  --shadow-shell: 0 20px 60px -24px rgba(15, 23, 42, 0.25);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --text-main: #0f172a;
  --text-muted: #6b7280;
  --accent-grad: linear-gradient(135deg, #4f6df5 0%, #8b5cf6 55%, #c026d3 100%);
  --accent: #4f46e5;
  --accent-soft: #eef0fe;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }

html, body {
  background: var(--grey-bg);
  color: var(--text-main);
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

a { color: inherit; }

.app-shell {
  display: flex;
  align-items: stretch;
  max-width: 1360px;
  margin: 20px auto;
  min-height: calc(100vh - 40px);
  background: var(--shell-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-shell);
  overflow: hidden;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #ffffff;
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 26px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.logo .logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-grad);
  flex-shrink: 0;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.94rem;
}

.nav-item a:hover { background: #f5f6fa; }

.nav-item a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.nav-item svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 999px;
  padding: 3px 7px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-footer .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.sidebar-footer .who { min-width: 0; }
.sidebar-footer .who strong { display: block; font-size: 0.88rem; }
.sidebar-footer .who a { font-size: 0.78rem; color: var(--text-muted); text-decoration: none; }

/* ---------- Main column ---------- */

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.search-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f2f6;
  border-radius: 999px;
  padding: 9px 16px;
  flex: 1 1 220px;
  max-width: 320px;
  min-width: 0;
}

.search-pill svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }

.search-pill input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.88rem;
  width: 100%;
  min-width: 0;
  color: var(--text-main);
}

.menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border-soft);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- Cards / widget grid ---------- */

.widget-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 20px;
  min-width: 0;
}

.card h3, .card h2 {
  margin-top: 0;
}

.card-hero {
  grid-column: span 2;
  background: var(--accent-grad);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.card-hero .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  opacity: 0.85;
}

.card-hero .big-number {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  word-break: break-word;
}

.card-hero .caption { font-size: 0.82rem; opacity: 0.9; }

.card-hero .chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

.card-hero .chip {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 0.72rem;
  font-weight: 600;
}

.card-ring {
  grid-column: span 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.card-ring .label { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; }

.ring {
  --pct: 0;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), #eceef3 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.ring::before {
  content: "";
  position: absolute;
  inset: 11px;
  background: #fff;
  border-radius: 50%;
}

.ring .ring-value {
  position: relative;
  z-index: 1;
  font-weight: 800;
  font-size: 1.15rem;
  padding: 0 8px;
}

.tag-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.tag {
  background: #f1f2f6;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 600;
}

.card-spend {
  grid-column: span 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-spend .big-number {
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  font-weight: 800;
}

.card-spend .delta { font-size: 0.78rem; color: var(--green); font-weight: 600; }
.card-spend .delta.flat { color: var(--text-muted); }

.sparkline { width: 100%; height: 48px; display: block; }

.spend-days {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  color: var(--text-muted);
  padding: 10px 0 4px;
}

.empty-state svg { width: 28px; height: 28px; opacity: 0.5; }
.empty-state .empty-title { font-weight: 700; color: var(--text-main); font-size: 0.86rem; }
.empty-state .empty-sub { font-size: 0.76rem; }

.card-table { grid-column: span 4; }

.card-table .card-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-table .card-table-head h3 { margin: 0; font-size: 1rem; }
.card-table .see-all { font-size: 0.82rem; font-weight: 600; color: var(--accent); text-decoration: none; }

.row-list { display: flex; flex-direction: column; }

.row-item {
  display: grid;
  grid-template-columns: 32px 1fr auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 11px 6px;
  border-radius: var(--radius-sm);
}

.row-item:hover { background: #f8f9fb; }

.row-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.row-name { min-width: 0; }
.row-name .primary { font-weight: 600; font-size: 0.9rem; }
.row-name .secondary { font-size: 0.76rem; color: var(--text-muted); }

.row-date { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.row-amount { font-size: 0.86rem; font-weight: 700; white-space: nowrap; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

.status-success { background: #eafaf0; color: var(--green); }
.status-success .dot { background: var(--green); }
.status-failed { background: #fdecec; color: var(--red); }
.status-failed .dot { background: var(--red); }
.status-pending { background: #fff7e6; color: var(--amber); }
.status-pending .dot { background: var(--amber); }

/* generic section cards below the widget grid */

.section-card { margin-bottom: 20px; }
.section-card .card-table-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section-card h2 { font-size: 1.05rem; margin: 0 0 4px; }

.plain-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.plain-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
}
.plain-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.plain-table tr:hover td { background: #f8f9fb; }
.plain-table .cost { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--text-muted); }

.stat-pair { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-pair .card { flex: 1 1 220px; }
.stat-pair .stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.stat-pair .stat-value { font-size: 1.5rem; font-weight: 800; }

/* ---------- Mobile drawer ---------- */

#nav-toggle { display: none; }

@media (max-width: 900px) {
  .app-shell {
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
    max-width: none;
  }

  .menu-toggle { display: flex; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-shell);
    width: min(80vw, 280px);
    flex-basis: auto;
  }

  #nav-toggle:checked ~ .sidebar {
    transform: translateX(0);
  }

  .nav-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 40;
  }

  #nav-toggle:checked ~ .nav-scrim { display: block; }

  .main { padding: 18px 16px 40px; }
}

@media (max-width: 700px) {
  .widget-grid { grid-template-columns: 1fr; }
  .card-hero, .card-ring, .card-spend, .card-table { grid-column: span 1; }
  .topbar { gap: 10px; }
  .search-pill { max-width: none; flex-basis: 100%; order: 3; }
  .row-item {
    grid-template-columns: 28px 1fr auto;
    row-gap: 4px;
  }
  .row-date { display: none; }
  .plain-table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 420px) {
  .sidebar-footer .who a { display: none; }
}
