/* 华牛进销存 · shared interface styles. No external assets or fonts. */
:root {
  color-scheme: light;
  --ink: #20352e;
  --ink-soft: #4b6057;
  --muted: #6c7c74;
  --green: #20664d;
  --green-hover: #174e3a;
  --green-dark: #153d30;
  --green-deep: #102e25;
  --green-wash: #edf5ef;
  --canvas: #f5f6f1;
  --surface: #ffffff;
  --surface-soft: #f8faf7;
  --border: #dce4dc;
  --border-strong: #becdc1;
  --warning: #805b18;
  --warning-wash: #fff8e7;
  --danger: #a13c35;
  --danger-wash: #fff1ee;
  --info: #345e74;
  --info-wash: #eef5f8;
  --radius: 14px;
  --radius-small: 8px;
  --shadow: 0 3px 16px rgb(22 52 37 / 4%);
  --focus: #4b886b;
  --sidebar-width: 244px;
}

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

html {
  min-width: 320px;
  background: var(--canvas);
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

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

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

h1,
h2,
h3,
h4 {
  color: var(--ink);
  line-height: 1.35;
  font-weight: 650;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(24px, 2.3vw, 32px);
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 14px;
  font-size: 19px;
  letter-spacing: -0.02em;
}

h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

p:last-child {
  margin-bottom: 0;
}

small {
  font-size: 12px;
}

hr {
  margin: 24px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

::selection {
  color: var(--green-deep);
  background: #d6e9d9;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  flex-direction: column;
  padding: 30px 18px 20px;
  overflow-y: auto;
  color: #d1e0d6;
  background: var(--green-dark);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  margin: 0 8px 34px;
  color: #fff;
  text-decoration: none;
}

.brand:hover {
  color: #fff;
}

.brand-mark {
  display: inline-flex;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: 12px;
  color: #f8f8e9;
  background: rgb(255 255 255 / 7%);
  font-size: 20px;
  font-weight: 650;
  line-height: 1;
}

.brand-title {
  display: block;
  color: inherit;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: 0.04em;
  line-height: 1.4;
}

.brand-subtitle {
  display: block;
  margin-top: 3px;
  color: #afc8b9;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.12em;
  line-height: 1.5;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-link {
  position: relative;
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  color: #cee0d4;
  font-size: 14px;
  text-decoration: none;
  transition: background-color 140ms ease, color 140ms ease;
}

.nav-link:hover {
  color: #fff;
  background: rgb(255 255 255 / 7%);
}

.nav-link.active,
.nav-link[aria-current="page"] {
  border-color: rgb(213 237 217 / 12%);
  color: #fff;
  background: #2d5945;
  font-weight: 600;
}

.nav-link.active::before,
.nav-link[aria-current="page"]::before {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #c5d9ae;
  content: "";
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 28px 12px 0;
  color: #acc4b6;
  font-size: 12px;
  line-height: 1.8;
}

.sidebar-footer a {
  color: #d8e5db;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 36px;
  border-bottom: 1px solid var(--border);
  background: #fcfdf9;
}

.topbar-title {
  min-width: 0;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
}

.topbar-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.topbar-actions {
  justify-content: flex-end;
  font-size: 13px;
}

.topbar-actions form,
.actions form {
  margin: 0;
}

.content {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 32px 36px 48px;
}

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

.page-heading > :first-child {
  min-width: 0;
}

.page-heading .actions {
  flex-shrink: 0;
  padding-bottom: 3px;
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--green);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.12em;
}

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

.subtitle {
  max-width: 780px;
  margin-bottom: 0;
  font-size: 14px;
  line-height: 1.8;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
input[type="submit"],
input[type="button"],
.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
  font-weight: 550;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease,
    box-shadow 140ms ease;
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
.button:hover,
.button.secondary:hover {
  border-color: #9db4a2;
  color: var(--ink);
  background: var(--surface-soft);
}

.button.primary,
button.primary,
input[type="submit"].primary {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.button.primary:hover,
button.primary:hover,
input[type="submit"].primary:hover {
  border-color: var(--green-hover);
  color: #fff;
  background: var(--green-hover);
}

.button.secondary {
  border-color: var(--border-strong);
  color: var(--ink-soft);
  background: var(--surface);
}

.button.danger,
button.danger,
input[type="submit"].danger {
  border-color: #e1b7af;
  color: var(--danger);
  background: var(--danger-wash);
}

.button.danger:hover,
button.danger:hover,
input[type="submit"].danger:hover {
  border-color: #cb8f83;
  color: #842b25;
  background: #ffe5de;
}

.button.small,
button.small {
  min-height: 32px;
  padding: 5px 11px;
  font-size: 12px;
}

button:disabled,
input[type="submit"]:disabled,
input[type="button"]:disabled,
.button[aria-disabled="true"] {
  opacity: 0.5;
  box-shadow: none;
  cursor: not-allowed;
}

.button svg,
button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.card,
.panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.card-header h2,
.card-header h3,
.card-header p {
  margin-bottom: 0;
}

.card-header h2 {
  font-size: 17px;
}

.card-header .subtitle {
  margin-top: 5px;
  font-size: 12px;
}

.card-body {
  padding: 22px;
}

.metric-grid,
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric,
.stat-card {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-label,
.stat-label {
  margin-bottom: 12px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
}

.metric-value,
.stat-value {
  display: block;
  margin-bottom: 8px;
  color: var(--green-dark);
  font-size: clamp(26px, 2.5vw, 36px);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.metric-note,
.stat-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 22px;
}

.section-stack {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 22px;
}

.table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-color: #b7c7b9 transparent;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.card > .table-wrap:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table-wrap table {
  min-width: 700px;
}

th,
td {
  padding: 13px 18px;
  border-bottom: 1px solid #e7ece5;
  vertical-align: top;
}

th {
  color: var(--ink-soft);
  background: #f5f8f3;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

td {
  color: #354c40;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  line-height: 1.7;
}

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

tbody tr:hover > td {
  background: #fafcf8;
}

td .muted,
td small {
  display: block;
  margin-top: 3px;
}

td .button {
  vertical-align: top;
}

caption {
  padding: 14px 18px;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.badge {
  display: inline-flex;
  max-width: 100%;
  min-height: 25px;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #58675e;
  background: #f1f4ef;
  font-size: 11px;
  font-weight: 550;
  line-height: 1.5;
  vertical-align: middle;
}

.badge.success {
  border-color: #cce0cf;
  color: #2a6243;
  background: #eef6ed;
}

.badge.warning {
  border-color: #ebd9ad;
  color: var(--warning);
  background: var(--warning-wash);
}

.badge.neutral {
  border-color: #dce3dc;
  color: #5b6a60;
  background: #f1f4ef;
}

.badge.danger {
  border-color: #eac8c0;
  color: var(--danger);
  background: var(--danger-wash);
}

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

.empty-state h2,
.empty-state h3 {
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 17px;
}

.empty-state p {
  max-width: 520px;
  margin-right: auto;
  margin-left: auto;
}

.empty-state .actions {
  justify-content: center;
  margin-top: 20px;
}

form {
  margin: 0;
}

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

legend {
  margin-bottom: 18px;
  padding: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
}

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

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

.field {
  min-width: 0;
}

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

label,
.field > label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 550;
  line-height: 1.55;
}

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]):not([type="color"]):not([type="hidden"])),
select,
textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.55;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input::placeholder,
textarea::placeholder {
  color: #8a968d;
  opacity: 1;
}

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"])):hover,
select:hover,
textarea:hover {
  border-color: #9cb1a1;
}

:where(input:not([type="checkbox"]):not([type="radio"])):focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  outline: 0;
  box-shadow: 0 0 0 3px rgb(44 110 76 / 13%);
}

textarea {
  min-height: 112px;
  resize: vertical;
}

select {
  cursor: pointer;
}

select[multiple] {
  min-height: 120px;
}

input[type="checkbox"],
input[type="radio"] {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  margin: 0 6px 0 0;
  accent-color: var(--green);
  vertical-align: middle;
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

input[type="color"] {
  width: 48px;
  height: 40px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  background: var(--surface);
}

input[type="file"] {
  overflow: hidden;
  padding: 6px;
  color: var(--muted);
  font-size: 13px;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 5px 10px;
  border: 0;
  border-radius: 5px;
  color: var(--green-dark);
  background: var(--green-wash);
  font: inherit;
  cursor: pointer;
}

input:disabled,
select:disabled,
textarea:disabled {
  color: #7b887e;
  background: #f1f4ee;
  cursor: not-allowed;
}

input[readonly],
textarea[readonly] {
  color: var(--ink-soft);
  background: #f5f7f2;
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: #c67262;
  background: #fffcfb;
}

.field-help,
.helptext {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.field-errors,
.errorlist {
  margin: 7px 0 0;
  padding-left: 18px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.7;
}

.field-errors:empty,
.errorlist:empty {
  display: none;
}

.error-summary {
  margin-bottom: 24px;
  padding: 16px 18px;
  border: 1px solid #e7bdb3;
  border-left: 3px solid #b44e40;
  border-radius: var(--radius-small);
  color: #8c342c;
  background: var(--danger-wash);
}

.error-summary h2,
.error-summary h3,
.error-summary a {
  color: inherit;
}

.error-summary .errorlist {
  margin-top: 8px;
  color: inherit;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.line-formset {
  min-width: 0;
  margin-top: 24px;
}

.line-formset > .line-row {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) repeat(3, minmax(110px, 1fr)) minmax(64px, auto);
  align-items: start;
  gap: 14px;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface-soft);
}

.line-formset table {
  min-width: 800px;
}

.line-formset td {
  min-width: 130px;
  padding: 12px;
}

.line-formset td:first-child {
  min-width: 200px;
}

.line-formset td input,
.line-formset td select {
  min-height: 38px;
  font-size: 13px;
}

.line-formset td label {
  margin-bottom: 0;
}

.checkbox-field,
label.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.65;
}

.checkbox-field input[type="checkbox"],
.checkbox-field input[type="radio"] {
  margin: 3px 0 0;
}

.checkbox-field label {
  margin: 0;
  font-weight: 400;
}

.detail-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  margin: 0;
}

.detail-item,
.summary-grid > div {
  min-width: 0;
}

.detail-item dt,
.summary-grid dt,
.detail-item > .label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.detail-item dd,
.summary-grid dd {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.source-details {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  color: var(--ink-soft);
  background: #f7f9f4;
  font-size: 12px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.source-details summary {
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}

.source-details[open] summary {
  margin-bottom: 12px;
}

.source-details dl {
  margin: 0;
}

.source-details dd {
  margin: 0 0 10px;
}

.source-details code,
.source-details pre {
  font-size: 11px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message {
  margin-bottom: 16px;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-small);
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 13px;
  line-height: 1.8;
}

.message.success {
  border-color: #c5ddc9;
  border-left-color: #558662;
  color: #315b3d;
  background: #f0f7ee;
}

.message.warning {
  border-color: #e8d6a8;
  border-left-color: #b58b3b;
  color: var(--warning);
  background: var(--warning-wash);
}

.message.error {
  border-color: #e7bdb3;
  border-left-color: #b44e40;
  color: var(--danger);
  background: var(--danger-wash);
}

.message.info {
  border-color: #cddfe7;
  border-left-color: #6c98ab;
  color: var(--info);
  background: var(--info-wash);
}

.message a {
  color: inherit;
  font-weight: 550;
}

.auth-layout {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 40px 20px;
  background: #edf2e9;
}

.auth-card {
  width: min(100%, 440px);
  padding: 36px;
  border: 1px solid #d5e0d3;
  border-top: 4px solid var(--green);
  border-radius: 18px;
  background: #fffefb;
  box-shadow: 0 18px 60px rgb(34 65 42 / 8%);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
  color: var(--green-dark);
  font-size: 20px;
  font-weight: 650;
}

.auth-brand .brand-mark {
  border-color: #c9d9ca;
  color: var(--green-dark);
  background: var(--green-wash);
}

.auth-brand .brand-subtitle {
  color: var(--muted);
}

.auth-copy {
  margin-bottom: 26px;
  color: var(--muted);
}

.auth-copy h1 {
  margin-bottom: 8px;
  font-size: 26px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-form > p {
  margin-bottom: 0;
}

.auth-form .button,
.auth-form > button,
.auth-form > input[type="submit"] {
  width: 100%;
  min-height: 44px;
}

.auth-form .form-actions {
  margin-top: 0;
  padding-top: 4px;
  border-top: 0;
}

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

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  color: var(--muted);
  font-size: 12px;
}

.pagination nav,
.pagination .pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.pagination a,
.pagination .current {
  display: inline-flex;
  min-width: 32px;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  text-decoration: none;
}

.pagination a:hover {
  border-color: #aec6b2;
  background: var(--green-wash);
}

.pagination .current,
.pagination [aria-current="page"] {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
  padding: 15px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  color: var(--ink-soft);
  background: #edf3e9;
  font-size: 13px;
}

.summary-strip strong {
  color: var(--green-dark);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.danger-zone {
  margin-top: 28px;
  padding: 22px;
  border: 1px solid #e8c9c0;
  border-radius: var(--radius);
  background: #fffaf7;
}

.danger-zone h2,
.danger-zone h3 {
  color: var(--danger);
}

/* Small helpers for identifiers, numeric amounts, and natural long text. */
.number,
.text-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.text-center {
  text-align: center;
}

.nowrap {
  white-space: nowrap;
}

.wrap-text {
  overflow-wrap: anywhere;
  white-space: normal;
}

.identifier,
code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}

.filter-form .field {
  flex: 1 1 180px;
}

.filter-form .field.grow {
  flex-grow: 2;
}

.filter-form .actions {
  flex: 0 0 auto;
  padding-bottom: 1px;
}

.visually-muted {
  color: var(--muted);
  font-weight: 400;
}

/* The server-rendered ledger templates use these panel and dashboard names. */
.panel {
  margin-bottom: 22px;
  padding: 22px;
}

.panel:last-child,
.two-column > .panel,
.section-stack > .panel {
  margin-bottom: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-heading > :first-child {
  min-width: 0;
}

.panel-heading h2,
.panel-heading h3,
.panel-heading p {
  margin-bottom: 0;
}

.panel-heading p {
  margin-top: 6px;
  font-size: 13px;
}

.panel > .table-wrap {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.panel > .table-wrap:first-child {
  margin-top: 0;
}

.panel > .pagination {
  padding-right: 0;
  padding-bottom: 0;
  padding-left: 0;
}

.two-column .table-wrap table {
  min-width: 420px;
}

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

.quick-card {
  display: flex;
  min-width: 0;
  min-height: 128px;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
  padding: 20px 18px;
  border: 1px solid #dce5d8;
  border-radius: 10px;
  color: var(--green-dark);
  background: #f6f9f2;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.quick-card:hover {
  border-color: #9ebb9f;
  color: var(--green-hover);
  background: #eef5e9;
}

.quick-card strong {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
}

.quick-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.stat-note {
  margin: 0;
}

.notice {
  margin: 18px 0 22px;
  padding: 14px 17px;
  border: 1px solid #d6e2cf;
  border-left: 3px solid #88a57d;
  border-radius: var(--radius-small);
  color: #4a6344;
  background: #f0f5eb;
  font-size: 13px;
  line-height: 1.85;
}

.notice.warning {
  border-color: #e8d6a8;
  border-left-color: #b58b3b;
  color: var(--warning);
  background: var(--warning-wash);
}

.notice:first-child {
  margin-top: 0;
}

.notice:last-child {
  margin-bottom: 0;
}

.notice a {
  color: inherit;
  font-weight: 550;
}

.summary-grid {
  margin-bottom: 22px;
}

.preserve-lines {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.block {
  display: block;
}

.small {
  font-size: 12px;
}

.details {
  min-width: 0;
  margin: 9px 0;
}

.details > summary,
td details > summary {
  color: var(--green);
  font-size: 12px;
  font-weight: 550;
  line-height: 1.8;
  cursor: pointer;
}

.details[open] > summary,
td details[open] > summary {
  margin-bottom: 12px;
}

.details > form {
  display: grid;
  gap: 16px;
  margin-top: 14px;
}

.details dl {
  margin: 12px 0;
}

.details dt {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.details dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.source-json {
  max-width: 100%;
  max-height: 420px;
  margin: 12px 0 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  color: #405249;
  background: #f3f6f1;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.8;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.filter-form .search-field {
  flex: 1 1 380px;
}

.line-formset {
  margin-top: 0;
}

.line-formset > .line-row {
  display: block;
  padding: 0;
  overflow: hidden;
  background: var(--surface);
}

.line-row > .card-header {
  min-height: 56px;
  padding: 13px 18px;
  background: var(--surface-soft);
}

.line-row > .form-grid {
  padding: 18px;
}

.line-row > .error-summary {
  margin: 18px 18px 0;
}

.line-card {
  margin-top: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface-soft);
}

.line-card > .button:last-child {
  margin-top: 18px;
}

.field.checkbox-field {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 6px 8px;
}

.field.checkbox-field > label {
  grid-column: 2;
  grid-row: 1;
  margin-bottom: 0;
}

.field.checkbox-field > input {
  grid-column: 1;
  grid-row: 1;
  margin: 3px 0 0;
}

.field.checkbox-field > .field-help,
.field.checkbox-field > .field-errors {
  grid-column: 2;
  margin-top: 0;
}

.site-footer {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.workspace > .site-footer {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 36px 26px;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.site-footer a:hover {
  color: var(--green);
  text-decoration: underline;
}

.site-footer > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.auth-card > .site-footer {
  justify-content: center;
  gap: 6px 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
}

@media (max-width: 1200px) {
  :root {
    --sidebar-width: 218px;
  }

  .content {
    padding: 28px 26px 40px;
  }

  .topbar {
    padding-right: 26px;
    padding-left: 26px;
  }

  .workspace > .site-footer {
    padding-right: 26px;
    padding-left: 26px;
  }

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

  .form-grid.three,
  .detail-grid,
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .line-formset > .line-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  html {
    scroll-padding-top: 24px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    height: auto;
    padding: 16px 20px 0;
    overflow: visible;
  }

  .brand {
    margin: 0 0 14px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    border-radius: 10px;
    font-size: 18px;
  }

  .brand-title {
    font-size: 18px;
  }

  .brand-subtitle {
    font-size: 10px;
  }

  .nav {
    flex-direction: row;
    gap: 4px;
    margin-right: -20px;
    margin-left: -20px;
    padding: 0 14px 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-color: #6e8c79 transparent;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .nav-link {
    min-height: 40px;
    flex: 0 0 auto;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  .nav-link.active::before,
  .nav-link[aria-current="page"]::before {
    top: auto;
    right: 12px;
    bottom: 0;
    left: 12px;
    width: auto;
    height: 2px;
    border-radius: 2px 2px 0 0;
  }

  .sidebar-footer {
    position: absolute;
    top: 18px;
    right: 20px;
    display: flex;
    max-width: 40%;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 0;
  }

  .sidebar-footer > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar .brand {
    max-width: calc(100% - 135px);
  }

  .topbar {
    position: relative;
    min-height: 62px;
    padding: 12px 20px;
  }

  .content {
    padding: 26px 20px 40px;
  }

  .workspace > .site-footer {
    padding-right: 20px;
    padding-left: 20px;
  }

  .two-column {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .page-heading .actions {
    flex-shrink: 1;
    justify-content: flex-end;
  }
}

@media (max-width: 600px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
  }

  .topbar-title {
    padding-top: 4px;
    font-size: 12px;
  }

  .topbar-actions {
    gap: 7px;
    font-size: 12px;
  }

  .content {
    padding: 22px 16px 32px;
  }

  .workspace > .site-footer {
    gap: 6px 12px;
    padding: 0 16px 22px;
  }

  .page-heading {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 22px;
  }

  .page-heading .actions {
    width: 100%;
    justify-content: flex-start;
    padding-bottom: 0;
  }

  h1 {
    font-size: 25px;
  }

  .subtitle {
    font-size: 13px;
  }

  .metric-grid,
  .stat-grid {
    gap: 10px;
    margin-bottom: 20px;
  }

  .metric,
  .stat-card {
    padding: 16px;
    border-radius: 11px;
  }

  .metric-label,
  .stat-label {
    margin-bottom: 10px;
    font-size: 12px;
  }

  .metric-value,
  .stat-value {
    font-size: 26px;
  }

  .metric-note,
  .stat-note {
    font-size: 11px;
  }

  .card-header {
    min-height: 60px;
    flex-wrap: wrap;
    padding: 16px;
  }

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

  .section-stack,
  .two-column {
    gap: 18px;
  }

  .form-grid,
  .form-grid.three,
  .detail-grid,
  .summary-grid,
  .quick-grid,
  .line-formset > .line-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }

  .line-formset > .line-row {
    padding: 0;
  }

  .line-row > .form-grid,
  .line-card {
    padding: 16px;
  }

  .panel {
    margin-bottom: 18px;
    padding: 18px 16px;
  }

  .panel-heading {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
  }

  .quick-grid {
    gap: 10px;
  }

  .quick-card {
    min-height: 100px;
    padding: 17px;
  }

  .sidebar-footer > span {
    display: none;
  }

  .sidebar .brand {
    max-width: calc(100% - 80px);
  }

  .sidebar-footer {
    right: 16px;
  }

  .form-actions .button,
  .form-actions > button,
  .form-actions > input[type="submit"] {
    flex: 1 1 auto;
  }

  .filter-form {
    gap: 12px;
  }

  .filter-form .field,
  .filter-form .actions {
    flex: 1 1 100%;
  }

  .filter-form .actions .button,
  .filter-form .actions button {
    flex: 1;
  }

  .pagination {
    align-items: flex-start;
    padding: 14px 16px;
  }

  .summary-strip {
    gap: 8px 18px;
    padding: 14px 16px;
    font-size: 12px;
  }

  .empty-state {
    padding: 34px 18px;
  }

  .auth-layout {
    padding: 24px 16px;
  }

  .auth-card {
    padding: 28px 24px;
    border-radius: 14px;
  }

  .auth-brand {
    margin-bottom: 26px;
  }

  .danger-zone {
    padding: 18px 16px;
  }
}

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

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

@media print {
  :root {
    --ink: #111;
    --ink-soft: #333;
    --muted: #555;
    --border: #ccc;
  }

  html,
  body,
  .workspace,
  .card,
  .panel,
  .metric,
  .stat-card {
    background: #fff;
  }

  .app-shell {
    display: block;
  }

  .sidebar,
  .topbar,
  .page-heading > .actions,
  .form-actions,
  .pagination,
  .no-print {
    display: none !important;
  }

  .content {
    max-width: none;
    padding: 0;
  }

  .card,
  .panel,
  .metric,
  .stat-card {
    box-shadow: none;
  }

  .table-wrap {
    overflow: visible;
  }

  .table-wrap table {
    min-width: 0;
  }

  th,
  td {
    padding: 7px;
    font-size: 10px;
    overflow-wrap: anywhere;
  }

  thead {
    display: table-header-group;
  }

  tr,
  .metric,
  .stat-card,
  .detail-item,
  .source-details {
    break-inside: avoid;
  }

  a {
    color: inherit;
  }
}
