* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-ui); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--forest); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); display: flex; flex-direction: column; padding: 24px 18px; background: var(--surface); border-right: 1px solid var(--line); z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--forest); font-size: 17px; font-weight: 700; margin: 0 4px 28px; }
.brand-mark { width: 32px; height: 32px; display: inline-grid; place-items: center; color: #fff; background: var(--forest); border: 1px solid var(--forest); border-radius: 4px; font-weight: 700; }
.brand-mark.large { width: 48px; height: 48px; font-size: 20px; }
.side-nav { display: flex; flex: 1; flex-direction: column; gap: 3px; }
.nav-label { margin: 8px 10px 5px; color: var(--muted); font-size: 11px; font-weight: 650; }
.nav-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.nav-link { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 9px 12px; color: var(--ink); border-radius: 4px; transition: background var(--duration-fast) var(--ease-out); }
.nav-link span { width: 18px; text-align: center; color: var(--muted); font-family: var(--font-mono); }
.nav-link:hover { background: var(--surface-muted); }
.nav-link.is-active { color: var(--forest); background: var(--forest-soft); font-weight: 650; }
.nav-link.is-active span { color: var(--forest); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 16px 4px 0; border-top: 1px solid var(--line); }
.avatar { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--forest); font-weight: 700; }
.user-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.user-copy strong, .user-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy small { color: var(--muted); font-size: 11px; }
.icon-link { width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); }
.logout-button { padding: 0; background: transparent; border: 0; cursor: pointer; }
.sidebar-user form { margin: 0; }
.main-area { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; top: 0; z-index: 10; min-height: var(--topbar-height); display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 10px 28px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 18px; line-height: 1.3; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; gap: 8px; }
.page-content { width: 100%; max-width: var(--content-max); padding: 28px; }
.content-narrow { max-width: 1000px; }
.content-narrow.small { max-width: 680px; }
.mobile-header, .mobile-nav { display: none; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.form-panel { padding: 24px; }
.form-panel > h2 { margin: 0 0 18px; font-size: 16px; }
.form-stack { display: grid; gap: 22px; }
.form-grid { display: grid; gap: 20px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-group { min-width: 0; }
.field-group > label, .filter-bar label { display: block; margin-bottom: 6px; color: var(--ink); font-size: 13px; font-weight: 650; }
label em { color: var(--coral); font-style: normal; }
.form-control { width: 100%; min-height: 44px; padding: 9px 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; outline: none; transition: border-color var(--duration-fast), outline var(--duration-fast); }
.form-control:focus { border-color: var(--forest); outline: 2px solid color-mix(in srgb, var(--forest) 22%, transparent); }
.form-control:disabled { color: var(--muted); background: var(--surface-muted); }
textarea.form-control { min-height: 112px; resize: vertical; }
input[type=checkbox].form-control { width: 18px; min-height: 18px; accent-color: var(--forest); }
.select-wrap { margin-top: 8px; }
.input-suffix { position: relative; }
.input-suffix .form-control { padding-right: 58px; }
.input-suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; pointer-events: none; }
.field-help { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.field-error, .form-error { margin: 5px 0 0; color: var(--coral); font-size: 12px; }
.form-error { padding: 10px 12px; background: var(--coral-soft); border: 1px solid color-mix(in srgb, var(--coral) 35%, white); border-radius: 4px; }
.errorlist { margin: 0; padding-left: 18px; }
.item-info { display: grid; grid-template-columns: 1fr .7fr 2.3fr; gap: 20px; margin-top: 14px; padding: 16px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: 4px; }
.item-info small { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.item-info strong, .item-info p { margin: 0; }
.item-interpretation { padding-left: 18px; border-left: 1px solid var(--line); }
.form-actions { display: flex; flex-direction: row-reverse; gap: 10px; padding-top: 6px; }
.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 9px 18px; border: 1px solid transparent; border-radius: 4px; cursor: pointer; font-weight: 650; transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast); }
.btn-primary { color: white; background: var(--forest); border-color: var(--forest); }
.btn-primary:hover { background: var(--forest-hover); }
.btn-secondary { color: var(--forest); background: var(--surface); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--forest-soft); }
.btn-block { width: 100%; }
.notice { display: flex; gap: 10px; margin-bottom: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 4px; }
.notice.warning { background: var(--gold-soft); }
.notice.compact { align-items: flex-start; margin-top: 14px; margin-bottom: 0; font-size: 12px; }
.notice.compact strong { color: var(--gold); white-space: nowrap; }
.message-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.message { padding: 10px 14px; border: 1px solid var(--line); background: var(--surface); border-radius: 4px; }
.message.success { color: var(--mint); background: var(--mint-soft); }
.message.error { color: var(--coral); background: var(--coral-soft); }
.filter-bar { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)) auto; align-items: end; gap: 12px; margin-bottom: 18px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.stats-filter { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.filter-bar .btn { align-self: end; }
.table-panel { overflow: hidden; }
.panel-heading { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 16px; }
.panel-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.count-badge, .status-badge { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 4px; font-size: 11px; white-space: nowrap; }
.status-badge.success { color: var(--mint); background: var(--mint-soft); }
.status-badge.danger { color: var(--coral); background: var(--coral-soft); }
.status-badge.muted { color: var(--muted); background: var(--surface-muted); }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 10px 14px; color: var(--muted); background: var(--surface-muted); border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; font-weight: 650; white-space: nowrap; }
.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table small { color: var(--muted); }
.row-actions { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.row-actions form { margin: 0; }
.link-button { padding: 0; color: var(--forest); background: none; border: 0; cursor: pointer; }
.link-button.danger { color: var(--coral); }
.empty-state { min-height: 130px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 28px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); }
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi-card { min-height: 106px; display: flex; flex-direction: column; justify-content: space-between; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.kpi-card > span { color: var(--muted); font-size: 12px; }
.kpi-card strong { color: var(--forest); font-family: var(--font-mono); font-size: 27px; line-height: 1.2; }
.kpi-card strong.small-kpi { font-family: var(--font-ui); font-size: 18px; }
.kpi-card strong small { font-family: var(--font-ui); font-size: 12px; }
.project-stats { display: grid; gap: 16px; }
.project-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.project-heading h2 { margin: 2px 0 0; font-size: 18px; }
.eyebrow { margin: 0; color: var(--muted); font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; }
.project-totals { display: flex; gap: 28px; }
.project-totals span { display: flex; flex-direction: column; }
.project-totals small { color: var(--muted); font-size: 11px; }
.project-totals strong { color: var(--forest); font-family: var(--font-mono); }
.split-layout { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(0, 1.5fr); gap: 18px; align-items: start; }
.catalog-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.inline-create { display: grid; grid-template-columns: minmax(160px, 1fr) auto auto; gap: 10px; align-items: end; }
.inline-create .field-group:nth-of-type(2) { align-self: center; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip { padding: 5px 9px; color: var(--forest); background: var(--forest-soft); border: 1px solid var(--line); border-radius: 4px; font-size: 12px; }
.chip.is-muted { color: var(--muted); background: var(--surface-muted); }
.muted { color: var(--muted); }
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--paper); }
.auth-wrap { width: min(900px, 100%); display: grid; grid-template-columns: 1.1fr .9fr; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.auth-intro { min-height: 520px; display: flex; flex-direction: column; justify-content: center; padding: 48px; color: white; background: var(--forest); }
.auth-intro .brand-mark { color: var(--forest); background: white; }
.auth-intro .eyebrow { margin-top: 54px; color: #dbe8e0; }
.auth-intro h1 { margin: 8px 0 12px; font-size: 34px; }
.auth-intro p { max-width: 360px; color: #e7efe9; }
.auth-card { display: flex; flex-direction: column; justify-content: center; gap: 28px; padding: 40px; }
.auth-card h2 { margin: 3px 0; font-size: 22px; }
.auth-help { margin: 0; color: var(--muted); font-size: 12px; text-align: center; }
@media (max-width: 1100px) {
  .filter-bar { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .catalog-quick { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  body { padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); }
  .sidebar, .topbar { display: none; }
  .main-area { margin-left: 0; min-height: auto; }
  .mobile-header { position: sticky; top: 0; z-index: 20; min-height: var(--mobile-topbar-height); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .mobile-brand { font-size: 16px; font-weight: 700; }
  .mobile-user { max-width: 50%; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-nav { position: fixed; inset: auto 0 0 0; z-index: 30; height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
  .mobile-nav a { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); }
  .mobile-nav a span { font-family: var(--font-mono); font-size: 18px; line-height: 1; }
  .mobile-nav a small { font-size: 10px; }
  .mobile-nav a.is-active { color: var(--forest); font-weight: 700; }
  .page-content { padding: 12px; }
  .form-panel { padding: 16px; }
  .form-grid.three, .item-info, .kpi-grid, .split-layout { grid-template-columns: 1fr; }
  .item-interpretation { padding: 12px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; min-height: 48px; }
  .filter-bar { grid-template-columns: 1fr 1fr; padding: 12px; }
  .filter-bar .btn { grid-column: 1 / -1; width: 100%; }
  .panel-heading { padding: 14px; }
  .responsive-table thead { display: none; }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
  .responsive-table tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .responsive-table tr:last-child { border-bottom: 0; }
  .responsive-table td { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 5px 0; border: 0; }
  .responsive-table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; }
  .responsive-table td[colspan] { display: block; }
  .responsive-table td[colspan]::before { display: none; }
  .project-heading { align-items: flex-start; padding: 14px; }
  .project-totals { gap: 14px; text-align: right; }
  .inline-create { grid-template-columns: 1fr; }
  .top-actions .btn { min-height: 40px; padding: 7px 12px; }
  .auth-body { padding: 12px; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-intro { min-height: auto; padding: 28px; }
  .auth-intro .eyebrow { margin-top: 28px; }
  .auth-intro h1 { font-size: 26px; }
  .auth-card { padding: 28px 20px; }
}
@media (max-width: 420px) {
  .filter-bar { grid-template-columns: 1fr; }
  .project-heading { flex-direction: column; }
  .project-totals { width: 100%; justify-content: space-between; text-align: left; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0ms !important; animation-duration: 0ms !important; } }
