/* TSN Pulse Time — tracker-console theme.
   Self-contained: no external fonts, no CDNs.
   Palette: charcoal slate surfaces, ice-blue primary action, magenta project
   labels, TSN pulse-green reserved for the LIVE/running state only. */
:root {
  --bg: #22272e;          /* main canvas */
  --side: #171b20;        /* sidebar rail */
  --surface: #262c34;     /* cards, tracker bar */
  --row: #2a313a;         /* entry rows */
  --row-head: #232930;    /* day headers */
  --border: #343d48;
  --text: #cdd9e5;
  --muted: #7d8899;
  --blue: #2fb4f0;        /* primary action (START, links) */
  --blue-ink: #06202e;
  --pink: #ef6cab;        /* project / issue labels */
  --pulse: #35d0a0;       /* running state + brand dot only */
  --danger: #e0645f;
  --warn: #d9a441;
  --radius: 8px;
  font-size: 15.5px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.45;
}

h1 { font-size: 0.95rem; margin: 0; letter-spacing: 0.09em; font-weight: 600; }
h2 { font-size: 1.05rem; margin: 0 0 0.6rem; font-weight: 600; letter-spacing: 0.02em; }
h3 { font-size: 0.78rem; margin: 1.1rem 0 0.45rem; color: var(--muted);
     text-transform: uppercase; letter-spacing: 0.08em; }

.hidden { display: none !important; }
.spacer { flex: 1; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
        font-size: 0.85rem; word-break: break-all; }

/* ---------------------------------------------------------------- brand */
.brand { display: flex; align-items: center; gap: 0.55rem; }
.brand-center { justify-content: center; margin-bottom: 1rem; }
.pulse-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--pulse); flex: none;
  box-shadow: 0 0 0 0 rgba(53, 208, 160, 0.55);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(53, 208, 160, 0.5); }
  70%  { box-shadow: 0 0 0 10px rgba(53, 208, 160, 0); }
  100% { box-shadow: 0 0 0 0 rgba(53, 208, 160, 0); }
}
@media (prefers-reduced-motion: reduce) { .pulse-dot { animation: none; } }

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

.sidebar {
  width: 216px; flex: none; background: var(--side);
  display: flex; flex-direction: column;
  padding: 1rem 0 0.75rem; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 0 1.1rem 1.1rem; }
.sidebar nav { display: flex; flex-direction: column; }
.nav-label {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); padding: 1.1rem 1.1rem 0.35rem;
}
.nav-item {
  display: flex; align-items: center; gap: 0.7rem;
  background: none; border: none; border-left: 3px solid transparent;
  color: var(--muted); text-align: left; width: 100%;
  padding: 0.62rem 1.1rem; font-size: 0.86rem; cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.nav-item:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.nav-item.active {
  color: var(--text); background: rgba(47, 180, 240, 0.08);
  border-left-color: var(--blue);
}
.nav-ico { width: 1.1em; text-align: center; opacity: 0.85; }
.sidebar-foot {
  margin-top: auto; padding: 0.8rem 1.1rem 0; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  font-size: 0.84rem; color: var(--muted);
}

.main { flex: 1; min-width: 0; padding: 1.1rem 1.4rem 3rem; }
.view-head { margin-bottom: 0.9rem; }
.view-head h2 { margin-bottom: 0.4rem; }

/* ------------------------------------------------------------ inputs/btns */
input, select {
  background: #1d2229; border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 0.5rem 0.65rem; font-size: 0.9rem; min-width: 0;
}
input:focus, select:focus, button:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
input { flex: 1 1 150px; }
input[type="datetime-local"], input[type="date"] { flex: 0 1 220px; }

button {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 0.5rem 1rem; font-weight: 600; cursor: pointer; font-size: 0.88rem;
}
button:hover { filter: brightness(1.15); }
button.primary {
  background: var(--blue); color: var(--blue-ink); border-color: var(--blue);
  text-transform: uppercase; letter-spacing: 0.05em;
}
button.secondary { background: var(--surface); }
button.ghost { background: transparent; color: var(--muted); border-color: transparent; }
button.ghost:hover { color: var(--text); border-color: var(--border); }
button.danger { background: var(--danger); color: #2b0d0c; border-color: var(--danger);
  text-transform: uppercase; letter-spacing: 0.05em; }
button.icon { font-size: 1.05rem; padding: 0.4rem 0.7rem; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.row { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; margin: 0.45rem 0; }
.stack { display: flex; flex-direction: column; gap: 0.55rem; margin: 0.45rem 0; }
/* In a column flex container, input flex-basis becomes HEIGHT — pin it. */
.stack > input, .stack > select { flex: 0 0 auto; width: 100%; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem;
}
.card.narrow { max-width: 440px; margin: 4rem auto; }
.auth-card { box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35); }

.msg { color: var(--muted); font-size: 0.86rem; min-height: 1.2em; }
.msg.ok { color: var(--pulse); }
.msg.err { color: var(--danger); }
.msg.warn { color: var(--warn); }
.hint { color: var(--muted); font-size: 0.83rem; }

/* ------------------------------------------------------------ tracker bar */
.tracker-bar {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.65rem 0.8rem;
  position: sticky; top: 0.6rem; z-index: 10;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.tracker-bar input#timer-desc { flex: 1 1 260px; border: none; background: transparent;
  font-size: 0.98rem; }
.tracker-bar select { flex: 0 1 190px; color: var(--pink); font-weight: 600; }
.timer-display {
  font-family: ui-monospace, Consolas, monospace; font-size: 1.25rem;
  min-width: 108px; text-align: right; color: var(--text);
}
.timer-display.running { color: var(--pulse); }

.browse-jira { margin: 0.7rem 0 0.2rem; }
.browse-jira > summary { color: var(--muted); cursor: pointer; font-size: 0.85rem;
  padding: 0.25rem 0.15rem; }
.browse-jira[open] > summary { color: var(--text); }

/* --------------------------------------------------------- entry groups */
.week-block { margin-top: 1.4rem; }
.week-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 0.2rem 0.45rem;
}
.week-head .wk-name { font-weight: 600; font-size: 0.95rem; }
.week-head .wk-total { color: var(--muted); font-size: 0.85rem; }
.week-head .wk-total b { color: var(--text); font-size: 1.02rem; margin-left: 0.4rem;
  font-family: ui-monospace, Consolas, monospace; }

.day-block { border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 0.85rem; }
.day-head {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--row-head); padding: 0.5rem 0.9rem;
  font-size: 0.84rem; color: var(--muted);
}
.day-head b { color: var(--text); font-family: ui-monospace, Consolas, monospace;
  font-size: 0.98rem; margin-left: 0.4rem; }

.entry-row {
  display: flex; align-items: center; gap: 0.7rem;
  background: var(--row); border-top: 1px solid var(--border);
  padding: 0.55rem 0.9rem;
}
.entry-row:hover { background: #2f3742; }
.entry-desc { flex: 1 1 200px; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.entry-desc .placeholder { color: var(--muted); }
.entry-issue { color: var(--pink); font-weight: 600; font-size: 0.86rem;
  white-space: nowrap; }
.entry-issue::before { content: "\25CF"; margin-right: 0.4rem; font-size: 0.7em;
  vertical-align: 0.1em; }
.entry-range { color: var(--muted); font-size: 0.84rem; white-space: nowrap;
  font-family: ui-monospace, Consolas, monospace; }
.entry-dur { font-family: ui-monospace, Consolas, monospace; font-weight: 600;
  font-size: 0.95rem; min-width: 84px; text-align: right; }
.entry-dur.running { color: var(--pulse); }

.tag { display: inline-block; padding: 0.02rem 0.5rem; border-radius: 999px;
  font-size: 0.7rem; border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap; }
.tag.flag { color: var(--warn); border-color: var(--warn); }
.tag.sync { color: var(--pulse); border-color: var(--pulse); }

.play-btn { background: none; border: 1px solid transparent; color: var(--blue);
  font-size: 1rem; padding: 0.25rem 0.55rem; }
.play-btn:hover { border-color: var(--blue); }

/* Kebab menu (pure CSS via <details>) */
.kebab { position: relative; }
.kebab > summary { list-style: none; cursor: pointer; color: var(--muted);
  padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 1.05rem; }
.kebab > summary::-webkit-details-marker { display: none; }
.kebab > summary:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.kebab-menu {
  position: absolute; right: 0; top: 1.7rem; z-index: 20;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; min-width: 150px; padding: 0.3rem;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
  display: flex; flex-direction: column;
}
.kebab-menu button { background: none; border: none; text-align: left;
  padding: 0.45rem 0.7rem; font-weight: 500; border-radius: 4px; }
.kebab-menu button:hover { background: rgba(255, 255, 255, 0.06); }
.kebab-menu button.danger-item { color: var(--danger); }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; margin-top: 0.5rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; text-transform: uppercase;
     font-size: 0.7rem; letter-spacing: 0.05em; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* ------------------------------------------------------------- timesheet */
.week-label { color: var(--muted); font-size: 0.9rem; min-width: 200px; text-align: center; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.5rem;
  margin: 0.4rem 0 1rem; }
.day-cell { background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.55rem; min-height: 84px; }
.day-cell .d-name { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; }
.day-cell .d-total { font-family: ui-monospace, Consolas, monospace;
  font-size: 1.05rem; color: var(--text); margin-top: 0.3rem; }
.day-cell .d-count { font-size: 0.72rem; color: var(--muted); }
.day-cell.today { border-color: var(--blue); }

/* ----------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(6, 9, 13, 0.72);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 1rem;
}
.modal { width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); }
.modal h2 { margin-bottom: 0.2rem; }

/* --------------------------------------------------------- schema editor */
.schema-row {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr 1.1fr 0.9fr auto auto auto auto;
  gap: 0.4rem; align-items: center;
  padding: 0.35rem 0; border-bottom: 1px solid var(--border);
}
.schema-row input, .schema-row select { width: 100%; }
.schema-row .opts { grid-column: 1 / -1; }
.schema-row label.mini, label.mini {
  font-size: 0.72rem; color: var(--muted); display: flex; gap: 0.25rem;
  align-items: center; white-space: nowrap;
}
.schema-head { font-size: 0.7rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.05em; }

img#mfa-qr { background: #fff; border-radius: 8px; padding: 8px; }
details summary { cursor: pointer; }

/* ----------------------------------------------------------------- charts */
.chart-box { width: 100%; overflow-x: auto; }
.chart-box svg { display: block; }
.bar-value { fill: var(--text); font-size: 11px; font-family: ui-monospace, Consolas, monospace; }
.bar-label { fill: var(--muted); font-size: 11px; }
.bar-rect { fill: #8bc34a; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.donut-wrap { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.chart-box.donut { width: 260px; flex: none; }
.donut-total { fill: var(--text); font-size: 15px; font-weight: 600;
  font-family: ui-monospace, Consolas, monospace; }
.legend { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; min-width: 220px; }
.legend-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.84rem; }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.legend-item .mono { margin-left: auto; color: var(--muted); }
.filter-bar { border-top: 1px solid var(--border); padding-top: 0.55rem; }
.filter-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.08em; }
.schema-filters { margin: 0; gap: 0.55rem; }
.filter-bar select, .filter-bar input { flex: 0 1 180px; }

/* -------------------------------------------------------------- responsive */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row;
    flex-wrap: wrap; align-items: center; padding: 0.5rem; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { width: auto; border-left: none; border-bottom: 3px solid transparent; }
  .nav-item.active { border-bottom-color: var(--blue); }
  .nav-label, .sidebar-foot span { display: none; }
  .sidebar-foot { border: none; margin: 0; padding: 0; }
  .week-grid { grid-template-columns: repeat(4, 1fr); }
  .tracker-bar { flex-wrap: wrap; position: static; }
  .entry-range { display: none; }
}

/* tabs */
.tabs { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.tab { border: none; border-radius: 0; background: var(--surface); color: var(--muted);
  padding: 0.45rem 1rem; }
.tab.active { background: rgba(47,180,240,0.15); color: var(--text); }
/* print: report only */
@media print {
  body { background: #fff; color: #000; }
  .sidebar, .tracker-bar, #rep-controls .filter-bar, #rep-controls .row:last-of-type,
  #view-tracker, #view-timesheet, #view-jira, #view-settings, #view-admin { display: none !important; }
  .card { border: 1px solid #ccc; background: #fff; color: #000; }
  .msg.ok { color: #000; }
  th, td { color: #000; border-color: #ccc; }
  .bar-value, .bar-label, .donut-total { fill: #000; }
}

/* ============================================================================
   MODERN THEME (Phase C) — Clockify-inspired light default + preserved dark.
   Appended as an override layer: later rules win the cascade, so the original
   component structure above stays untouched. Toggle: sidebar ◐ button
   (html[data-theme="dark"] restores the original tracker-console palette).
   ========================================================================== */
:root {
  --bg: #f6f8fa;
  --side: #ffffff;
  --surface: #ffffff;
  --row: #ffffff;
  --row-head: #f1f4f7;
  --border: #e4e8ed;
  --text: #2c3542;
  --muted: #8b95a5;
  --blue: #4a90e2;
  --blue-ink: #ffffff;
  --pink: #c9509e;
  --pulse: #1fae85;
  --danger: #d8504a;
  --warn: #b3872b;
  --radius: 10px;
  --field: #fbfcfd;
  --hover: rgba(20, 40, 70, 0.045);
  --shadow: 0 4px 16px rgba(20, 30, 55, 0.07);
}
html[data-theme="dark"] {
  --bg: #22272e; --side: #171b20; --surface: #262c34; --row: #2a313a;
  --row-head: #232930; --border: #343d48; --text: #cdd9e5; --muted: #7d8899;
  --blue: #2fb4f0; --blue-ink: #06202e; --pink: #ef6cab; --pulse: #35d0a0;
  --danger: #e0645f; --warn: #d9a441;
  --field: #1d2229; --hover: rgba(255, 255, 255, 0.05);
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

/* Smoothness: gentle motion on interactive surfaces */
button, .nav-item, .entry-row, input, select, .tab, .list-row {
  transition: background 0.15s ease, color 0.15s ease,
              border-color 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

/* Re-point hardcoded darks at theme variables */
input, select { background: var(--field); }
.entry-row:hover { background: var(--hover); }
.nav-item:hover { background: var(--hover); }
.kebab > summary:hover { background: var(--hover); }
.kebab-menu button:hover { background: var(--hover); }
tr:hover td { background: var(--hover); }
.tracker-bar { box-shadow: var(--shadow); }
.kebab-menu { box-shadow: var(--shadow); }
.auth-card { box-shadow: 0 12px 36px rgba(20, 30, 55, 0.12); }
html[data-theme="dark"] .auth-card { box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35); }

/* Hover: darken slightly on light, brighten on dark */
button:hover { filter: brightness(0.97); }
html[data-theme="dark"] button:hover { filter: brightness(1.15); }
button.ghost:hover { filter: none; background: var(--hover); }
button.primary { box-shadow: 0 2px 8px rgba(74, 144, 226, 0.28); }
html[data-theme="dark"] button.primary { box-shadow: none; }

/* Sidebar refinement */
.sidebar { border-right: 1px solid var(--border); }
.card { box-shadow: 0 1px 3px rgba(20, 30, 55, 0.05); }
html[data-theme="dark"] .card { box-shadow: none; }

/* ------------------------------------------------------------- dashboard */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem; margin-bottom: 1rem;
}
.stat-card { margin: 0; padding: 0.95rem 1.15rem; }
.stat-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted);
}
.stat-value {
  font-size: 1.75rem; margin-top: 0.25rem;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
.stat-value.running { color: var(--pulse); }
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 860px) { .dash-cols { grid-template-columns: 1fr; } }

/* Generic list rows (favourites, recent tickets, team members) */
.list-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.15rem; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row .grow {
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.team-card { margin-bottom: 0.85rem; }
.team-card .members { margin: 0.2rem 0 0.6rem 1.1rem; }

/* Print: keep new views out of reports */
@media print {
  #view-dashboard, #view-projects, #view-teams, #view-departments {
    display: none !important;
  }
}

/* Reports filter bar: aligned grid instead of ragged wrapping */
#rep-controls .filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem; align-items: center;
}
#rep-controls .filter-bar .filter-label { grid-column: 1 / -1; padding-top: 0.2rem; }
#rep-controls .schema-filters { display: contents; }
#rep-controls .filter-bar select,
#rep-controls .filter-bar input { width: 100%; flex: none; }

/* Kebab menu must escape the day-block's overflow clip and sit above rows */
.day-block { overflow: visible; }          /* was hidden - clipped the menu */
.entry-row { position: relative; }
.entry-row:has(.kebab[open]) { z-index: 30; }   /* lift the active row */
.kebab-menu { z-index: 40; }
