:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e8eef6;
  --header-bg: rgba(255, 255, 255, 0.9);
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-soft: #ccfbf1;
  --primary-softer: #f0fdfa;
  --on-primary: #ffffff;
  --accent: #0ea5e9;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-line: #fecaca;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --success-line: #bbf7d0;
  --info: #1d4ed8;
  --info-soft: #eff6ff;
  --info-line: #bfdbfe;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 18px 45px -28px rgba(15, 23, 42, 0.28);
  --shadow-lg: 0 28px 80px -36px rgba(15, 23, 42, 0.38);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --type-radiography: #2563eb;
  --type-fluorography: #0d9488;
  --type-mammography: #db2777;
  --type-ct: #d97706;
  --type-mri: #7c3aed;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #08111f;
    --surface: #101b2d;
    --surface-2: #162338;
    --surface-3: #1c2b42;
    --header-bg: rgba(8, 17, 31, 0.9);
    --text: #e6edf7;
    --text-soft: #c4d0e0;
    --muted: #91a1b7;
    --line: #22314a;
    --line-strong: #334663;
    --primary: #2dd4bf;
    --primary-hover: #5eead4;
    --primary-soft: #103c3a;
    --primary-softer: #0c2929;
    --on-primary: #042f2e;
    --accent: #38bdf8;
    --danger: #fca5a5;
    --danger-soft: #3a1720;
    --danger-line: #6b2635;
    --success: #86efac;
    --success-soft: #10291c;
    --success-line: #245b37;
    --info: #93c5fd;
    --info-soft: #132443;
    --info-line: #27457a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.22);
    --shadow: 0 18px 45px -28px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 28px 80px -36px rgba(0, 0, 0, 0.8);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 8% -4%, rgba(13, 148, 136, 0.12), transparent 30rem),
    radial-gradient(circle at 100% 0, rgba(37, 99, 235, 0.09), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
dl,
dd,
ul {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(1.8rem, 3vw, 2.45rem);
}

h2 {
  margin-bottom: 8px;
  font-size: 1.15rem;
}

a {
  color: var(--primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--primary-hover);
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: 2px;
}

::selection {
  background: var(--primary-soft);
  color: var(--text);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--surface);
  transform: translateY(-160%);
  transition: transform 0.15s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(16px);
}

.site-header__inner {
  width: min(1180px, calc(100% - 40px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 26px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  flex: 0 0 auto;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 13px;
  background: linear-gradient(135deg, #0f172a, #134e4a);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 8px 18px -12px rgba(13, 148, 136, 0.8);
}

.brand-mark span {
  width: 3px;
  height: 16px;
  border-radius: 3px;
  background: #5eead4;
}

.brand-mark span:nth-child(1) {
  height: 11px;
  opacity: 0.7;
}

.brand-mark span:nth-child(2) {
  height: 20px;
}

.brand-mark span:nth-child(3) {
  height: 14px;
  opacity: 0.85;
}

.brand-text {
  display: grid;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 0.98rem;
  letter-spacing: -0.02em;
}

.brand-text small {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand--large .brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
}

.brand--large .brand-text strong {
  font-size: 1.1rem;
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: 3px;
}

.nav-link {
  padding: 8px 12px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.user-menu {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  display: grid;
  gap: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  line-height: 1.2;
}

.user-chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.user-chip__name {
  max-width: 150px;
  overflow: hidden;
  font-size: 0.87rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip__role {
  color: var(--muted);
  font-size: 0.67rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.logout-form {
  margin: 0;
}

.button-link {
  padding: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.button-link:hover {
  color: var(--danger);
}

.page {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 64px;
  flex: 1;
}

.notice {
  margin-bottom: 20px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  white-space: pre-line;
  box-shadow: var(--shadow-sm);
}

.notice--success {
  border-color: var(--success-line);
  background: var(--success-soft);
  color: var(--success);
}

.notice--info {
  border-color: var(--info-line);
  background: var(--info-soft);
  color: var(--info);
}

.notice--error {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

.page-heading {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
}

.page-heading h1 {
  margin-bottom: 4px;
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.page-subtitle {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.eyebrow + h1,
.eyebrow + h2 {
  margin-top: 0;
}

.btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn--primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 10px 20px -14px color-mix(in srgb, var(--primary) 80%, transparent);
}

.btn--primary:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  color: var(--on-primary);
}

.btn--ghost {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text-soft);
}

.btn--ghost:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.btn--danger {
  border-color: var(--danger-line);
  background: transparent;
  color: var(--danger);
}

.btn--danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn--small {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
}

.btn--block {
  width: 100%;
}

.btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.text-link {
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.text-link:hover {
  text-decoration: underline;
}

.card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-header {
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.card-header h2 {
  margin-bottom: 2px;
}

.card-header p {
  margin-bottom: 0;
  font-size: 0.86rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 0.73rem;
  font-weight: 700;
  white-space: nowrap;
}

.chip--soft {
  margin-left: 5px;
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
  vertical-align: 1px;
}

.filter-bar {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.filter-bar__fields {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex: 1;
}

.filter-bar__actions {
  display: flex;
  gap: 8px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field label {
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
  outline: none;
}

.field input::placeholder {
  color: var(--muted);
}

.field--compact {
  gap: 5px;
}

.filter-bar .field--compact {
  width: 158px;
}

.filter-bar .field--grow {
  width: auto;
  min-width: 220px;
  flex: 1;
}

.field-hint {
  color: var(--muted);
  font-size: 0.73rem;
}

.form-stack {
  display: grid;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 0.8fr auto;
  align-items: end;
  gap: 14px;
}

.form-grid__actions {
  display: flex;
  align-items: flex-end;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.form-note {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

.inline-form {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.input--compact {
  width: 10.5rem;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
}

.inline-form select {
  min-height: 32px;
  padding: 4px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
}

.stat-grid {
  margin-bottom: 22px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  min-width: 0;
  padding: 19px 20px;
  display: grid;
  align-content: start;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stat-card--accent {
  border-color: transparent;
  background:
    linear-gradient(135deg, rgba(13, 148, 136, 0.96), rgba(15, 118, 110, 0.96)),
    var(--primary);
  color: #f0fdfa;
}

.stat-label {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-card--accent .stat-label {
  color: rgba(240, 253, 250, 0.78);
}

.stat-value {
  overflow: hidden;
  font-size: clamp(1.65rem, 3vw, 2.1rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1.15;
  text-overflow: ellipsis;
}

.stat-value--text {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.7rem;
}

.stat-card--accent .stat-value {
  color: #ffffff;
}

.stat-note {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.77rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-card--accent .stat-note {
  color: rgba(240, 253, 250, 0.82);
}

.dashboard-grid {
  margin-bottom: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.chart-card {
  min-width: 0;
}

.daily-card {
  margin-top: 22px;
}

.day-section {
  margin-top: 24px;
}

.day-section h3 {
  margin: 0 0 8px;
  font-size: 0.98rem;
}

.table--day {
  min-width: 760px;
}

.table--day thead th {
  background: var(--surface-2);
  text-align: center;
}

.table--day tbody td,
.table--day tbody th {
  font-variant-numeric: tabular-nums;
}

.table--day .day-highlight {
  background: var(--primary-softer);
}

.table--day th.day-highlight {
  background: var(--primary-soft);
  color: var(--primary);
}

.table--day .day-na {
  color: var(--muted);
  font-weight: 500;
}

.day-filter select {
  max-width: 170px;
}

.chart-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.chart-range select {
  max-width: 150px;
}

.chart-scroll {
  margin: 0 -4px;
  padding: 0 4px 4px;
  overflow-x: auto;
}

.chart {
  min-width: 720px;
}

.chart .empty-state {
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-gridline {
  stroke: var(--line);
  stroke-dasharray: 3 5;
  stroke-width: 1;
}

.chart-axis {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.chart-axis-label,
.chart-x-label,
.chart-total-label {
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 10px;
}

.chart-x-label {
  fill: var(--text-soft);
  font-size: 10.5px;
  font-weight: 600;
}

.chart-total-label {
  fill: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
}

.chart-bar {
  transition: opacity 0.15s ease;
}

.chart-bar:hover {
  opacity: 0.82;
}

.chart-legend {
  padding-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
  font-size: 0.76rem;
}

.chart-legend__swatch {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
}

.chart-legend__name {
  font-weight: 600;
}

.chart-legend__value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table th,
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.table thead th {
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table tbody tr:last-child td,
.table tbody tr:last-child th {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: var(--primary-softer);
}

.table tfoot th,
.table tfoot td {
  padding-top: 13px;
  border-top: 1px solid var(--line-strong);
  border-bottom: 0;
  font-size: 0.9rem;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table--compact th,
.table--compact td {
  padding: 10px 8px;
}

.table-link {
  font-weight: 600;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.table-subline {
  margin-top: 2px;
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
}

.table-subrow th,
.table-subrow td {
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  color: var(--text-soft);
  font-size: 0.82rem;
}

.table-subrow th {
  padding-left: 26px;
  font-weight: 500;
}

.table-subrow .type-dot {
  width: 6px;
  height: 6px;
  box-shadow: none;
  opacity: 0.75;
}

.table-subrow .share-bar {
  height: 3px;
  opacity: 0.7;
}

.table-detailrow th {
  padding-left: 44px;
}

.table-detailrow .type-dot {
  width: 5px;
  height: 5px;
  opacity: 0.55;
}

.subrow-prefix {
  margin-right: 5px;
  color: var(--muted);
  font-size: 0.68rem;
}

.table-note {
  margin: 10px 4px 0;
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.4;
}

.actions-column {
  width: 1%;
}

.type-cell {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.type-cell small {
  display: block;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 400;
  line-height: 1.25;
}

.type-cell .contrast-note {
  color: var(--primary);
  font-size: 0.68rem;
}

.type-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--type, var(--muted));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--type, var(--muted)) 14%, transparent);
}

.type-color--radiography {
  --type: var(--type-radiography);
}

.type-color--fluorography {
  --type: var(--type-fluorography);
}

.type-color--mammography {
  --type: var(--type-mammography);
}

.type-color--ct {
  --type: var(--type-ct);
}

.type-color--mri {
  --type: var(--type-mri);
}

.share-cell {
  width: 35%;
}

.share-bar {
  width: 100%;
  height: 5px;
  margin-top: 5px;
  display: block;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--surface-3);
  appearance: none;
}

.share-bar::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--surface-3);
}

.share-bar::-webkit-progress-value {
  border-radius: 999px;
  background: var(--type, var(--primary));
}

.share-bar::-moz-progress-bar {
  border-radius: 999px;
  background: var(--type, var(--primary));
}

.recent-card {
  margin-top: 0;
}

.empty-state {
  padding: 26px 16px;
  color: var(--muted);
  text-align: center;
}

.empty-state p {
  margin-bottom: 12px;
}

.error-panel {
  max-width: 660px;
  margin: 8vh auto 0;
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.error-code {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.error-panel h1 {
  margin-bottom: 10px;
}

.error-panel p {
  margin-bottom: 24px;
  color: var(--text-soft);
}

.error-panel .page-actions {
  justify-content: center;
}

.mini-stats {
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-stats span {
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.79rem;
}

.mini-stats strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.pagination {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.pagination__label {
  color: var(--muted);
  font-size: 0.8rem;
}

.page--auth {
  width: min(1120px, calc(100% - 40px));
  padding: 46px 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
}

.auth-body {
  background:
    radial-gradient(circle at 15% 10%, rgba(13, 148, 136, 0.16), transparent 30rem),
    radial-gradient(circle at 90% 90%, rgba(14, 165, 233, 0.12), transparent 34rem),
    var(--bg);
}

.auth-shell {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  align-items: center;
  gap: clamp(36px, 7vw, 84px);
}

.auth-intro {
  max-width: 620px;
}

.auth-intro .brand {
  margin-bottom: 42px;
}

.auth-intro h1 {
  margin-bottom: 18px;
  font-size: clamp(2.3rem, 5.4vw, 4rem);
  letter-spacing: -0.045em;
}

.auth-lead {
  max-width: 520px;
  margin-bottom: 24px;
  color: var(--text-soft);
  font-size: 1.04rem;
}

.auth-points {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 18px;
  list-style: none;
}

.auth-points li {
  position: relative;
  padding-left: 23px;
  color: var(--text-soft);
  font-size: 0.87rem;
}

.auth-points li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--primary);
  font-weight: 900;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  justify-self: end;
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.auth-card__header {
  margin-bottom: 22px;
}

.auth-card__header h2 {
  margin-bottom: 6px;
  font-size: 1.42rem;
}

.auth-card__header p:last-child {
  margin-bottom: 0;
  font-size: 0.84rem;
}

.callout {
  max-width: 520px;
  padding: 15px 17px;
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.82rem;
}

.callout strong {
  color: var(--text);
  font-size: 0.84rem;
}

.account-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
  align-items: start;
}

.profile-list {
  margin: 0 0 22px;
  display: grid;
}

.profile-list > div {
  padding: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.profile-list > div:first-child {
  padding-top: 0;
}

.profile-list > div:last-child {
  border-bottom: 0;
}

.profile-list dt {
  color: var(--muted);
  font-size: 0.79rem;
}

.profile-list dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.role-pill--admin {
  background: var(--primary-soft);
  color: var(--primary);
}

.role-pill--editor {
  background: var(--info-soft);
  color: var(--info);
}

.role-pill--viewer {
  background: var(--surface-3);
  color: var(--muted);
}

.entry-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.entry-form {
  padding: 26px;
}

.entry-date-row {
  margin-bottom: 23px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.date-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-stepper input {
  min-width: 165px;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.entry-status {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
}

.entry-status.is-error {
  color: var(--danger);
}

.entry-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.entry-grid--simple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.entry-groups {
  margin-top: 14px;
  display: grid;
  gap: 14px;
}

.entry-group {
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--type, var(--line-strong));
  border-radius: 12px;
  background: var(--surface-2);
}

.entry-group__head {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.entry-group__title {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.entry-group__title h2 {
  margin: 0;
  color: var(--text);
  font-size: 0.94rem;
  letter-spacing: -0.01em;
}

.entry-group__title small {
  color: var(--muted);
  font-size: 0.71rem;
}

.entry-group__total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.entry-group__total strong {
  color: var(--text);
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.subtype-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.subtype-card {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.subtype-card > label {
  margin-bottom: 8px;
  display: block;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.subtype-card--legacy {
  border-style: dashed;
  background: var(--surface-2);
}

.subtype-card--legacy > label {
  color: var(--muted);
}

.subtype-contrast {
  margin-top: 10px;
  padding-top: 9px;
  display: grid;
  gap: 5px;
  border-top: 1px dashed var(--line-strong);
}

.subtype-contrast label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.subtype-contrast input {
  width: 100%;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.subtype-contrast input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.subtype-card .stepper {
  grid-template-columns: 34px minmax(0, 1fr) 34px;
}

.subtype-card .stepper input {
  min-height: 38px;
  font-size: 1.02rem;
}

.subtype-card .stepper__button {
  min-height: 38px;
}

.entry-type {
  padding: 15px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--type, var(--line-strong));
  border-radius: 12px;
  background: var(--surface-2);
}

.entry-type__head {
  margin-bottom: 13px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.entry-type__head > div {
  min-width: 0;
}

.entry-type__head label {
  display: block;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.entry-type__head small {
  color: var(--muted);
  font-size: 0.71rem;
}

.stepper {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: stretch;
}

.stepper input {
  width: 100%;
  min-height: 42px;
  padding: 6px 2px;
  border: 1px solid var(--line-strong);
  border-right: 0;
  border-left: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font-size: 1.18rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
}

.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.stepper__button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
}

.stepper__button:first-child {
  border-radius: 9px 0 0 9px;
}

.stepper__button:last-child {
  border-radius: 0 9px 9px 0;
}

.stepper__button:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.entry-summary {
  margin-top: 22px;
  padding-top: 18px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.entry-summary strong {
  color: var(--text);
  font-size: 1.7rem;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.entry-form .form-actions {
  margin-top: 20px;
}

.info-card {
  padding: 22px;
}

.info-card h2 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.info-card p {
  margin-bottom: 0;
  font-size: 0.8rem;
}

.info-list {
  margin: 0 0 15px;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.info-list li::marker {
  color: var(--primary);
}

.add-user-card {
  margin-bottom: 18px;
}

.users-table {
  min-width: 920px;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.role-grid p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.79rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--header-bg);
}

.site-footer__inner {
  width: min(1180px, calc(100% - 40px));
  min-height: 62px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 0.73rem;
}

@media (max-width: 1080px) {
  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid,
  .entry-layout {
    grid-template-columns: 1fr;
  }

  .info-card {
    position: static;
  }

  .auth-shell {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 0.9fr);
    gap: 38px;
  }

  .auth-intro .brand {
    margin-bottom: 30px;
  }

  .auth-intro h1 {
    font-size: clamp(2.2rem, 4.4vw, 3.2rem);
  }

  .filter-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-bar__actions {
    justify-content: flex-end;
  }

  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid__actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .site-header__inner {
    padding: 10px 0;
    flex-wrap: wrap;
    gap: 8px 18px;
  }

  .primary-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .user-menu {
    margin-left: auto;
  }

  .site-header {
    position: static;
  }

  .auth-shell {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .auth-intro {
    max-width: none;
  }

  .auth-intro .brand {
    margin-bottom: 24px;
  }

  .auth-intro h1 {
    font-size: clamp(2rem, 8vw, 2.8rem);
  }

  .auth-card {
    max-width: none;
    justify-self: stretch;
  }

  .auth-points {
    grid-template-columns: 1fr;
  }

  .account-grid,
  .role-grid {
    grid-template-columns: 1fr;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-actions {
    justify-content: flex-start;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .subtype-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  .site-header__inner,
  .page,
  .page--auth,
  .site-footer__inner {
    width: min(calc(100% - 28px), 1180px);
  }

  .page {
    padding: 24px 0 46px;
  }

  .page--auth {
    padding: 26px 0;
  }

  .brand-text small,
  .user-chip__role {
    display: none;
  }

  .user-chip {
    padding: 6px 8px;
  }

  .user-chip__name {
    max-width: 110px;
  }

  .nav-link {
    padding: 7px 10px;
    font-size: 0.84rem;
  }

  .card {
    padding: 18px;
    border-radius: 14px;
  }

  .auth-card {
    padding: 22px;
  }

  .auth-intro h1 {
    font-size: 2.1rem;
  }

  .auth-lead {
    font-size: 0.94rem;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .chart-card .card-header,
  .daily-card .card-header {
    flex-direction: column;
  }

  .daily-card .day-filter {
    width: 100%;
  }

  .chart-actions {
    width: 100%;
    justify-content: space-between;
  }

  .stat-card {
    padding: 16px 18px;
  }

  .filter-bar__fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .filter-bar .field--compact,
  .filter-bar .field--grow {
    width: auto;
    min-width: 0;
  }

  .filter-bar .field--grow {
    grid-column: 1 / -1;
  }

  .filter-bar__actions .btn {
    flex: 1;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .entry-form {
    padding: 18px;
  }

  .entry-date-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .entry-status {
    text-align: left;
  }

  .date-stepper {
    width: 100%;
  }

  .date-stepper input {
    min-width: 0;
    flex: 1;
  }

  .entry-grid {
    grid-template-columns: 1fr;
  }

  .entry-group__head {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .subtype-grid {
    grid-template-columns: 1fr;
  }

  .mini-stats span {
    padding: 6px 10px;
  }

  .row-actions {
    flex-wrap: wrap;
  }

  .pagination {
    flex-wrap: wrap;
  }

  .site-footer__inner {
    padding: 14px 0;
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .error-panel {
    padding: 28px 20px;
    margin-top: 4vh;
  }

  .user-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .inline-form {
    flex-wrap: wrap;
  }
}

@media (max-width: 680px) {
  .filter-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-bar__fields,
  .filter-bar__actions {
    width: 100%;
  }

  .filter-bar__actions .btn {
    flex: 1;
    min-width: 0;
  }

  .chart {
    width: 100%;
    min-width: 0;
  }

  .chart-scroll {
    margin: 0;
    padding: 0;
  }

  .table--day {
    width: 100%;
    min-width: 0;
    display: block;
  }

  .table--day thead {
    display: none;
  }

  .table--day tbody {
    display: grid;
    gap: 12px;
  }

  .table--day tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
  }

  .table--day tbody tr:hover {
    background: var(--surface);
  }

  .table--day tbody th[scope="row"] {
    grid-column: 1 / -1;
    padding: 0 0 8px;
    border-bottom: 1px solid var(--line);
    white-space: normal;
  }

  .table--day tbody td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
    border: 0;
    text-align: right;
    white-space: normal;
  }

  .table--day tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-align: left;
  }

  .table--day tbody td.day-highlight {
    padding: 4px 7px;
    border-radius: 7px;
    background: var(--primary-softer);
  }
}

@media (max-width: 400px) {
  .table--day tbody tr {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .site-header,
  .site-footer,
  .filter-bar,
  .page-actions,
  .logout-form,
  .btn,
  .pagination,
  .row-actions {
    display: none !important;
  }

  .page {
    width: 100%;
    padding: 0;
  }

  .card,
  .stat-card {
    border-color: #cbd5e1;
    box-shadow: none;
    break-inside: avoid;
  }
}
