/*
  Noodle Tools shell.

  Same brand palette as Atlas (Moxxi blue + yellow, dark chrome over a light
  working area) so the two apps read as one family. Layout is "option A":
  the top bar carries the brand, the tool tabs and the account chip in one
  band; the active tool's sub-tools live in the dark sidebar beneath it.
*/

:root {
  color-scheme: light;

  --bg: #eef6fc;
  --bg-2: #f7fbfe;
  --surface: #ffffff;
  --surface-2: #f5fafd;

  --text: #0f172a;
  --muted: #47566c;
  --muted-2: #7d8da4;

  --line: rgba(15, 23, 42, 0.12);
  --line-soft: rgba(15, 23, 42, 0.07);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);

  --accent: #0099e5;
  --accent-ink: #0076b4;
  --accent-wash: rgba(0, 153, 229, 0.09);
  --accent-2: #ffc44d;
  --ok: #12876a;
  --danger: #e11d48;

  --chrome: #0b1220;
  --chrome-2: #101c33;
  --chrome-line: rgba(255, 255, 255, 0.10);
  --chrome-text: rgba(255, 255, 255, 0.93);
  --chrome-muted: rgba(255, 255, 255, 0.55);

  --topbar-h: 52px;
  --sidebar-w: 212px;
  --radius: 12px;
  --radius-sm: 8px;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  background: linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar: brand + tool tabs + account ---------- */

.topbar {
  flex: 0 0 var(--topbar-h);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  background: linear-gradient(180deg, var(--chrome), var(--chrome-2));
  border-bottom: 1px solid var(--chrome-line);
  color: var(--chrome-text);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.012em;
  color: var(--chrome-text);
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: #fff; }
.brand__mark { display: flex; color: var(--accent); }

.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  font-size: 13px;
  font-weight: 550;
  letter-spacing: -0.005em;
  color: var(--chrome-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: background-color .13s ease, color .13s ease;
}
.tab:hover { color: var(--chrome-text); background: rgba(255, 255, 255, 0.07); }
.tab[aria-current="page"] {
  color: #fff;
  font-weight: 620;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.10);
}
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.userchip {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.userchip__avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
}
.userchip__avatar--fallback {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
}
.userchip__email {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--chrome-muted);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 560;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .13s ease, border-color .13s ease;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-ink); }
.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}
.btn--secondary:hover { background: var(--surface-2); }
/* on the dark bar the secondary button has to sit on ink, not paper */
.topbar .btn--secondary {
  background: rgba(255, 255, 255, 0.09);
  color: var(--chrome-text);
  border-color: var(--chrome-line);
}
.topbar .btn--secondary:hover { background: rgba(255, 255, 255, 0.15); }
.topbar form { display: flex; }

/* ---------- page frames ---------- */

/* Column so flashed messages stack above the page body instead of beside it. */
.page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.page--center {
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

/* ---------- landing / signed-out card ---------- */

.card--intro {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px;
  max-width: 460px;
  width: 100%;
  text-align: center;
}
.card--intro h1 {
  font-size: 27px;
  font-weight: 720;
  letter-spacing: -0.022em;
  margin: 0 0 8px;
}
.muted { color: var(--muted); font-size: 14px; margin: 0; }
.actions { margin-top: 24px; display: flex; gap: 10px; justify-content: center; }

/* ---------- home: the grid of tool cards ---------- */

.home {
  flex: 1;
  overflow-y: auto;
  padding: 30px 28px 48px;
}
.home__inner { max-width: 1040px; margin: 0 auto; }
.home__title {
  font-size: 24px;
  font-weight: 720;
  letter-spacing: -0.022em;
  margin: 0;
}
.home__sub { color: var(--muted); font-size: 14px; margin: 5px 0 22px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 14px;
}

.toolcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 150px;
  text-decoration: none;
  color: inherit;
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.toolcard:hover {
  border-color: rgba(0, 153, 229, 0.45);
  box-shadow: 0 8px 22px rgba(0, 153, 229, 0.13);
  transform: translateY(-1px);
}
.toolcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.toolcard__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--accent-wash);
  color: var(--accent-ink);
  flex: 0 0 auto;
}
.toolcard__name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.012em;
}
.toolcard__tagline { font-size: 13px; color: var(--muted); }
.toolcard__foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ok);
}
.toolcard__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* the "nothing here yet" tile that holds the grid's rhythm */
.toolcard--placeholder {
  border-style: dashed;
  background: transparent;
  color: var(--muted-2);
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.toolcard--placeholder .toolcard__name { font-weight: 620; font-size: 14px; color: var(--muted); }
.toolcard--placeholder .toolcard__tagline { font-size: 12.5px; }

/* ---------- tool shell: dark sidebar + content ---------- */

.shell {
  flex: 1;
  min-height: 0;
  display: flex;
}

.sidebar {
  flex: 0 0 var(--sidebar-w);
  min-width: 0;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--chrome), var(--chrome-2));
  border-right: 1px solid var(--chrome-line);
}
.sidebar__label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--chrome-muted);
  padding: 0 10px 10px;
}

.navitem {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--chrome-muted);
  text-decoration: none;
  transition: background-color .13s ease, color .13s ease;
}
.navitem:hover { color: var(--chrome-text); background: rgba(255, 255, 255, 0.06); }
.navitem[aria-current="page"] {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}
.navitem:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.navitem__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
  flex: 0 0 auto;
}
.sidebar__empty {
  font-size: 12.5px;
  color: var(--chrome-muted);
  padding: 4px 10px;
  line-height: 1.45;
}

.content {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 22px 26px 40px;
}
.content__head { margin-bottom: 18px; }
.crumb {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted-2);
}
.content__title {
  font-size: 22px;
  font-weight: 720;
  letter-spacing: -0.022em;
  margin: 3px 0 0;
}
.content__lede { color: var(--muted); font-size: 14px; margin: 6px 0 0; max-width: 66ch; }

/* placeholder for tool bodies that aren't built yet */
.tbd {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 40px 24px;
  text-align: center;
}
.tbd__label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.tbd__note { font-size: 13.5px; color: var(--muted); margin: 8px auto 0; max-width: 46ch; }

/* ---------- table tools (Copy CSV, added by table-copy.js) ---------- */

.tbl-tools {
  display: flex;
  justify-content: flex-end;
  margin: 8px 0 -6px;
}
.tbl-tools__btn {
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted-2);
  cursor: pointer;
}
.tbl-tools__btn:hover { color: var(--accent-ink); border-color: var(--accent); }
.tbl-tools__btn.is-done { color: var(--ok); border-color: var(--ok); }
.tbl-tools__btn.is-failed { color: var(--danger); border-color: var(--danger); }

/* whole-page export: one CSV with a block per table (table-copy.js) */
.page-tools { position: fixed; right: 18px; bottom: 18px; z-index: 40; }
.page-tools__btn {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted-2);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}
.page-tools__btn:hover { color: var(--accent-ink); border-color: var(--accent); }
.page-tools__btn.is-done { color: var(--ok); border-color: var(--ok); }

/* ---------- flashes ---------- */

.alerts {
  display: grid;
  gap: 8px;
  margin: 16px auto 0;
  padding: 0 16px;
  width: 100%;
  max-width: 620px;
}
.alert {
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 14px;
  font-size: 13.5px;
}
.alert--error { border-left-color: var(--danger); }
.alert--success { border-left-color: var(--ok); }

/* ---------- narrow screens ---------- */

@media (max-width: 720px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .userchip__email { display: none; }
  .shell { flex-direction: column; }
  .sidebar {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--chrome-line);
    padding: 10px;
  }
  .sidebar__label { display: none; }
  .navitem { white-space: nowrap; }
  .navitem[aria-current="page"] { box-shadow: inset 0 2px 0 var(--accent); }
  .content { padding: 18px 16px 32px; }
  .home { padding: 22px 16px 36px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- frozen first column (every tool table) ----------
   The label column stays put while a wide table scrolls sideways. Sticky
   cells need a solid background to cover what scrolls under them, so the
   row variants that use translucent tints are re-stated here as opaque
   mixes of the same colours. The corner cell (first header) sticks on
   both axes; a second header row's first cell does not stick left, since
   the corner cell's rowspan already owns that column. */

.cpc-tbl tbody th:first-child, .cpc-tbl tbody td:first-child,
.cpc-tbl tfoot th:first-child, .cpc-tbl tfoot td:first-child,
.mig-tbl tbody th:first-child, .mig-tbl tbody td:first-child,
.mig-tbl tfoot th:first-child, .mig-tbl tfoot td:first-child,
.results tbody th:first-child, .results tbody td:first-child,
.tbl tbody th:first-child, .tbl tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line-soft);
}
.cpc-tbl thead tr:first-child th:first-child,
.mig-tbl thead tr:first-child th:first-child,
.results thead tr:first-child th:first-child,
.tbl thead tr:first-child th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
}
.cpc-tbl thead tr + tr th:first-child,
.mig-tbl thead tr + tr th:first-child { left: auto; }

/* opaque stand-ins for the translucent row tints */
.cpc-tbl tbody tr.is-sub td:first-child,
.cpc-tbl tbody tr.is-total th:first-child, .cpc-tbl tbody tr.is-total td:first-child,
.cpc-tbl tfoot tr.is-total th:first-child, .cpc-tbl tfoot tr.is-total td:first-child,
.mig-tbl tr.is-total th:first-child, .mig-tbl tr.is-total td:first-child { background: var(--surface-2); }
.cpc-tbl tbody tr.is-group th:first-child,
.cpc-tbl tbody tr.is-group td:first-child { background: color-mix(in srgb, var(--text) 5%, var(--surface)); }
.cpc-tbl tbody tr.is-link:hover th:first-child,
.cpc-tbl tbody tr.is-link:hover td:first-child,
.results tbody tr:hover td:first-child { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.cpc-tbl tbody tr.is-sub.is-link:hover td:first-child { background: color-mix(in srgb, var(--accent) 9%, var(--surface-2)); }
.mig-tbl tr.is-divider td:first-child { background: var(--surface-2); }

/* A date with its hour beside it (From / To on every dated screen). */
.dt-pair { display: inline-flex; gap: 4px; align-items: stretch; }
.dt-pair .hour-select,
.cpc-field .dt-pair .hour-select {
  min-width: 0;
  width: auto;
  font: inherit;
  font-size: 13px;
  padding: 6px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.dt-pair__sep { align-self: center; color: var(--muted-2); padding: 0 2px; }
