:root {
  color-scheme: light;
  --ink: #172235;
  --muted: #68758a;
  --line: #dfe5ec;
  --surface: #ffffff;
  --canvas: #f3f6f8;
  --navy: #152d4b;
  --navy-2: #20466f;
  --mint: #27b58a;
  --mint-soft: #e7f7f1;
  --amber: #e99d30;
  --amber-soft: #fff3df;
  --red: #c54a57;
  --shadow: 0 18px 48px rgba(26, 42, 65, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

.topbar {
  height: 76px;
  padding: 0 clamp(20px, 4vw, 60px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  background: linear-gradient(145deg, var(--navy-2), var(--navy));
  box-shadow: 0 7px 18px rgba(21, 45, 75, 0.25);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; }
.nav-actions { display: flex; align-items: center; gap: 22px; font-size: 14px; font-weight: 650; }
.nav-actions a, .link-button { color: #4f5d70; text-decoration: none; }
.nav-actions a:hover, .link-button:hover { color: var(--navy); }
.nav-actions form { margin: 0; }
.link-button { border: 0; background: none; padding: 0; }

.page-shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 60px; }
.page-heading, .form-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 8px 0 26px;
}
.page-heading h1, .form-heading h1 { margin: 3px 0 6px; font-size: clamp(30px, 4vw, 47px); letter-spacing: -0.045em; }
.page-heading p:not(.eyebrow) { margin: 0; color: var(--muted); }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .15em; font-size: 11px; font-weight: 800; color: var(--mint); }

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 750;
  font-size: 14px;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--navy); box-shadow: 0 8px 22px rgba(21, 45, 75, .18); }
.button-primary:hover { background: #0d223b; }
.button-secondary { color: var(--navy); background: #eef2f6; border-color: #d9e1e9; }
.button-ghost { color: #536174; background: transparent; border-color: var(--line); }
.button-light { background: white; color: var(--navy); }
.button-small { min-height: 34px; padding: 7px 11px; font-size: 12px; }
.button-wide { width: 100%; }

.security-notice {
  margin-bottom: 24px;
  padding: 14px 16px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--amber-soft);
  border: 1px solid #f3d6a7;
  color: #704815;
}
.security-notice strong, .security-notice span { display: block; }
.security-notice span { margin-top: 2px; font-size: 13px; }
.flash-stack { position: fixed; top: 88px; right: 20px; z-index: 50; display: grid; gap: 8px; width: min(380px, calc(100% - 40px)); }
.flash { padding: 13px 15px; border-radius: 12px; box-shadow: var(--shadow); background: white; border-left: 4px solid var(--navy); font-size: 14px; }
.flash-success { border-color: var(--mint); }
.flash-error { border-color: var(--red); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card {
  min-height: 146px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(28, 45, 68, .045);
}
.metric-card span { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.metric-card strong { margin: 10px 0 4px; font-size: clamp(24px, 2.6vw, 34px); letter-spacing: -.035em; }
.metric-card small { color: #8a95a5; }
.metric-primary { color: white; background: linear-gradient(140deg, #18385c, #10263f); border: 0; }
.metric-primary span, .metric-primary small { color: #b9cbe0; }

.progress-card, .inventory-card, .editor-card {
  margin-top: 18px;
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.progress-head, .inventory-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.progress-head h2, .inventory-head h2, .compact-card h2 { margin: 4px 0 0; font-size: 24px; letter-spacing: -.025em; }
.target-form { display: flex; align-items: flex-end; gap: 9px; }
label > span:first-child { display: block; margin-bottom: 6px; color: #566376; font-size: 12px; font-weight: 750; }
input, select, textarea {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  border: 1px solid #cfd8e2;
  border-radius: 10px;
  color: var(--ink);
  background: white;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #4e87bc; box-shadow: 0 0 0 3px rgba(61, 119, 174, .12); }
textarea { resize: vertical; }
.input-with-suffix { position: relative; display: block; }
.input-with-suffix input { padding-right: 38px; }
.input-with-suffix b { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.target-form input { width: 180px; }
.progress-group { margin-top: 23px; }
.progress-label { margin-bottom: 7px; display: flex; justify-content: space-between; gap: 15px; font-size: 13px; }
.progress-track { height: 14px; border-radius: 99px; overflow: hidden; background: #e8edf2; }
.progress-fill { display: block; width: 0; height: 100%; border-radius: inherit; transition: width .7s cubic-bezier(.2,.8,.2,1); }
.progress-actual { background: linear-gradient(90deg, #17956e, var(--mint)); }
.progress-theoretical { background: linear-gradient(90deg, #d78922, #f0b75e); }
.progress-track-soft { background: #f6ead8; }
.empty-progress { margin: 22px 0 0; padding: 16px; border-radius: 12px; background: #f4f7f9; color: var(--muted); }

.status-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.status-chip { padding: 8px 11px; border-radius: 99px; text-decoration: none; font-size: 12px; font-weight: 700; }
.status-chip b { margin-right: 4px; }
.status-open { background: #edf1f5; color: #566579; }
.status-listed { background: var(--amber-soft); color: #8a5917; }
.status-sold { background: var(--mint-soft); color: #167558; }
.filter-bar { margin: 24px 0 12px; padding: 13px; display: flex; gap: 10px; align-items: center; background: #f5f7f9; border-radius: 14px; }
.search-field { flex: 1; }
.filter-bar select { min-width: 150px; }
.clear-link { color: #50647c; font-weight: 700; font-size: 13px; text-decoration: none; white-space: nowrap; }
.clear-link:hover { color: var(--navy); text-decoration: underline; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 12px; color: #778396; font-size: 11px; text-align: left; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--line); }
td { padding: 15px 12px; border-bottom: 1px solid #e9edf2; vertical-align: middle; font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.money-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.revenue { color: #147455; }
.status-select { min-width: 118px; min-height: 36px; padding: 7px 32px 7px 10px; border: 0; border-radius: 99px; font-weight: 750; font-size: 12px; }
.status-select-open { background: #edf1f5; color: #536174; }
.status-select-listed { background: var(--amber-soft); color: #885515; }
.status-select-sold { background: var(--mint-soft); color: #147455; }
.row-actions { display: flex; justify-content: flex-end; align-items: center; gap: 11px; white-space: nowrap; }
.row-actions form { margin: 0; }
.icon-link, .danger-link { border: 0; background: none; padding: 0; font-size: 12px; font-weight: 750; text-decoration: none; }
.icon-link { color: #426991; }
.danger-link { color: var(--red); }
.empty-state { padding: 52px 20px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--ink); }
.empty-state p { margin: 6px 0 0; }

.form-page { width: min(950px, 100%); margin: 0 auto; }
.editor-card { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.field-span-2 { grid-column: span 2; }
.form-grid label small, .stack-form label small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.form-actions { margin-top: 25px; padding-top: 20px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); }
.settings-grid { display: grid; grid-template-columns: .85fr 1.15fr; gap: 18px; }
.compact-card h2 { margin-bottom: 6px; }
.compact-card > p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.stack-form { display: grid; gap: 16px; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 15%, rgba(38, 181, 138, .13), transparent 32%),
    radial-gradient(circle at 85% 80%, rgba(46, 99, 154, .17), transparent 34%),
    #edf2f5;
}
.login-page .page-shell { width: min(440px, calc(100% - 32px)); padding: 30px 0; }
.login-card { padding: 34px; background: rgba(255, 255, 255, .96); border: 1px solid rgba(255,255,255,.8); border-radius: 24px; box-shadow: 0 28px 80px rgba(23, 42, 64, .16); }
.login-brand { display: flex; align-items: center; gap: 15px; }
.brand-mark-large { width: 50px; height: 50px; border-radius: 15px; font-size: 20px; }
.login-brand h1 { margin: 3px 0 0; font-size: 30px; letter-spacing: -.035em; }
.login-copy { margin: 18px 0 24px; color: var(--muted); line-height: 1.55; }

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

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar { height: auto; min-height: 68px; padding: 12px 18px; align-items: flex-start; }
  .nav-actions { gap: 12px; font-size: 12px; flex-wrap: wrap; justify-content: flex-end; }
  .brand small { display: none; }
  .page-shell { width: min(100% - 24px, 1440px); padding-top: 22px; }
  .page-heading, .form-heading, .progress-head, .inventory-head { align-items: stretch; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 124px; }
  .progress-card, .inventory-card, .editor-card { padding: 18px; border-radius: 16px; }
  .target-form, .filter-bar { align-items: stretch; flex-direction: column; }
  .target-form input { width: 100%; }
  .status-summary { width: 100%; }
  .status-chip { flex: 1; text-align: center; }
  .form-grid { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: span 1; }
  .security-notice { align-items: flex-start; flex-direction: column; }

  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody { display: grid; gap: 12px; }
  tr { padding: 14px; border: 1px solid var(--line); border-radius: 14px; }
  td { min-height: 36px; padding: 8px 0 8px 43%; position: relative; border-bottom: 1px dashed #e0e5eb; }
  td::before { content: attr(data-label); position: absolute; left: 0; top: 10px; width: 39%; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; }
  td:first-child { padding-left: 0; padding-top: 0; font-size: 16px; }
  td:first-child::before, .row-actions::before { display: none; }
  .row-actions { min-height: auto; padding: 12px 0 0; justify-content: flex-start; border: 0; }
}
