:root {
  color-scheme: light;
  font-family: Inter, Segoe UI, Arial, Helvetica, sans-serif;
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #111827;
  --muted: #64748b;
  --border: #d7dee8;
  --header: #071526;
  --header-soft: #132338;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --success-bg: #dcfce7;
  --success: #166534;
  --danger-bg: #fee2e2;
  --danger: #991b1b;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  min-height: 104px;
  padding: 24px 32px;
  background: linear-gradient(90deg, var(--header), var(--header-soft));
  color: #ffffff;
}

.app-header h1,
.panel h2,
.table-title h3 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: 28px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 5px;
  color: #93a4bc;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.refresh-meta {
  display: grid;
  gap: 4px;
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.refresh-meta span {
  color: #b6c3d4;
  font-size: 12px;
  font-weight: 700;
}

.refresh-meta strong {
  color: #ffffff;
  font-size: 14px;
}

.dashboard {
  display: grid;
  gap: 20px;
  max-width: 1680px;
  margin: 0 auto;
  padding: 24px 28px 40px;
}

.panel,
.table-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-primary {
  border-top: 4px solid var(--accent);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 21px;
  line-height: 1.2;
}

.inline-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.timeline-panel .panel-heading {
  display: block;
}

.timeline-controls {
  grid-template-columns: minmax(180px, 1.3fr) repeat(2, minmax(130px, 0.8fr)) minmax(175px, 1fr) auto auto;
  margin-top: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
}

input,
select {
  width: 100%;
  padding: 7px 9px;
  background: #ffffff;
  color: #111827;
}

button {
  padding: 7px 14px;
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  font-weight: 800;
  cursor: pointer;
  transition: transform 170ms ease, box-shadow 170ms ease, background-color 170ms ease, border-color 170ms ease;
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}

button:active {
  transform: translateY(1px) scale(0.97);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.18);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

button.secondary {
  background: #ffffff;
  color: #111827;
  border-color: var(--border);
}

button.secondary:hover {
  background: #f1f5f9;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 13px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 200ms ease, transform 200ms ease, box-shadow 200ms ease;
}

.metric:hover {
  transform: translateY(-3px);
  border-color: #91afea;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.09);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  align-self: end;
  color: #0f172a;
  font-size: 24px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.status {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.status.error {
  color: #b91c1c;
}

.table-card {
  overflow: hidden;
  box-shadow: none;
}

.table-title {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.table-title h3 {
  font-size: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  font-size: 14px;
}

th {
  background: #e8eef8;
  color: #172554;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr:nth-child(even) {
  background: #f8fafc;
}

tbody tr {
  transition: background-color 160ms ease;
}

tbody tr:hover {
  background: #eaf3ff;
}

.week-controls {
  grid-template-columns: minmax(150px, 1fr) 38px 38px;
  gap: 8px;
}

.week-controls button {
  padding: 0;
  font-size: 25px;
  line-height: 1;
}

.week-table {
  min-width: 1040px;
}

.week-table th,
.week-table td {
  text-align: center;
}

.week-table th:first-child,
.week-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 190px;
  background: inherit;
  text-align: left;
  font-weight: 800;
}

.week-table th:first-child {
  background: #e8eef8;
}

.week-day {
  width: 38px;
  min-height: 38px;
  padding: 0;
  background: #edf2f7;
  border-color: #dce5ee;
  color: #64748b;
  font-size: 13px;
  font-weight: 900;
}

.week-day.has-signal {
  background: #d6f3ed;
  border-color: #9ad7c9;
  color: #07675d;
}

.week-day.has-action {
  background: #b7e9c9;
  border-color: #6bc495;
  color: #105536;
}

.week-day.has-submit {
  background: #fbe4ae;
  border-color: #f5b647;
  color: #704307;
}

.week-day:hover,
.week-day.selected {
  background: #1f5cca;
  border-color: #1f5cca;
  color: #fff;
  transform: translateY(-3px) scale(1.09);
  box-shadow: 0 9px 15px rgba(31, 92, 202, 0.26);
}

.week-day.selected {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
}

.results-panel {
  border-top: 4px solid #0e8073;
}

.results-note {
  margin: -4px 0 12px;
}

.results-table {
  min-width: 650px;
}

.result-count {
  color: #0e685e;
  font-weight: 900;
  font-size: 14px;
}

.badge {
  display: inline-flex;
  min-width: 92px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.badge-worked {
  background: var(--success-bg);
  color: var(--success);
}

.badge-missing {
  background: var(--danger-bg);
  color: var(--danger);
}

.empty {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.chart-shell {
  position: relative;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.view-flipper {
  height: 440px;
  perspective: 1400px;
}

.view-flipper-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 560ms ease;
}

.view-flipper.is-flipped .view-flipper-inner {
  transform: rotateY(180deg);
}

.view-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.heatmap-shell {
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  transform: rotateY(180deg);
}

.heatmap-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
}

.heatmap-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.heatmap-table th,
.heatmap-table td {
  width: 104px;
  min-width: 104px;
  height: 30px;
  padding: 3px 6px;
  border: 0;
  text-align: center;
}

.heatmap-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 42px;
  border-bottom: 1px solid var(--border);
  background: #e8eef8;
  font-size: 11px;
  text-transform: none;
  white-space: normal;
}

.heatmap-table .heatmap-hour {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 74px;
  min-width: 74px;
  background: #f8fafc;
  border-right: 1px solid var(--border);
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.heatmap-table thead .heatmap-hour {
  z-index: 3;
  background: #e8eef8;
}

.heatmap-cell {
  display: block;
  width: 22px;
  height: 22px;
  min-height: 22px;
  margin: 0 auto;
  padding: 0;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 4px;
  background: #e6ecf2;
  cursor: pointer;
}

.heatmap-cell:hover,
.heatmap-cell:focus-visible {
  outline: 2px solid #0f172a;
  outline-offset: 2px;
}

.heatmap-caption {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.chart-empty {
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.86);
  border-radius: 6px;
}

.chart-empty[hidden] {
  display: none;
}

.note {
  margin: 12px 0 0;
  max-width: 960px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 1100px) {
  .panel-heading {
    display: grid;
    align-items: stretch;
  }

  .inline-controls,
  .timeline-controls,
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-header {
    display: grid;
    padding: 20px 16px;
  }

  .dashboard {
    padding: 16px;
  }

  .inline-controls,
  .timeline-controls,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .week-controls {
    grid-template-columns: minmax(0, 1fr) 38px 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .view-flipper-inner,
  button,
  .metric,
  tbody tr {
    transition: none;
  }
}

/* One full day with compact labels and no inner vertical scrollbar. */
[hidden]{display:none!important}
.header-actions{display:flex;align-items:center;gap:14px}
.day-navigation{display:flex;gap:4px;align-items:center}
.day-navigation button{min-width:38px;padding:7px}
.timeline-controls{display:flex;flex-wrap:wrap;gap:10px;align-items:flex-end}
.timeline-controls label{flex:0 1 170px}
.timeline-controls label:first-child{flex-basis:240px}
.view-flipper,.view-flipper-inner{height:auto;perspective:none;transform:none!important;transition:none}
.view-face{position:relative;inset:auto;transform:none;backface-visibility:visible}
#timeline-line-face{display:block;height:440px}
#timeline-heatmap-face{display:none}
.is-flipped #timeline-line-face{display:none}
.is-flipped #timeline-heatmap-face{display:block}
.heatmap-scroll{height:auto;overflow-x:auto;overflow-y:visible;padding:8px}
.heatmap-table{width:auto;min-width:0;table-layout:fixed}
.heatmap-table th,.heatmap-table td{width:27px;min-width:27px;height:18px;padding:1px 3px;line-height:16px}
.heatmap-table thead th{height:112px;vertical-align:bottom;padding-bottom:6px}
.heatmap-column-label{display:inline-block;writing-mode:vertical-rl;transform:rotate(180deg);white-space:nowrap;font-size:11px;line-height:17px}
.heatmap-table .heatmap-hour{width:58px;min-width:58px;font-size:10px;padding:0 6px}
.heatmap-cell{width:16px;height:16px;min-height:16px;border-radius:2px}
.heatmap-cell:hover{transform:none;box-shadow:none}
.heatmap-caption{margin:0 0 10px}
@media(max-width:640px){.header-actions{flex-wrap:wrap}.timeline-controls label{flex-basis:140px}}
.login-panel{max-width:440px;width:100%;margin:5vh auto}.login-panel form{display:grid;gap:18px;margin:24px 0}.login-panel button{margin-top:6px}
