/* Alex Evans Everything Dashboard — design system
   Style reference: BYLD admin (dense, bordered cards, monochrome with sharp accents).
   Theme follows the OS setting via prefers-color-scheme. Light is default. */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

/* Bootzy is the logotype font. Drop the licensed file in /public/fonts/
   as Bootzy.woff2 and it activates automatically; until then the logo
   falls back to bold Poppins. */
@font-face {
  font-family: "Bootzy";
  src: url("/fonts/Bootzy.woff2") format("woff2");
  font-display: swap;
}

:root {
  --font-body: "Inter", -apple-system, "Segoe UI", sans-serif;
  --font-logo: "Bootzy", "Inter", sans-serif;

  --bg: #fafafa;
  --bg-sidebar: #fafafa;
  --bg-card: #ffffff;
  --bg-hover: #f0f0f2;
  --bg-active: #e9e9ec;
  --border: #e4e4e8;
  --border-strong: #d4d4da;
  --text: #16161a;
  --text-muted: #6f6f7a;
  --text-faint: #9a9aa4;

  --green: #1a9e56;
  --green-bg: rgba(26, 158, 86, 0.10);
  --red: #e5484d;
  --red-bg: rgba(229, 72, 77, 0.10);
  --amber: #d98f00;
  --amber-bg: rgba(217, 143, 0, 0.12);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.10);

  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-w: 244px;
}

/* Dark tokens. Applied two ways so a manual choice beats the OS setting:
   1. OS is dark AND no manual "light" override
   2. Manual "dark" override, regardless of OS */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0b;
    --bg-sidebar: #0a0a0b;
    --bg-card: #111113;
    --bg-hover: #1b1b1f;
    --bg-active: #222227;
    --border: #26262b;
    --border-strong: #34343b;
    --text: #f2f2f4;
    --text-muted: #9a9aa4;
    --text-faint: #62626b;

    --green: #3ecf78;
    --green-bg: rgba(62, 207, 120, 0.10);
    --red: #f2555a;
    --red-bg: rgba(242, 85, 90, 0.12);
    --amber: #f0b429;
    --amber-bg: rgba(240, 180, 41, 0.12);
    --blue: #60a5fa;
    --blue-bg: rgba(96, 165, 250, 0.12);
  }
}

:root[data-theme="dark"] {
  --bg: #0a0a0b;
  --bg-sidebar: #0a0a0b;
  --bg-card: #111113;
  --bg-hover: #1b1b1f;
  --bg-active: #222227;
  --border: #26262b;
  --border-strong: #34343b;
  --text: #f2f2f4;
  --text-muted: #9a9aa4;
  --text-faint: #62626b;

  --green: #3ecf78;
  --green-bg: rgba(62, 207, 120, 0.10);
  --red: #f2555a;
  --red-bg: rgba(242, 85, 90, 0.12);
  --amber: #f0b429;
  --amber-bg: rgba(240, 180, 41, 0.12);
  --blue: #60a5fa;
  --blue-bg: rgba(96, 165, 250, 0.12);
}

/* Ghost icon buttons (theme flipper, notifications) — BYLD style */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

/* Notifications popover */
.notif-wrap { position: relative; }
.notif-pop {
  display: none;
  position: absolute;
  right: 0;
  top: 40px;
  width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 6px;
  z-index: 40;
}
.notif-pop.open { display: block; }
.notif-pop .notif-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.notif-pop .notif-item { padding: 10px; font-size: 13px; color: var(--text); border-radius: var(--radius-sm); }
.notif-pop .notif-item small { display: block; color: var(--text-faint); margin-top: 2px; }
.notif-pop .notif-empty { padding: 18px 10px; font-size: 13px; color: var(--text-faint); text-align: center; }

/* Search (BYLD-style rounded input) */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  width: 240px;
  color: var(--text-faint);
}
.search svg { width: 14px; height: 14px; flex-shrink: 0; }
.search input {
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}
.search input::placeholder { color: var(--text-faint); }
.search:focus-within { border-color: var(--border-strong); }

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---- layout ---------------------------------------------------------- */

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.logo {
  font-family: var(--font-logo);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.02em;
  padding: 22px 20px 18px;
}

.nav-group { padding: 6px 12px 16px; }
.nav-group-label {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  padding: 8px 10px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 450;
  cursor: pointer;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { background: var(--bg-active); }
.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
}
.nav-item.active svg, .nav-item:hover svg { color: var(--text); }

/* Inline sub-nav: unfolds under the active section */
.sub-nav {
  display: flex;
  flex-direction: column;
  margin: 2px 0 8px 17px;
  border-left: 1px solid var(--border);
  padding-left: 9px;
}
.sub-nav-item {
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.sub-nav-item:hover { background: var(--bg-hover); color: var(--text); }
.sub-nav-item.active { background: var(--bg-active); color: var(--text); font-weight: 500; }

/* Flyout sub-nav: slim rail that slides out next to the sidebar */
.flyout {
  width: 0;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--bg-sidebar);
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.16s ease;
}
.flyout.open { width: 188px; border-right: 1px solid var(--border); }
.flyout-inner {
  width: 188px;
  padding: 22px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.flyout-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  padding: 0 9px 10px;
  white-space: nowrap;
}
.flyout .sub-nav-item { white-space: nowrap; }

/* Temporary switcher for picking a sub-nav variation */
.navstyle {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-faint);
}
.navstyle button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}
.navstyle button.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  font-size: 12px;
  color: var(--text-muted);
}
.sidebar-foot .status-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 7px;
}
.sidebar-foot .who { margin-top: 10px; color: var(--text); font-weight: 600; }
.sidebar-foot .who small { display: block; color: var(--text-muted); font-weight: 400; }
.sidebar-foot .logout { color: var(--text-faint); cursor: pointer; margin-top: 8px; display: inline-block; }
.sidebar-foot .logout:hover { color: var(--red); }

.main { flex: 1; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.topbar .crumb { font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .updated { font-size: 12px; color: var(--text-faint); }

.content { padding: 26px 28px 60px; max-width: 1280px; }

.page-title { font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.page-sub { color: var(--text-muted); margin-bottom: 22px; }

/* ---- subtabs (BYLD-style segmented row) ------------------------------ */

.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; }
.subtab {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.subtab:hover { color: var(--text); border-color: var(--border-strong); }
.subtab.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ---- cards ----------------------------------------------------------- */

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.card .big { font-size: 30px; font-weight: 700; line-height: 1.1; }
.card .delta { font-size: 12px; margin-top: 6px; color: var(--text-muted); }
.card .delta.up { color: var(--green); }
.card .delta.down { color: var(--red); }

.rock {
  border-left: 3px solid var(--amber);
}
.rock .big { font-size: 18px; font-weight: 600; }

/* ---- pills / status --------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 500;
}
.pill.green { color: var(--green); border-color: var(--green); background: var(--green-bg); }
.pill.red { color: var(--red); border-color: var(--red); background: var(--red-bg); }
.pill.amber { color: var(--amber); border-color: var(--amber); background: var(--amber-bg); }
.pill.blue { color: var(--blue); border-color: var(--blue); background: var(--blue-bg); }

/* ---- tables ----------------------------------------------------------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-muted); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }

/* ---- lists ------------------------------------------------------------ */

.check-list { list-style: none; }
.check-list li {
  display: flex; gap: 10px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.check-list li:last-child { border-bottom: none; }
.check-list .box { color: var(--text-faint); }
.check-list li.done { color: var(--text-faint); text-decoration: line-through; }
.check-list li.done .box { color: var(--green); }

.link-list { list-style: none; }
.link-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.link-list li:last-child { border-bottom: none; }
.link-list a { color: var(--text); font-weight: 500; }
.link-list a:hover { text-decoration: underline; }
.link-list small { color: var(--text-faint); display: block; }

/* ---- habit tracker ---------------------------------------------------- */

.habits { display: flex; flex-direction: column; gap: 8px; }
.habit-row { display: flex; align-items: center; gap: 10px; }
.habit-name { width: 130px; font-size: 13px; color: var(--text); }
.habit-cells { display: flex; gap: 4px; }
.habit-cell {
  width: 16px; height: 16px; border-radius: 4px;
  background: var(--bg-hover); border: 1px solid var(--border);
}
.habit-cell.hit { background: var(--green); border-color: var(--green); }

/* ---- placeholder blocks ------------------------------------------------ */

.placeholder {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 26px;
  color: var(--text-faint);
  text-align: center;
  font-size: 13px;
}

.quote { font-size: 16px; font-weight: 500; line-height: 1.5; }
.quote .attr { display: block; margin-top: 8px; font-size: 12px; color: var(--text-faint); font-weight: 400; }

.section-block { margin-bottom: 26px; }
.section-block > h2 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

/* ---- login ------------------------------------------------------------ */

.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 30px;
  text-align: center;
}
.login-card .logo { padding: 0 0 6px; font-size: 26px; }
.login-card p { color: var(--text-muted); margin-bottom: 22px; font-size: 13px; }
.login-card input {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  text-align: center;
  letter-spacing: 0.2em;
  margin-bottom: 12px;
}
.login-card input:focus { outline: 2px solid var(--blue); border-color: transparent; }
.login-card button {
  width: 100%;
  padding: 11px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.login-card .err { color: var(--red); font-size: 12px; margin-top: 10px; min-height: 16px; }

/* ---- mobile ----------------------------------------------------------- */

.menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 15px;
}

@media (max-width: 900px) {
  .grid.cols-4, .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .menu-btn { display: block; }
  .search { width: auto; flex: 1; min-width: 0; }
  .topbar .updated { display: none; }
  .flyout { display: none; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: 0 0 40px rgba(0,0,0,0.35);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 18px 16px 60px; }
  .topbar { padding: 12px 16px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .habit-name { width: 104px; }
}
