:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-soft: #f8f9fb;
  --text: #20242a;
  --muted: #68707c;
  --line: #dfe3e8;
  --primary: #244e78;
  --primary-dark: #183a5c;
  --attention: #a34a00;
  --attention-bg: #fff2e5;
  --success: #236b3d;
  --success-bg: #eaf7ef;
  --danger: #a12d2d;
  --danger-bg: #fdecec;
  --radius: 0.8rem;
  --shadow: 0 0.35rem 1.5rem rgb(25 35 45 / 7%);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 0.96rem;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
a { color: var(--primary); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 94%);
  backdrop-filter: blur(12px);
}

.site-header__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.65rem 1.5rem 0;
}

.site-header__top {
  display: flex;
  align-items: center;
}

.brand {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav-areas,
.nav-tabs {
  display: flex;
  gap: 0.3rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.nav-areas { margin-top: 0.7rem; }
.nav-tabs { margin-top: 0.35rem; }

.nav-areas__link,
.nav-tab {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.4rem 0.7rem;
  border-bottom: 0.2rem solid transparent;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.nav-areas__link:hover,
.nav-tab:hover { color: var(--primary); }

.nav-areas__link.is-active {
  border-bottom-color: var(--primary);
  color: var(--primary-dark);
}

.nav-tab {
  min-height: 2rem;
  border: 1px solid transparent;
  border-radius: 0.5rem 0.5rem 0 0;
  font-size: 0.88rem;
}

.nav-tab.is-active {
  border-color: var(--line);
  border-bottom-color: var(--surface);
  background: var(--surface);
  color: var(--primary-dark);
}

.account-menu {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--muted);
}
.account-menu form { margin: 0; }

.page-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 4rem;
}

.card {
  background: var(--surface);
  border: 1px solid rgb(223 227 232 / 90%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.product-history-card { margin-bottom: 1rem; padding: 1.25rem; }
.product-history-card h2, .product-history-card h3 { margin-top: 0; }
.product-history-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; margin: 0 0 1rem; }
.product-history-summary dt { color: var(--muted); font-size: .86rem; }
.product-history-summary dd { margin: .15rem 0 0; font-size: 1.15rem; font-weight: 700; }
.seasonality-chart { display: grid; gap: .35rem; margin: 1rem 0 1.5rem; }
.seasonality-chart__row { display: grid; grid-template-columns: 4.5rem minmax(8rem, 1fr) 5.5rem; gap: .6rem; align-items: center; font-size: .86rem; }
.seasonality-chart__track { height: .8rem; overflow: hidden; border-radius: .2rem; background: var(--surface-soft); }
.seasonality-chart__bar { display: block; height: 100%; }
.seasonality-chart__bar--positive { background: var(--primary); }
.seasonality-chart__bar--negative { background: var(--danger); }
.seasonality-chart__quantity--negative { color: var(--danger); }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.page-heading h1 { margin: 0.2rem 0 0.35rem; font-size: clamp(1.8rem, 3vw, 2.55rem); line-height: 1.15; }
.page-heading--document { align-items: center; }
.eyebrow { margin: 0; color: var(--primary); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
.muted { margin-top: 0.2rem; color: var(--muted); }
.summary-chip { padding: 0.55rem 0.8rem; border-radius: 999px; background: #eaf0f6; color: var(--primary-dark); font-weight: 750; white-space: nowrap; }

.filter-card { padding: 1rem; margin-bottom: 1rem; }
.filter-grid { display: grid; grid-template-columns: minmax(14rem, 2fr) repeat(2, minmax(10rem, 1fr)); gap: 0.9rem 1rem; align-items: end; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label, .field-label { color: #4e5661; font-size: 0.82rem; font-weight: 750; }
.field input, .field select, .field textarea, .form-stack input, .form-stack textarea, .form-stack select {
  width: 100%;
  min-height: 2.65rem;
  padding: 0.62rem 0.75rem;
  border: 1px solid #cbd1d8;
  border-radius: 0.55rem;
  background: #fff;
  color: var(--text);
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid rgb(36 78 120 / 13%); border-color: var(--primary); }

.check-field { display: flex; align-items: center; gap: 0.55rem; min-height: 2.65rem; color: #4e5661; font-weight: 650; }
.check-field input { width: 1.05rem; height: 1.05rem; }
.check-field--boxed { align-items: flex-start; padding: 0.8rem; border: 1px solid var(--line); border-radius: 0.55rem; background: var(--surface-soft); }
.check-field--boxed span { display: flex; flex-direction: column; }
.check-field--boxed small { color: var(--muted); font-weight: 400; }
.filter-actions { display: flex; gap: 0.55rem; justify-content: flex-end; }

.button {
  display: inline-flex;
  min-height: 2.55rem;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}
.button--primary { background: var(--primary); color: #fff; }
.button--primary:hover { background: var(--primary-dark); }
.button--quiet { border-color: var(--line); background: #fff; color: #4f5965; }
.button--quiet:hover { background: #f5f7f9; }
.button--small { min-height: 2.05rem; padding: 0.35rem 0.65rem; font-size: 0.84rem; }
.button--wide { width: 100%; }

.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
.document-table { width: 100%; border-collapse: collapse; }
.document-table th { padding: 0.75rem 0.9rem; background: #f4f6f8; color: #5f6874; font-size: 0.76rem; text-align: left; text-transform: uppercase; letter-spacing: 0.045em; white-space: nowrap; }
.document-table td { padding: 0.85rem 0.9rem; border-top: 1px solid #e8ebee; vertical-align: middle; }
.document-row:hover td { background: #f9fbfd; }
.document-row--attention td:first-child { box-shadow: inset 0.22rem 0 var(--attention); }
.document-link { color: var(--primary-dark); font-weight: 800; text-decoration: none; }
.document-link:hover { text-decoration: underline; }
.secondary-line { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.8rem; }
.align-right { text-align: right !important; }
.nowrap { white-space: nowrap; }

.badge { display: inline-flex; align-items: center; max-width: 16rem; padding: 0.24rem 0.5rem; border-radius: 999px; font-size: 0.77rem; font-weight: 750; line-height: 1.25; }
.badge--employee { background: #eaf0f6; color: var(--primary-dark); }
.badge--muted { background: #eef0f2; color: #65707b; }
.badge--attention { background: var(--attention-bg); color: var(--attention); }
.badge--large { padding: 0.45rem 0.72rem; font-size: 0.86rem; }
.note-count { color: var(--muted); font-size: 0.8rem; }
.missing-value { color: #8a5353; font-style: italic; }
.inline-bonus-income-form {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  min-width: 11.5rem;
}
.inline-bonus-income-form input {
  width: 5.5rem;
  min-height: 2.05rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #cbd1d8;
  border-radius: 0.5rem;
  text-align: right;
}
.inline-bonus-income-form input:focus {
  outline: 3px solid rgb(36 78 120 / 13%);
  border-color: var(--primary);
}
.empty-state { padding: 2.5rem 1rem !important; color: var(--muted); text-align: center; }
.empty-state--compact { padding: 1rem !important; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; padding: 1rem; border-top: 1px solid var(--line); color: var(--muted); }

.back-link { display: inline-block; margin-bottom: 1rem; color: var(--muted); font-weight: 700; text-decoration: none; }
.back-link:hover { color: var(--primary); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(19rem, 0.7fr); gap: 1rem; margin-bottom: 1rem; }
.detail-card { padding: 1.25rem; margin-bottom: 1rem; }
.detail-card h2 { margin: 0 0 1rem; font-size: 1.15rem; }
.data-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; }
.data-list div { padding: 0.72rem 0; border-bottom: 1px solid #edf0f2; }
.data-list div:nth-child(odd) { padding-right: 1rem; }
.data-list dt { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.data-list dd { margin: 0.12rem 0 0; }
.assignment-box { display: flex; flex-direction: column; gap: 0.3rem; padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.form-stack { display: flex; flex-direction: column; gap: 0.9rem; }
.compact-form { max-width: 30rem; }
.optional { color: var(--muted); font-weight: 400; }
.read-only-value { display: flex; flex-direction: column; gap: 0.3rem; }
.read-only-value strong { font-size: 1.45rem; }
.read-only-value span, .read-only-value small, .metadata { color: var(--muted); }
.metadata { margin-bottom: 0; font-size: 0.8rem; }

.section-heading { display: flex; justify-content: space-between; align-items: start; }
.notes-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.8fr); gap: 1.25rem; }
.notes-list { display: flex; flex-direction: column; gap: 0.7rem; }
.note { padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: 0.65rem; background: var(--surface-soft); }
.note__meta { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: 0.8rem; }
.note__meta strong { color: var(--text); }
.note p { margin: 0.55rem 0 0; }
.note-form { padding-left: 1.25rem; border-left: 1px solid var(--line); }

.action-list { display: flex; flex-direction: column; gap: 0.65rem; }
.action-item { display: flex; justify-content: space-between; gap: 1rem; padding: 0.9rem; border: 1px solid var(--line); border-radius: 0.65rem; }
.action-item--open { border-color: #e8bb8d; background: #fffaf4; }
.action-item__title { display: flex; align-items: center; gap: 0.55rem; }
.action-item p { margin: 0.45rem 0; }
.action-item small { color: var(--muted); }
.document-table--compact th, .document-table--compact td { padding: 0.65rem 0.75rem; }

.messages { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.message { padding: 0.8rem 1rem; border-radius: 0.6rem; border: 1px solid var(--line); background: #eef3f8; }
.message--success { border-color: #b9dfc5; background: var(--success-bg); color: var(--success); }
.message--error { border-color: #efc0c0; background: var(--danger-bg); color: var(--danger); }

.login-shell { min-height: calc(100vh - 4.5rem); display: grid; place-items: center; }
.login-card { width: min(100%, 27rem); padding: 2rem; }
.login-card h1 { margin: 0.3rem 0; }
.login-card input { width: 100%; min-height: 2.75rem; padding: 0.65rem 0.75rem; border: 1px solid #cbd1d8; border-radius: 0.55rem; }

@media (max-width: 900px) {
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .field--wide { grid-column: 1 / -1; }
  .detail-grid, .notes-layout { grid-template-columns: 1fr; }
  .note-form { padding-left: 0; padding-top: 1rem; border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 640px) {
  .site-header__inner { padding: 0.65rem 1rem 0; }
  .site-header__top { gap: 0.8rem; }
  .nav-areas, .nav-tabs { margin-right: -1rem; padding-right: 1rem; }
  .account-menu span { display: none; }
  .page-shell { padding: 1.5rem 0.75rem 3rem; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 0.6rem; }
  .filter-grid { grid-template-columns: 1fr; }
  .field--wide { grid-column: auto; }
  .filter-actions { justify-content: stretch; }
  .filter-actions .button { flex: 1; }
  .data-list { grid-template-columns: 1fr; }
  .data-list div:nth-child(odd) { padding-right: 0; }
  .note__meta, .action-item { flex-direction: column; }
}
