:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-raised: #fbfcfd;
  --surface-muted: #eef3f2;
  --surface-nav: #f9fbfc;
  --surface-ledger: #f7f9fb;
  --text: #16202a;
  --text-muted: #5f6b7a;
  --text-subtle: #8490a0;
  --line: #d8dee7;
  --line-strong: #b9c3d0;
  --accent: #147260;
  --accent-hover: #0f5c4e;
  --accent-contrast: #ffffff;
  --accent-soft: #e4f3ef;
  --danger: #aa2a2a;
  --danger-hover: #891f1f;
  --danger-soft: #fff0f0;
  --danger-text: #ffffff;
  --success-bg: #e8f5f0;
  --success-border: #b9ddce;
  --success-text: #11513f;
  --warning-bg: #fff7e6;
  --warning-border: #e6c374;
  --warning-text: #744100;
  --error-bg: #fff0f0;
  --error-border: #ebb2b2;
  --error-text: #842020;
  --info-bg: #eaf3ff;
  --info-border: #b7d4f5;
  --info-text: #174a7a;
  --focus: #4ca5ff;
  --shadow-soft: 0 1px 2px rgb(15 23 42 / 5%);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1318;
  --surface: #171d24;
  --surface-raised: #1d2530;
  --surface-muted: #132820;
  --surface-nav: #141a21;
  --surface-ledger: #151c24;
  --text: #eef3f7;
  --text-muted: #b1bbc8;
  --text-subtle: #8290a1;
  --line: #2c3744;
  --line-strong: #465464;
  --accent: #35b395;
  --accent-hover: #69d1ba;
  --accent-contrast: #071512;
  --accent-soft: #12382f;
  --danger: #ffb4ab;
  --danger-hover: #ffd2cc;
  --danger-soft: #351b20;
  --danger-text: #ffffff;
  --success-bg: #12362f;
  --success-border: #287363;
  --success-text: #d6fff4;
  --warning-bg: #39280e;
  --warning-border: #8b601b;
  --warning-text: #ffe0a3;
  --error-bg: #3a181c;
  --error-border: #8d3038;
  --error-text: #ffd7d7;
  --info-bg: #132a40;
  --info-border: #2d628f;
  --info-text: #cfe8ff;
  --focus: #83c7ff;
  --shadow-soft: none;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent-hover);
  text-underline-offset: 3px;
}

:root[data-theme="dark"] a {
  color: var(--accent-hover);
}

a:focus,
button:focus,
summary:focus,
input:focus,
select:focus,
textarea:focus,
a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

h1 {
  font-size: 28px;
  font-weight: 750;
  line-height: 1.15;
  margin-bottom: var(--space-2);
}

h2 {
  font-size: 20px;
  font-weight: 750;
  line-height: 1.25;
  margin-bottom: var(--space-3);
}

h3 {
  font-size: 17px;
  font-weight: 750;
  line-height: 1.25;
  margin-bottom: var(--space-2);
}

.shell {
  min-height: 100vh;
}

.topbar {
  background: color-mix(in srgb, var(--surface-nav), var(--surface) 50%);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  align-items: center;
  display: flex;
  gap: var(--space-5);
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1240px;
  padding: 10px clamp(16px, 3vw, 40px);
  width: 100%;
}

.topbar-main {
  align-items: center;
  display: flex;
  gap: var(--space-5);
  min-width: 0;
}

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

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

.brand-mark {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  width: 34px;
}

.brand-mark-image {
  display: block;
  height: 34px;
  width: 34px;
}

.brand-copy {
  display: grid;
  gap: 1px;
  line-height: 1.1;
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
}

.brand-context {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.nav-primary {
  background: color-mix(in srgb, var(--surface), var(--line) 18%);
  border: 1px solid var(--line);
  border-radius: 8px;
  gap: 2px;
  padding: 3px;
}

.nav-utilities {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 3px;
  padding: 3px;
}

.nav-logout {
  display: inline-flex;
  margin: 0;
}

.nav a,
.button,
button,
.nav-button,
.nav-link-button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 650;
  justify-content: center;
  min-height: 40px;
  padding: 8px 12px;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.button,
button {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

a.button:not(.secondary):not(.tertiary):not(.danger-link):not(.danger-quiet),
a.button:not(.secondary):not(.tertiary):not(.danger-link):not(.danger-quiet):visited {
  color: var(--accent-contrast);
}

.button:hover,
button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.nav a,
.nav-button,
.nav-link-button {
  background: transparent;
  color: var(--text-muted);
}

.nav a:hover,
.nav-button:hover,
.nav-link-button:hover {
  background: var(--surface-raised);
  border-color: var(--line);
  color: var(--text);
}

.nav a[aria-current="page"] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent), transparent 48%);
  box-shadow: inset 0 -2px 0 var(--accent);
  color: var(--text);
}

.nav-button {
  border-color: transparent;
}

.button.secondary,
button.secondary {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--accent-hover);
}

.button.secondary:hover,
button.secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.button.tertiary,
button.tertiary {
  background: transparent;
  border-color: transparent;
  color: var(--accent-hover);
  min-height: auto;
  padding: 0;
}

.button.danger-link,
button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--danger-text);
}

a.button.danger-link,
a.button.danger-link:visited {
  color: var(--danger-text);
}

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

.button.danger-quiet,
.button.danger-quiet:visited {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger), transparent 64%);
  color: var(--danger);
}

.button.danger-quiet:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

button.warning-action,
.button.warning-action {
  background: transparent;
  border-color: var(--warning-border);
  color: var(--warning-text);
}

button.warning-action:hover,
.button.warning-action:hover {
  background: var(--warning-bg);
  border-color: var(--warning-border);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (prefers-reduced-motion: reduce) {
  .nav a,
  .button,
  button,
  .nav-button,
  .nav-link-button {
    transition: none;
  }
}

.content {
  margin: 0 auto;
  max-width: 1220px;
  padding: 28px clamp(16px, 4vw, 40px) 56px;
}

.page-head,
.page-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: var(--space-5);
  justify-content: space-between;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
}

.page-head > div:first-child,
.page-header > div:first-child {
  min-width: 0;
}

.page-head h1,
.page-header h1 {
  letter-spacing: 0;
  margin-bottom: var(--space-1);
}

.page-head p,
.page-header p {
  margin-bottom: 0;
}

.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.page-head > .actions,
.page-header > .actions,
.page-head > .button,
.page-header > .button {
  flex: 0 0 auto;
}

.dashboard-page-actions {
  justify-content: flex-end;
}

.dashboard-page-actions .button {
  white-space: nowrap;
}

.stack {
  display: grid;
  gap: var(--space-4);
}

.section-stack {
  display: grid;
  gap: var(--space-5);
}

.section-spaced {
  margin-bottom: var(--space-5);
}

.block-spaced {
  margin-top: var(--space-5);
}

.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.card,
.table-wrap,
form.panel,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  padding: var(--space-4);
}

.panel,
.card {
  min-width: 0;
}

.danger-panel {
  border-color: color-mix(in srgb, var(--danger), var(--line) 45%);
}

.metric {
  color: var(--text-muted);
  display: grid;
  gap: var(--space-1);
  font-size: 13px;
  min-height: 94px;
}

.metric strong {
  color: var(--text);
  display: block;
  font-size: 26px;
  font-weight: 750;
  line-height: 1.1;
}

.metric-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
}

.metric strong.currency-total-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.currency-total {
  white-space: nowrap;
}

.metric .metric-note {
  color: var(--text-subtle);
  font-size: 13px;
}

.compact-section {
  align-items: center;
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
}

.empty-state {
  align-items: center;
  background: var(--surface-raised);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: space-between;
  margin: 0;
  padding: var(--space-4);
}

.empty-state p {
  margin: 0;
}

.report-grid {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
}

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

.chart-header {
  align-items: end;
  display: flex;
  gap: var(--space-4);
  justify-content: space-between;
}

.chart-header p,
.chart-summary {
  margin-bottom: 0;
}

.chart-filter {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chart-filter label {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.chart-filter select {
  min-width: 118px;
}

.chart-summary {
  margin-top: var(--space-3);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
}

.chart-legend li {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.series-key {
  background: repeating-linear-gradient(var(--series-angle), var(--series-color) 0 3px, var(--surface) 3px 6px);
  border: 2px solid var(--series-color);
  display: inline-block;
  height: 14px;
  width: 22px;
}

.series-0 { --series-angle: 0deg; --series-color: #147260; }
.series-1 { --series-angle: 45deg; --series-color: #9a5b13; }
.series-2 { --series-angle: 90deg; --series-color: #3d62a8; }
.series-3 { --series-angle: 135deg; --series-color: #8b477c; }
.series-4 { --series-angle: 25deg; --series-color: #68751d; }
.series-5 { --series-angle: 65deg; --series-color: #a33d45; }
:root[data-theme="dark"] .series-0 { --series-color: #55c9ac; }
:root[data-theme="dark"] .series-1 { --series-color: #efb05e; }
:root[data-theme="dark"] .series-2 { --series-color: #7da2ed; }
:root[data-theme="dark"] .series-3 { --series-color: #d58bc4; }
:root[data-theme="dark"] .series-4 { --series-color: #b3c35a; }
:root[data-theme="dark"] .series-5 { --series-color: #ef8389; }
.target-key {
  background: transparent;
  border-color: var(--text);
  border-style: dashed none none;
  height: 1px;
}

.svg-chart-wrap {
  margin-top: var(--space-2);
  min-width: 0;
  width: 100%;
}

.svg-chart {
  display: block;
  height: auto;
  max-height: 360px;
  overflow: visible;
  width: 100%;
}

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

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

.chart-pattern-bg {
  fill: var(--surface);
}

.chart-pattern-line {
  fill: var(--series-color);
}

.chart-target-line {
  fill: none;
  stroke: var(--text);
  stroke-dasharray: 8 5;
  stroke-linejoin: round;
  stroke-width: 2.5;
}

.chart-data {
  border-top: 1px solid var(--line);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
}

.chart-data summary {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-hover);
  cursor: pointer;
  font-weight: 700;
  list-style-position: inside;
  min-height: 44px;
  padding: 10px 12px;
}

.chart-data summary:hover {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent), transparent 62%);
}

.chart-data summary::marker {
  color: var(--accent-hover);
}

.chart-data[open] summary {
  margin-bottom: var(--space-2);
}

.chart-data[open] .chart-table-wrap {
  margin-top: 0;
}

.chart-table-wrap {
  margin-top: var(--space-3);
  max-width: 100%;
  overflow-x: auto;
}

.list-toolbar {
  align-items: end;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: var(--space-3);
  grid-template-columns: minmax(220px, 1fr) auto auto;
  margin: 0 0 var(--space-5);
  padding: var(--space-3);
}

.search-field {
  margin: 0;
}

.toolbar-actions {
  align-items: end;
}

.density-field {
  border: 0;
  margin: 0;
  min-width: 0;
  padding: 0;
}

.density-field legend {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 var(--space-1);
  padding: 0;
}

.segmented-control {
  align-items: center;
  background: color-mix(in srgb, var(--surface), var(--line) 35%);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-flex;
  gap: 3px;
  min-height: 44px;
  padding: 3px;
}

.segmented-control button {
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 14px;
  min-height: 36px;
  padding: 6px 9px;
}

.segmented-control button.active {
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  color: var(--text);
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  margin-left: 6px;
  min-height: 22px;
  padding: 4px 8px;
  vertical-align: middle;
}

.badge.neutral {
  background: var(--surface-raised);
  color: var(--text-muted);
}

.badge.info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}

.badge.warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
}

.badge.success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.badge.danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger), var(--line) 40%);
  color: var(--danger);
}

.notice,
.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 600;
  padding: 10px 12px;
}

.notice {
  margin: 10px 0 0;
}

.message {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.message.info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}

.message.error,
.notice.error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.message.warning,
.notice.warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
}

.page-notice {
  margin: 0 0 var(--space-5);
}

.messages {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

table {
  border-collapse: collapse;
  width: 100%;
}

caption {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 650;
  padding: 0 0 var(--space-2);
  text-align: left;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-ledger);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--surface-ledger), transparent 35%);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.num {
  text-align: right;
}

.table-actions {
  justify-content: flex-end;
  min-width: 150px;
}

.table-actions a {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-hover);
  display: inline-flex;
  font-weight: 650;
  min-height: 36px;
  padding: 5px 8px;
  text-decoration: none;
}

.table-actions a:hover {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent), transparent 58%);
}

.record-list {
  display: none;
  gap: var(--space-3);
}

.record-card {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: var(--space-3);
  padding: var(--space-3);
}

.record-card header {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: var(--space-2);
  justify-content: space-between;
  padding-bottom: var(--space-2);
}

.record-title {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  font-weight: 750;
  min-height: 36px;
  min-width: 36px;
}

.record-meta {
  color: var(--text-muted);
  font-size: 13px;
}

.record-facts {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.record-fact {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 2px;
  padding: var(--space-2);
}

.record-fact span {
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.record-fact strong {
  font-size: 15px;
  font-weight: 650;
}

.record-card .table-actions {
  justify-content: flex-start;
  min-width: 0;
}

.record-card .table-actions a,
.record-card .table-actions button {
  min-height: 40px;
  padding: 7px 10px;
}

.record-card .table-actions form {
  display: inline-flex;
  margin: 0;
}

.quick-log {
  align-items: end;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: var(--space-3);
  grid-template-columns: minmax(180px, 1.3fr) minmax(180px, 1fr) auto minmax(140px, 0.7fr);
  padding: var(--space-3);
}

.quick-log.is-complete {
  align-items: center;
  background: color-mix(in srgb, var(--surface), var(--success-bg) 22%);
  grid-template-columns: minmax(180px, 1fr) auto;
}

.quick-log p {
  margin: 4px 0 0;
}

.quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.manual-log {
  align-items: end;
  display: flex;
  gap: var(--space-2);
}

.manual-log label {
  flex: 1 1 auto;
}

.preset-row {
  align-items: end;
  display: grid;
  gap: var(--space-3);
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 0.7fr) auto;
}

.preset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.inline-form {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.inline-form label {
  min-width: 220px;
}

.quick-extra {
  justify-self: end;
  min-width: 220px;
}

.quick-extra summary {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-hover);
  cursor: pointer;
  font-weight: 700;
  list-style-position: inside;
  padding: 8px 10px;
}

.quick-extra-fields {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

label {
  color: var(--text-muted);
  display: block;
  font-size: 13px;
  font-weight: 750;
  margin-bottom: 4px;
}

.field-label-row {
  align-items: center;
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
  min-width: 0;
  position: relative;
}

.field-label-row label {
  margin-bottom: 0;
}

.field-help-tooltip {
  display: inline-flex;
  position: static;
}

.help-icon {
  align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text-muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 750;
  height: 36px;
  justify-content: center;
  line-height: 1;
  min-height: 36px;
  padding: 0;
  width: 36px;
}

.help-icon:hover,
.help-icon:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.help-tooltip-text {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  left: 0;
  line-height: 1.35;
  max-width: min(300px, calc(100vw - 48px));
  opacity: 0;
  padding: 8px 10px;
  pointer-events: none;
  position: absolute;
  top: calc(100% + 6px);
  transform: translateY(-2px);
  transition: opacity 150ms ease, transform 150ms ease, visibility 150ms ease;
  visibility: hidden;
  width: max-content;
  z-index: 30;
}

.field-help-tooltip:hover .help-tooltip-text,
.field-help-tooltip:focus-within .help-tooltip-text {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
  .help-tooltip-text {
    transition: none;
  }
}

.required-marker {
  color: var(--danger);
  margin-left: 2px;
}

input,
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-width: 0;
  min-height: 42px;
  padding: 9px 10px;
  width: 100%;
}

input:hover,
select:hover,
textarea:hover {
  border-color: color-mix(in srgb, var(--line-strong), var(--text-muted) 38%);
}

textarea {
  min-height: 92px;
}

input[type="checkbox"],
input[type="radio"] {
  min-height: auto;
  padding: 0;
  width: auto;
}

input[type="file"] {
  background: var(--surface);
}

.file-widget {
  display: grid;
  gap: 10px;
}

.file-current,
.file-change,
.help,
.muted {
  color: var(--text-muted);
}

.help {
  font-size: 13px;
}

.field-error {
  color: var(--error-text);
  font-size: 13px;
  font-weight: 650;
  margin-top: 4px;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--error-border);
}

.error-summary ul,
.error-summary li {
  margin-bottom: 0;
}

.checkbox-line {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  font-size: 14px;
  font-weight: 650;
  gap: 8px;
  margin: 0;
}

.checkbox-field {
  align-content: center;
  background: color-mix(in srgb, var(--surface), var(--accent-soft) 35%);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: var(--space-3);
}

.form-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field {
  min-width: 0;
}

.form-grid.compact {
  grid-template-columns: minmax(160px, 0.45fr) minmax(140px, 0.35fr);
}

.field.full {
  grid-column: 1 / -1;
}

.form-section {
  border-top: 1px solid var(--line);
  margin-top: var(--space-5);
  padding-top: var(--space-5);
}

.form-section:first-child,
.form-section.first {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.form-section h2 {
  font-size: 17px;
  margin: 0 0 var(--space-1);
}

.form-section h3 {
  font-size: 17px;
  margin: 0 0 var(--space-1);
}

.form-section p {
  margin: 0 0 var(--space-3);
}

.form-actions {
  border-top: 1px solid var(--line);
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
}

.url-preview {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
  padding: var(--space-2);
}

.import-preview {
  align-items: start;
  display: grid;
  gap: var(--space-4);
  grid-template-columns: minmax(180px, 260px) 1fr;
  margin-bottom: var(--space-5);
}

.import-preview-image {
  aspect-ratio: 1;
  background: #eef1f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  width: 100%;
}

.import-preview-image img {
  border-radius: 6px;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.import-preview-copy {
  display: grid;
  gap: var(--space-3);
}

/* Product and inventory operations */
.inventory-kicker {
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 750;
  margin: 0 0 2px;
}

.product-card {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: minmax(78px, 0.42fr) minmax(0, 1fr);
  padding: var(--space-3);
}

.inventory-object {
  background: var(--surface);
}

.inventory-object-media {
  align-self: start;
  min-width: 0;
}

.inventory-object-body {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.inventory-object-heading {
  align-items: start;
  display: flex;
  gap: var(--space-2);
  justify-content: space-between;
  min-width: 0;
}

.product-title {
  font-size: 17px;
  margin-bottom: 0;
  min-width: 0;
}

.product-title a {
  align-items: center;
  display: inline-flex;
  min-height: 36px;
  min-width: 36px;
  overflow-wrap: anywhere;
}

.inventory-object-meta {
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
}

.inventory-object-meta span {
  align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  min-height: 28px;
  padding: 3px 8px;
}

.card-status-row {
  display: flex;
  margin: 0;
}

.product-status {
  flex: 0 0 auto;
  margin-left: 0;
}

.product-image {
  aspect-ratio: 1;
  align-self: center;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  width: min(220px, 100%);
}

.inventory-object-placeholder,
.product-image-empty {
  align-items: center;
  aspect-ratio: 1;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-subtle);
  display: flex;
  font-size: 18px;
  font-weight: 800;
  justify-content: center;
  width: min(220px, 100%);
}

.inventory-object-alert {
  grid-column: 1 / -1;
}

.inventory-detail-layout {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: minmax(260px, 0.9fr) minmax(360px, 1.5fr);
}

.product-identity-panel {
  align-content: start;
  display: grid;
  gap: var(--space-3);
}

.product-detail-image {
  justify-self: start;
  width: min(260px, 100%);
}

.product-identity-copy {
  display: grid;
  gap: var(--space-2);
}

.product-identity-copy h2 {
  margin: 0;
}

.inventory-metric-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inventory-metric {
  min-height: 112px;
}

.inventory-ledger {
  display: grid;
  gap: var(--space-3);
}

.ledger-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  padding-bottom: var(--space-3);
}

.ledger-header h2 {
  margin: 0;
}

.ledger-date {
  font-weight: 650;
  white-space: nowrap;
}

.usage-ledger .badge.neutral {
  font-size: 12px;
}

.inventory-form .form-section {
  background: color-mix(in srgb, var(--surface-raised), transparent 28%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: var(--space-3);
}

.inventory-form .form-section.first {
  border-top: 1px solid var(--line);
  padding-top: var(--space-3);
}

.product-grid.density-compact {
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.product-grid.density-compact .product-card {
  grid-template-columns: 58px minmax(0, 1fr);
  padding: var(--space-3);
}

.product-grid.density-compact .product-image {
  width: 58px;
}

.product-grid.density-compact .inventory-object-placeholder {
  width: 58px;
}

.product-grid.density-compact .product-title {
  font-size: 16px;
  line-height: 1.25;
}

.product-grid.density-compact .muted,
.product-grid.density-compact .notice {
  font-size: 13px;
}

/* Plan and schedule protocols */
.protocol-kicker {
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  margin: 0 0 2px;
}

.protocol-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.protocol-card {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-3);
}

.protocol-card-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  padding-bottom: var(--space-3);
}

.protocol-card-header h2 {
  font-size: 18px;
  margin: 0;
}

.protocol-card-header .badge {
  flex: 0 0 auto;
}

.protocol-stat-strip {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.protocol-stat,
.protocol-metric {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 2px;
  padding: var(--space-3);
}

.protocol-stat span,
.protocol-metric span {
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.protocol-stat strong,
.protocol-metric strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 750;
}

.protocol-metric em {
  color: var(--text-muted);
  font-size: 13px;
  font-style: normal;
}

.protocol-card-footer {
  display: flex;
  justify-content: flex-start;
}

.protocol-summary {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: var(--space-4);
}

.protocol-section,
.protocol-ledger {
  display: grid;
  gap: var(--space-3);
}

.protocol-section-header {
  align-items: flex-start;
}

.protocol-section-header .button {
  flex: 0 0 auto;
}

.protocol-table td:first-child {
  min-width: 180px;
}

.protocol-target-table td:nth-child(5) {
  min-width: 190px;
}

.cell-primary,
.cell-meta {
  display: block;
}

.cell-primary {
  color: var(--text);
  font-weight: 750;
  margin-bottom: 4px;
}

.cell-meta {
  color: var(--text-muted);
  font-size: 13px;
}

.protocol-form {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
}

.protocol-form .form-section {
  background: color-mix(in srgb, var(--surface-raised), transparent 28%);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 0;
  min-width: 0;
  padding: var(--space-3);
}

.protocol-form .form-section.first {
  border-top: 1px solid var(--line);
  padding-top: var(--space-3);
}

.protocol-form .form-actions {
  margin-top: 0;
}

.protocol-form .field,
.protocol-form .muted {
  min-width: 0;
  overflow-wrap: anywhere;
}

.danger-panel .protocol-kicker {
  color: var(--danger);
}

.login {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: var(--space-5);
}

.login form {
  margin: 0 auto;
  max-width: 420px;
  width: 100%;
}

.login-panel {
  display: grid;
  gap: var(--space-4);
}

.login-brand {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
}

.login-brand h1 {
  margin-bottom: 2px;
}

@media (max-width: 900px) {
  .topbar-inner {
    align-items: stretch;
    flex-direction: column;
    gap: var(--space-3);
  }

  .topbar-main {
    align-items: stretch;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-width: 0;
  }

  .nav-utilities {
    align-self: flex-end;
    flex: 0 0 auto;
  }

  .nav-primary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .nav-primary a,
  .nav-button,
  .nav-link-button {
    min-height: 38px;
    padding-left: 8px;
    padding-right: 8px;
    text-align: center;
  }

  .nav-logout {
    display: flex;
  }

  .nav-logout button {
    width: 100%;
  }

  .page-head,
  .page-header {
    flex-direction: column;
  }

  .page-head .actions,
  .page-header .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .page-head .actions .button,
  .page-head .actions button,
  .page-header .actions .button,
  .page-header .actions button {
    width: 100%;
  }

  .list-toolbar {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

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

  .toolbar-actions .button,
  .toolbar-actions button {
    width: 100%;
  }

  .segmented-control {
    display: flex;
  }

  .segmented-control button {
    flex: 1 1 0;
  }

  .quick-log,
  .quick-log.is-complete,
  .preset-row,
  .form-grid.compact,
  .import-preview,
  .inventory-detail-layout,
  .inventory-metric-grid,
  .protocol-summary {
    grid-template-columns: 1fr;
  }

  .quick-extra {
    justify-self: stretch;
    min-width: 0;
  }

  .table-wrap {
    overflow-x: auto;
  }

  .chart-panel {
    overflow-x: hidden;
  }

  .mobile-records .desktop-table {
    display: none;
  }

  .mobile-records .record-list {
    display: grid;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 15px;
  }

  h1 {
    font-size: 26px;
  }

  .topbar-inner {
    gap: var(--space-2);
    padding: 12px 14px;
  }

  .brand-context {
    display: none;
  }

  .nav-utilities {
    align-self: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .nav-button,
  .nav-link-button {
    width: 100%;
  }

  .content {
    padding: 20px 14px 44px;
  }

  .content > .page-header,
  .content > .page-head,
  .content > .card,
  .content > .table-wrap,
  .content > form.panel,
  .content > .panel {
    max-width: calc(100vw - 28px);
  }

  .card,
  .table-wrap,
  form.panel,
  .panel {
    padding: var(--space-3);
  }

  .metric {
    min-height: 84px;
  }

  .metric strong {
    font-size: 24px;
  }

  .chart-header,
  .chart-filter {
    align-items: stretch;
    flex-direction: column;
  }

  .chart-filter button,
  .chart-filter select {
    width: 100%;
  }

  .chart-axis-label {
    font-size: 10px;
  }

  .page-head .actions,
  .page-header .actions,
  .toolbar-actions,
  .form-actions {
    grid-template-columns: 1fr;
  }

  .quick-buttons button {
    flex: 1 1 0;
  }

  .inline-form {
    align-items: stretch;
  }

  .manual-log {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form label {
    min-width: 0;
    width: 100%;
  }

  .inline-form button,
  .inline-form .button {
    width: 100%;
  }

  .table-actions {
    justify-content: flex-start;
    min-width: 0;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

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

  .product-grid.density-compact .product-card {
    grid-template-columns: 1fr;
  }

  .product-grid.density-compact .product-image {
    width: min(92px, 100%);
  }

  .product-grid.density-compact .inventory-object-placeholder {
    width: min(92px, 100%);
  }

  .product-grid:not(.density-compact) {
    gap: var(--space-3);
  }

  .product-grid:not(.density-compact) .product-card {
    gap: 6px;
    grid-template-columns: 92px minmax(0, 1fr);
    padding: var(--space-3);
  }

  .product-grid:not(.density-compact) .product-card .inventory-object-media {
    grid-row: 1 / span 3;
  }

  .product-grid:not(.density-compact) .product-card .product-image {
    width: 92px;
  }

  .product-grid:not(.density-compact) .product-card .inventory-object-placeholder {
    width: 92px;
  }

  .product-grid:not(.density-compact) .product-card .inventory-object-alert {
    grid-column: 1 / -1;
  }

  .product-grid:not(.density-compact) .product-title {
    font-size: 16px;
  }

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

  .protocol-card-header,
  .protocol-section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .protocol-section-header .button {
    width: 100%;
  }

  .record-facts {
    grid-template-columns: 1fr;
  }
}
/* Dashboard cockpit */
.dashboard-layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--space-5);
  align-items: start;
}

.dashboard-cockpit {
  grid-auto-flow: row dense;
}

.dashboard-widget {
  min-width: 0;
}

.dashboard-widget.table-wrap {
  align-content: start;
  display: grid;
  gap: var(--space-4);
  grid-template-columns: minmax(0, 1fr);
}

.dashboard-widget.table-wrap,
.dashboard-widget .chart-table-wrap {
  overflow-x: auto;
}

.dashboard-widget.chart-panel {
  overflow-x: hidden;
}

.dashboard-widget table {
  min-width: max-content;
}

.dashboard-widget svg {
  display: block;
  height: auto;
  max-width: 100%;
  width: 100%;
}

.dashboard-widget.widget-expanded {
  grid-column: 1 / -1;
}

.dashboard-widget.widget-compact {
  grid-column: span 6;
}

.dashboard-widget-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  justify-content: space-between;
  margin: 0;
  padding-bottom: var(--space-2);
}

.dashboard-widget-header > div {
  min-width: 0;
}

.dashboard-widget-header h2 {
  font-size: 19px;
  margin: 0;
}

.dashboard-widget-header p {
  margin: var(--space-1) 0 0;
}

.dashboard-widget-header .badge {
  flex: 0 0 auto;
  margin-left: 0;
}

.dashboard-widget-header .button {
  flex: 0 0 auto;
}

.dashboard-widget-kicker {
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 750;
  margin: 0 0 2px;
}

.dashboard-widget-priority {
  background: color-mix(in srgb, var(--surface), var(--accent-soft) 16%);
  border-color: color-mix(in srgb, var(--accent), var(--line) 70%);
  box-shadow: none;
  padding: var(--space-5);
}

.dashboard-widget-priority .dashboard-widget-header {
  border-bottom-color: color-mix(in srgb, var(--accent), var(--line) 68%);
  padding-bottom: var(--space-3);
}

.dashboard-widget-priority .dashboard-widget-kicker {
  color: var(--accent-hover);
}

.dashboard-widget-priority .quick-log {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--accent), var(--line) 76%);
}

.dashboard-widget-priority .quick-log.is-complete {
  background: color-mix(in srgb, var(--surface), var(--success-bg) 28%);
  border-color: var(--success-border);
}

.quick-log-title {
  color: var(--text);
  display: block;
  font-size: 16px;
  line-height: 1.3;
}

.dashboard-widget-risk {
  background: color-mix(in srgb, var(--surface), var(--warning-bg) 28%);
  border-color: color-mix(in srgb, var(--warning-border), var(--line) 48%);
  box-shadow: none;
}

.dashboard-widget-risk .dashboard-widget-header {
  border-bottom-color: color-mix(in srgb, var(--warning-border), var(--line) 55%);
}

.dashboard-widget-risk .dashboard-widget-kicker {
  color: var(--warning-text);
}

.dashboard-widget-report.table-wrap {
  background: var(--surface);
}

.dashboard-metrics {
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-metrics .metric {
  background: var(--surface-raised);
  border-color: var(--line);
  box-shadow: none;
  gap: var(--space-2);
  min-height: 108px;
}

.dashboard-metrics .metric strong {
  font-size: 22px;
}

.dashboard-widget-report .dashboard-widget-kicker {
  color: var(--info-text);
}

.dashboard-widget-report.chart-panel {
  background: var(--surface);
}

.usage-review-counts,
.record-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.usage-review-group + .usage-review-group { margin-top: var(--space-4); }
.usage-review-group h3 { margin: 0 0 var(--space-2); font-size: 1rem; }
.usage-review-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-3); }
.detail-panel { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: var(--space-4); margin-bottom: var(--space-4); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--space-3); margin: 0; }
.detail-grid > div { border-top: 1px solid var(--line); padding-top: var(--space-2); }
.detail-grid dt { color: var(--text-muted); font-weight: 750; font-size: .875rem; }
.detail-grid dd { margin: var(--space-1) 0 0; }

.dashboard-widget-report .chart-summary {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-muted);
  padding: var(--space-3);
}

.chart-panel .chart-summary,
.chart-panel .svg-chart-wrap,
.chart-panel .chart-data {
  margin-top: 0;
}

.chart-panel .chart-legend {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 0;
  padding: var(--space-2) var(--space-3);
}

.chart-panel > p {
  margin-bottom: 0;
}

.widget-settings-list {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.widget-setting {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.widget-setting-primary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  min-width: 0;
}

.widget-setting-identity {
  min-width: 0;
}

.widget-setting-identity h2 {
  margin: 0;
}

.widget-position-context {
  margin: var(--space-1) 0 0;
}

.widget-visibility {
  min-width: max-content;
}

.widget-movement {
  display: grid;
  gap: var(--space-1);
  justify-items: end;
  min-width: 0;
}

.widget-movement > .field-label {
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 750;
}

.widget-movement-controls,
.widget-direct-move {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.widget-movement-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.widget-movement-controls button,
.widget-movement-controls select {
  min-height: 44px;
}

.widget-step-button {
  width: 44px;
  padding-inline: 0;
}

.widget-direct-move select {
  width: auto;
  min-width: 4.25rem;
}

.widget-movement .errorlist {
  margin: 0;
  max-width: 28rem;
}

.widget-setting-fields {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: var(--space-3);
}

.widget-setting-fields label {
  flex: 1 1 15rem;
  min-width: 0;
  max-width: 24rem;
}

.schedule-context-row > td {
  padding-top: 0;
}

.schedule-context,
.pause-history {
  max-width: 100%;
  min-width: 0;
  width: 100%;
}

.schedule-context > summary,
.pause-history > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  cursor: pointer;
  font-weight: 750;
}

.schedule-context-body {
  min-width: 0;
  padding: 0 0 var(--space-3);
}

.schedule-context-note,
.plan-checks-intro {
  max-width: 72ch;
}

.schedule-preview {
  display: grid;
  grid-template-columns: repeat(7, minmax(6.5rem, 1fr));
  gap: var(--space-2);
  margin: var(--space-3) 0;
  padding: 0;
  list-style: none;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.schedule-preview-day {
  display: grid;
  align-content: start;
  gap: var(--space-2);
  min-height: 5.5rem;
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.schedule-preview-day time {
  font-size: 0.8rem;
  font-weight: 750;
}

.schedule-pause-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.pause-history {
  border-top: 1px solid var(--line);
}

.saved-schedule-context {
  margin-top: var(--space-5);
  min-width: 0;
}

.diagnostic-list {
  border-top: 1px solid var(--line);
}

.diagnostic-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--line);
}

.diagnostic-row h3 {
  display: inline;
  margin-left: var(--space-2);
}

.diagnostic-row p {
  max-width: 72ch;
  margin: var(--space-2) 0;
}

.diagnostic-context {
  margin: 0;
  padding-left: 1.2rem;
}

.diagnostic-actions {
  align-content: flex-start;
  flex: 0 0 auto;
}

.diagnostic-actions a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

@media (max-width: 700px) {
  .schedule-preview {
    grid-template-columns: repeat(14, minmax(7.25rem, 1fr));
  }

  .diagnostic-row {
    align-items: stretch;
    flex-direction: column;
  }

  .diagnostic-actions a {
    min-height: 44px;
  }
}

@media (max-width: 900px) {
  .widget-setting-primary {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .widget-movement {
    grid-column: 1 / -1;
    justify-items: start;
  }

  .widget-movement-controls {
    justify-content: flex-start;
  }

  .dashboard-page-actions {
    justify-content: stretch;
  }

  .dashboard-widget.widget-compact,
  .dashboard-widget[data-widget-key="monthly_spending"],
  .dashboard-widget[data-widget-key="category_usage_chart"] {
    grid-column: 1 / -1;
  }

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

@media (max-width: 700px) {
  .dashboard-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-widget.widget-compact,
  .dashboard-widget.widget-expanded {
    grid-column: 1 / -1;
  }

  .dashboard-metrics {
    grid-template-columns: 1fr;
  }

  .dashboard-widget-priority {
    padding: var(--space-3);
  }
}

@media (max-width: 600px) {
  .widget-setting-primary {
    grid-template-columns: minmax(0, 1fr);
  }

  .widget-visibility {
    min-height: 44px;
  }

  .widget-movement,
  .widget-movement-controls {
    width: 100%;
  }

  .widget-direct-move {
    flex: 1 1 11rem;
  }

  .widget-direct-move select {
    flex: 1 1 auto;
    width: 1%;
  }

  .phase-one-action {
    min-height: 44px;
    white-space: normal;
  }

  .dashboard-widget-header {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-widget-header .button {
    width: 100%;
  }
}
.restock-context { margin-top: 8px; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--surface-muted); overflow-wrap: anywhere; }
.restock-context p, .restock-row p { margin: 6px 0 0; }
.restock-note, .preserve-lines { white-space: pre-wrap; overflow-wrap: anywhere; }
.restock-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.restock-row > div:first-child { min-width: 0; }
.stock-risk-ledger .record-actions .button { min-height: 44px; padding: 8px 12px; }
@media (max-width: 760px) { .restock-row { display: block; } .restock-row > .actions { margin-top: 12px; } }
