/* ==========================================================================
   theme.css — SYNC design system
   Minimal · monochrome · flat · typographic.

   Principles:
   - Hierarchy comes from type, spacing and alignment — not colour or shadow.
   - Surfaces are flat. Separation is a 1px border, never elevation.
   - Colour is reserved for status. Everything else is the neutral ramp.
   - One 8px spacing scale, one radius, one border. No exceptions per page.
   ========================================================================== */

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

:root {
  /* ---- Neutral ramp — the entire palette ------------------------------- */
  --c-black:   #000000;
  --c-900:     #0a0a0a;   /* primary text */
  --c-800:     #171717;   /* headings */
  --c-700:     #404040;   /* body */
  --c-600:     #525252;
  --c-500:     #737373;   /* secondary text */
  --c-400:     #a3a3a3;   /* metadata, placeholders */
  --c-300:     #d4d4d4;   /* strong border */
  --c-200:     #e5e5e5;   /* default border */
  --c-100:     #f5f5f5;   /* hover fill */
  --c-050:     #fafafa;   /* off-white surface */
  --c-white:   #ffffff;

  /* Brand accent, shared with the landing page — the current destination in
     the nav and today's date in the calendar. */
  --accent:     #7b4dff;
  --accent-dim: rgba(123, 77, 255, 0.12);

  /* ---- Status — the only colour in the system, used sparingly ---------- */
  --s-success: #0f7b4f;
  --s-warning: #a16207;
  --s-error:   #b42318;
  --s-info:    #3f3f46;

  --s-success-bg: #edf7f2;
  --s-warning-bg: #fdf6e7;
  --s-error-bg:   #fdf1f0;
  --s-info-bg:    var(--c-100);

  /* ---- Spacing: strict 8px scale --------------------------------------- */
  --sp-1: 8px;
  --sp-2: 16px;
  --sp-3: 24px;
  --sp-4: 32px;
  --sp-5: 40px;
  --sp-6: 48px;

  /* Screen gutter — identical on every page */
  --gutter: var(--sp-2);

  /* ---- Geometry --------------------------------------------------------- */
  --radius:    6px;
  --radius-lg: 8px;
  --border:    1px solid var(--c-200);

  /* ---- Type ------------------------------------------------------------- */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

  --t-display:  1.25rem;   /* screen title      20 */
  --t-title:    1rem;      /* section heading   16 */
  --t-subtitle: 0.875rem;  /* subheading        14 */
  --t-body:     0.875rem;  /* body              14 */
  --t-small:    0.8125rem; /* secondary         13 */
  --t-meta:     0.6875rem; /* metadata          11 */

  /* ---- Legacy token remap (modern.css / Bootstrap) ---------------------- */
  --primary: var(--c-900);
  --primary-hover: var(--c-700);
  --secondary: var(--c-500);
  --success: var(--s-success);
  --danger: var(--s-error);
  --warning: var(--s-warning);
  --info: var(--s-info);
  --light: var(--c-050);
  --dark: var(--c-900);
  --surface: var(--c-white);
  --text: var(--c-900);
  --muted: var(--c-500);

  --bs-primary: var(--c-900);
  --bs-primary-rgb: 10, 10, 10;
  --bs-body-color: var(--c-900);
  --bs-body-font-family: var(--font);
  --bs-border-color: var(--c-200);
  --bs-border-radius: var(--radius);
  --bs-border-radius-lg: var(--radius-lg);
  --bs-body-bg: var(--c-white);
}

/* ==========================================================================
   Base
   ========================================================================== */
body {
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.5;
  color: var(--c-900);
  background: var(--c-white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Typography — the primary hierarchy device
   ========================================================================== */
h1, .h1 {
  font-size: var(--t-display);
  font-weight: 600;
  letter-spacing: -0.024em;
  line-height: 1.25;
  color: var(--c-black);
  margin: 0 0 var(--sp-1);
}

h2, .h2 {
  font-size: var(--t-title);
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.35;
  color: var(--c-black);
  margin: 0 0 var(--sp-1);
}

h3, .h3, h4, .h4 {
  font-size: var(--t-subtitle);
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--c-800);
  margin: 0 0 var(--sp-1);
}

h5, h6, .h5, .h6 {
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--c-500);
  margin: 0 0 4px;
}

p { margin: 0 0 var(--sp-1); color: var(--c-700); }
p:last-child { margin-bottom: 0; }

small, .small { font-size: var(--t-small); }

.text-muted, .text-secondary { color: var(--c-500) !important; }
.text-dark, .text-body      { color: var(--c-900) !important; }
.fw-bold                     { font-weight: 600 !important; }

/* Section label — uppercase, tracked, quiet. Used above groups. */
.section-label {
  font-size: var(--t-meta);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-400);
  margin-bottom: var(--sp-1);
}

/* Tabular numerals so figures align down a column */
.metric, .fs-2, .fs-1, .display-6 {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  font-weight: 600;
  color: var(--c-black);
}

a { color: var(--c-900); text-decoration: none; }
a:hover { color: var(--c-600); }

/* ==========================================================================
   Surfaces — flat, bordered, never elevated
   ========================================================================== */
.card {
  background: var(--c-white);
  border: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

/* Templates variously stack .shadow-sm / .border-light / .rounded-3 on .card.
   Collapse them all into the single treatment. */
.card.shadow-sm,
.card.shadow,
.card.border-light,
.card.rounded-3,
.shadow-sm, .shadow {
  box-shadow: none !important;
  border-color: var(--c-200) !important;
  border-radius: var(--radius-lg) !important;
}

.card:hover { box-shadow: none !important; }

.card-header {
  background: transparent;
  border-bottom: var(--border);
  padding: 12px 14px;
  font-weight: 600;
}

.card-body { padding: 14px; }
.card-footer { background: transparent; border-top: var(--border); padding: var(--sp-2); }

hr { border-top: var(--border); opacity: 1; margin: var(--sp-2) 0; color: transparent; }

/* ==========================================================================
   Buttons — one system, three weights
   ========================================================================== */
.btn {
  font-family: var(--font);
  font-size: var(--t-body);
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 9px 14px;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}

/* Primary — solid black */
.btn-primary, .btn-dark {
  background: var(--c-black);
  border-color: var(--c-black);
  color: var(--c-white);
}
.btn-primary:hover, .btn-primary:focus,
.btn-dark:hover, .btn-dark:focus {
  background: var(--c-700);
  border-color: var(--c-700);
  color: var(--c-white);
}

/* Secondary — bordered white */
.btn-secondary,
.btn-outline-secondary,
.btn-outline-dark,
.btn-light {
  background: var(--c-white);
  border-color: var(--c-200);
  color: var(--c-900);
}
.btn-secondary:hover,
.btn-outline-secondary:hover,
.btn-outline-dark:hover,
.btn-light:hover {
  background: var(--c-050);
  border-color: var(--c-300);
  color: var(--c-900);
}

/* Tertiary — text only */
.btn-link {
  background: none;
  border-color: transparent;
  color: var(--c-600);
  padding-left: 0;
  padding-right: 0;
  text-decoration: none;
}
.btn-link:hover { color: var(--c-900); }

/* Destructive */
.btn-danger {
  background: var(--s-error);
  border-color: var(--s-error);
  color: var(--c-white);
}
.btn-danger:hover { background: #9a1f13; border-color: #9a1f13; }

.btn-sm { font-size: var(--t-meta); padding: 6px 10px; }
.btn-lg { font-size: var(--t-body); padding: 12px var(--sp-3); }

.btn:focus-visible,
.btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--c-white), 0 0 0 4px var(--c-900);
}

.btn:disabled, .btn.disabled { opacity: .4; }

/* ==========================================================================
   Inputs
   ========================================================================== */
.form-control,
.form-select,
.input-group-text {
  font-family: var(--font);
  font-size: var(--t-body);
  color: var(--c-900);
  background: var(--c-white);
  border: var(--border);
  border-radius: var(--radius);
  padding: 9px 11px;
  box-shadow: none;
}

.form-control::placeholder { color: var(--c-400); }

.form-control:focus,
.form-select:focus {
  border-color: var(--c-900);
  box-shadow: none;
  outline: none;
}

.form-label {
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--c-700);
  margin-bottom: 6px;
}

.form-text { font-size: var(--t-meta); color: var(--c-400); }

.form-check-input {
  border-color: var(--c-300);
  border-radius: 4px;
}
.form-check-input:checked {
  background-color: var(--c-black);
  border-color: var(--c-black);
}
.form-check-input:focus { box-shadow: none; border-color: var(--c-900); }

.input-group-text { background: var(--c-050); color: var(--c-500); }

/* ==========================================================================
   Tables — rules, not stripes; no card chrome
   ========================================================================== */
.table {
  --bs-table-color: var(--c-900);
  --bs-table-bg: transparent;
  font-size: var(--t-small);
  margin-bottom: 0;
  border-color: var(--c-200);
}

.table > thead th {
  background: transparent;
  color: var(--c-400);
  font-size: var(--t-meta);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-bottom: var(--border);
  white-space: nowrap;
}

.table > tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-100);
  vertical-align: middle;
  color: var(--c-700);
}

.table > tbody tr:last-child td { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { background: var(--c-050); }
.table-light, .table-light th { background: transparent !important; }

/* ==========================================================================
   Status — the only place colour appears
   ========================================================================== */
.badge {
  font-family: var(--font);
  font-size: var(--t-meta);
  font-weight: 500;
  letter-spacing: 0;
  padding: 4px 8px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.badge.bg-success, .badge.text-bg-success {
  background: var(--s-success-bg) !important;
  color: var(--s-success) !important;
  border-color: rgba(15,123,79,.18);
}
.badge.bg-danger, .badge.text-bg-danger {
  background: var(--s-error-bg) !important;
  color: var(--s-error) !important;
  border-color: rgba(180,35,24,.18);
}
.badge.bg-warning, .badge.text-bg-warning {
  background: var(--s-warning-bg) !important;
  color: var(--s-warning) !important;
  border-color: rgba(161,98,7,.20);
}
.badge.bg-secondary, .badge.bg-light, .badge.bg-info,
.badge.text-bg-secondary, .badge.text-bg-info {
  background: var(--c-100) !important;
  color: var(--c-600) !important;
  border-color: var(--c-200);
}
.badge.bg-primary, .badge.bg-dark, .badge.text-bg-primary, .badge.text-bg-dark {
  background: var(--c-900) !important;
  color: var(--c-white) !important;
}

/* Dot indicator — quieter than a pill where a row already has text */
.status-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-right: var(--sp-1);
  background: var(--c-400);
}
.status-dot.is-success { background: var(--s-success); }
.status-dot.is-warning { background: var(--s-warning); }
.status-dot.is-error   { background: var(--s-error); }

/* ==========================================================================
   Navigation
   ========================================================================== */
.sidebar-container {
  background: var(--c-white);
  border-right: var(--border);
}

.nav-pills .nav-link {
  border-radius: var(--radius);
  color: var(--c-600);
  font-size: var(--t-body);
  font-weight: 450;
  padding: 10px 12px;
}
.nav-pills .nav-link.active {
  background: var(--c-100);
  color: var(--c-black);
  font-weight: 500;
}

/* _sidebar.html marks the current item `active bg-dark text-white`. The rule
   above used to carry !important, which beat Bootstrap's .text-white and left
   dark text on a dark fill. */
.nav-link.bg-dark,
.nav-link.active.bg-dark,
.nav-pills .nav-link.active.bg-dark {
  background: var(--c-900) !important;
  color: var(--c-white) !important;
}

.nav-link.bg-dark i,
.nav-link.active.bg-dark i { color: var(--c-white) !important; }
.nav-pills .nav-link:hover:not(.active) {
  background: var(--c-050);
  color: var(--c-900) !important;
}

.nav-tabs { border-bottom: var(--border); }
.nav-tabs .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--c-500);
  font-size: var(--t-body);
  font-weight: 500;
  padding: 10px var(--sp-1);
}
.nav-tabs .nav-link.active {
  background: transparent;
  color: var(--c-black);
  border-bottom-color: var(--c-black);
}

/* ==========================================================================
   Overlays
   ========================================================================== */
.modal-content, .offcanvas {
  border: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: none;
}
.modal-header, .offcanvas-header { border-bottom: var(--border); padding: var(--sp-2); }
.modal-body   { padding: var(--sp-2); }
.modal-footer { border-top: var(--border); padding: var(--sp-2); gap: var(--sp-1); }
.modal-backdrop.show { opacity: .35; }

.dropdown-menu {
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: none;
  padding: 4px;
}
.dropdown-item {
  border-radius: 4px;
  font-size: var(--t-body);
  color: var(--c-700);
  padding: 8px 10px;
}
.dropdown-item:hover { background: var(--c-100); color: var(--c-900); }

.toast {
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}

/* ==========================================================================
   Empty & loading states
   ========================================================================== */
.empty-state {
  padding: var(--sp-6) var(--sp-2);
  text-align: center;
  border: 1px dashed var(--c-200);
  border-radius: var(--radius-lg);
}
.empty-state__title { font-size: var(--t-subtitle); font-weight: 600; color: var(--c-800); margin-bottom: 4px; }
.empty-state__body  { font-size: var(--t-small); color: var(--c-500); margin: 0; }

.skeleton {
  background: var(--c-100);
  border-radius: var(--radius);
  animation: skeleton 1.4s ease-in-out infinite;
}
@keyframes skeleton { 0%,100% { opacity: 1 } 50% { opacity: .55 } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ==========================================================================
   Column picker
   A quiet control above each table: text button, panel of checkboxes.
   Deliberately understated — it is a utility, not a feature to advertise.
   ========================================================================== */
.colpick {
  position: relative;
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--sp-1);
}

.colpick__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 10px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--c-white);
  color: var(--c-600);
  font-family: var(--font);
  font-size: var(--t-meta);
  font-weight: 500;
}

.colpick__btn:hover { background: var(--c-050); color: var(--c-900); }
.colpick__btn i { font-size: 11px; }

.colpick__count {
  color: var(--c-400);
  font-variant-numeric: tabular-nums;
}

.colpick__panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 1050;
  min-width: 200px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  background: var(--c-white);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
}

.colpick__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 4px;
  font-size: var(--t-small);
  color: var(--c-700);
  cursor: pointer;
}

.colpick__row:hover { background: var(--c-100); }

.colpick__row input {
  width: 16px;
  height: 16px;
  accent-color: var(--c-900);
  flex: none;
}

.colpick__reset {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border: 0;
  border-top: var(--border);
  border-radius: 0;
  background: none;
  color: var(--c-600);
  font-family: var(--font);
  font-size: var(--t-meta);
  font-weight: 500;
}

.colpick__reset:hover { color: var(--c-900); }

/* ==========================================================================
   Long-text cells
   A description longer than its column used to run under the next column.
   The text is clamped inside a fixed-width box so it can never overflow, with
   "Show more" expanding it in place.
   ========================================================================== */
.cell-collapse {
  display: block;
  /* Fills whatever width the column is given (see the rule below, which
     makes the table allocate a usable column). */
  width: 100%;
  max-width: 100%;
}

/* Browsers ignore max-width on table cells under auto table-layout, so the
   width is set on the inner box, which the cell must respect.

   From the tablet breakpoint up the column is wide enough to carry the whole
   description, which wraps — so there is no toggle at all. The phone layout
   keeps it, since a stacked record has no room to spare. */
@media (min-width: 768px) {
  td:has(> .cell-collapse) {
    min-width: 300px;
    max-width: 340px;
  }

  .cell-collapse {
    width: 100%;
    max-width: 100%;
  }

  /* The preview element already holds the full text, so the clamp is simply
     lifted. The <details> is hidden outright: a closed <details> hides its own
     children at the browser level, and no CSS on the child can override that —
     forcing the body visible left the cell blank. */
  .cell-collapse__peek {
    display: block !important;
    -webkit-line-clamp: none;
    overflow: visible;
    overflow-wrap: anywhere;
  }

  .cell-collapse__more { display: none !important; }
}

@media (min-width: 992px) {
  td:has(> .cell-collapse) {
    min-width: 320px;
    max-width: 380px;
  }
}

.cell-collapse > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  order: 2;
  color: var(--c-600);
  font-size: var(--t-meta);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.cell-collapse > summary::-webkit-details-marker { display: none; }
.cell-collapse > summary:hover { color: var(--c-900); }

/* Collapsed: one clamped line of the text, then the toggle. */
.cell-collapse__peek {
  width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--c-700);
  line-height: 1.45;
}

.cell-collapse.is-open .cell-collapse__peek { display: none; }

.cell-collapse__body {
  display: none;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--c-700);
  line-height: 1.5;
  padding-bottom: 4px;
}

.cell-collapse.is-open .cell-collapse__body { display: block; }

/* Keep the toggle beneath the text in both states. */
.cell-collapse { display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
.cell-collapse__more { display: block; }
