/* SES Dashboard — clean SaaS chrome (Brevo-inspired), dataviz reference palette */

:root {
  color-scheme: light;
  --plane: #f9f9f7;          /* page plane */
  --surface: #fcfcfb;        /* card / chart surface */
  --ink: #0b0b0b;            /* primary text */
  --ink-2: #52514e;          /* secondary text */
  --muted: #898781;          /* axis / labels */
  --hairline: #e1e0d9;       /* gridline gray */
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;         /* categorical slot 1 */
  --accent-deep: #1c5cab;
  --accent-wash: #eaf2fb;
  /* status text steps, darkened for legible text on light surface */
  --ok-text: #006300;
  --warn-text: #935600;
  --bad-text: #b42323;
  --bad-wash: #fdeeee;
  --warn-wash: #fdf3dd;
  --neutral-wash: #f0efec;
}

* { box-sizing: border-box; }

/* body must be allowed to GROW with the content (min-height, never height),
   otherwise the flex-stretched sidebar stops at one viewport height. */
html { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--plane);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
}

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* The outer sidebar stretches to the full page height (flex default), so its
   background and border run to the bottom; the inner wrapper stays sticky so
   the nav remains visible while scrolling. */
.sidebar {
  width: 216px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar-inner {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sidebar .brand .logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-weight: 500;
  text-decoration: none;
}

.sidebar nav a svg { width: 16px; height: 16px; stroke: currentColor; flex-shrink: 0; }

.sidebar nav a:hover { background: var(--neutral-wash); text-decoration: none; }

.sidebar nav a.active {
  background: var(--accent-wash);
  color: var(--accent-deep);
  font-weight: 600;
}

.sidebar .foot {
  margin-top: auto;
  padding: 0 10px;
  font-size: 11px;
  color: var(--muted);
}

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

main {
  flex: 1;
  min-width: 0;
  padding: 32px 36px 72px;
  max-width: 1200px;
}

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- Filter row ---------- */

.filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filters .sep { width: 1px; height: 20px; background: var(--hairline); margin: 0 8px; }

.filters a {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
}

.filters a:hover { background: var(--neutral-wash); text-decoration: none; }

.filters a.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  font-weight: 600;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
}

.section { margin-top: 16px; }

.card-title { font-size: 14px; font-weight: 650; margin: 0; }
.card-sub { font-size: 12px; color: var(--muted); margin: 1px 0 0; }
.card-head { margin-bottom: 14px; }

/* ---------- Overview hero row ---------- */

.overview {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 0;
  overflow: hidden;
}

.overview .stat {
  padding: 20px 24px;
  border-right: 1px solid var(--hairline);
}

.overview .stat:last-child { border-right: none; }

.stat .label { font-size: 12px; color: var(--ink-2); }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }
.stat .hint { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ---------- Per-app cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.app-card .app-name {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-deep);
  background: var(--accent-wash);
  border-radius: 6px;
  padding: 2px 8px;
  margin-bottom: 14px;
}

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; }

.metric .label { color: var(--muted); font-size: 11px; letter-spacing: 0.02em; }
.metric .value { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }

.rate-ok { color: var(--ok-text); }
.rate-warn { color: var(--warn-text); }
.rate-bad { color: var(--bad-text); }

/* ---------- Charts ---------- */

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 980px) { .charts { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */

.table-card { padding: 0; overflow: hidden; }
.table-card .card-head { padding: 18px 24px 0; margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  padding: 9px 12px;
  border-top: 1px solid var(--hairline);
  font-size: 13px;
}

th {
  border-top: none;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  padding-top: 14px;
  padding-bottom: 10px;
}

th:first-child, td:first-child { padding-left: 24px; }
th:last-child, td:last-child { padding-right: 24px; }

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

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.dim { color: var(--ink-2); }
td.time { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.tag-bounce { background: var(--bad-wash); color: var(--bad-text); }
.tag-complaint { background: var(--warn-wash); color: var(--warn-text); }
.tag-reject { background: var(--neutral-wash); color: var(--ink-2); }

.timeline-line { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.timeline-line strong { color: var(--ink); font-weight: 600; }

/* ---------- Login ---------- */

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

.login-card .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
}

.login-card .brand .logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.login-sub { color: var(--muted); font-size: 13px; margin: 6px 0 20px; }

.login-card .field { margin-bottom: 14px; }

.login-card label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 5px;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
}

.login-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.login-card input[type="submit"] {
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.login-card input[type="submit"]:hover { background: var(--accent-deep); }

.flash {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

.flash-alert { background: var(--bad-wash); color: var(--bad-text); }
.flash-notice { background: var(--accent-wash); color: var(--accent-deep); }

.signout {
  margin-top: 6px;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-family: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.signout:hover { color: var(--ink-2); }

/* ---------- Misc ---------- */

.empty {
  color: var(--muted);
  padding: 40px 24px;
  text-align: center;
  font-size: 13px;
}

.section-title { font-size: 14px; font-weight: 650; margin: 24px 0 12px; }

.backlink { display: inline-block; margin-top: 16px; font-size: 13px; }

@media (max-width: 760px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar-inner { position: static; height: auto; flex-direction: row; align-items: center; padding: 12px 16px; }
  .sidebar nav { flex-direction: row; }
  .sidebar .foot { display: none; }
  main { padding: 20px 16px 40px; }
  .overview { grid-template-columns: 1fr 1fr; }
  .overview .stat { border-bottom: 1px solid var(--hairline); }
}
