:root {
  color-scheme: light;
  --ink: #111111;
  --muted: #686868;
  --line: #dedede;
  --paper: #ffffff;
  --wash: #f2f2f2;
  --brand: #111111;
  --brand-dark: #000000;
  --danger: #a43131;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--wash); color: var(--ink); }
body.auth-required { overflow: hidden; }
body.auth-required > header, body.auth-required > main { visibility: hidden; }
.auth-gate { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 24px; background: #101010; }
.remote-loading { position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center; padding: 24px; background: rgb(242 242 242 / 94%); }
.remote-loading > div { padding: 22px 26px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 20px 70px rgb(0 0 0 / 14%); }
.remote-read-only-notice { margin: 0 0 14px; padding: 12px 15px; border: 1px solid #c8b36a; border-radius: 10px; background: #fff8d9; color: #5b4b12; font-weight: 650; }
.remote-read-only dialog button[type="submit"]:disabled { opacity: .45; cursor: not-allowed; }
.viewer-read-only #new-contact,
.viewer-read-only #new-article,
.viewer-read-only #new-movement,
.viewer-read-only #new-quote,
.viewer-read-only #new-order,
.viewer-read-only #save-price,
.viewer-read-only #save-quote-sequence,
.viewer-read-only #toggle-price-settings,
.viewer-read-only #cleanup-simulation-data,
.viewer-read-only #export-data,
.viewer-read-only #export-attachments,
.viewer-read-only #execute-restore,
.viewer-read-only [data-edit],
.viewer-read-only [data-delete],
.viewer-read-only [data-article-edit],
.viewer-read-only [data-article-delete],
.viewer-read-only [data-incoming-receive],
.viewer-read-only [data-quote-edit],
.viewer-read-only [data-quote-status],
.viewer-read-only [data-quote-delete],
.viewer-read-only [data-order-edit],
.viewer-read-only #add-order-line,
.viewer-read-only [data-order-line-remove],
.viewer-read-only .attachment-editor,
.viewer-read-only [data-attachment-delete] { display: none !important; }
.viewer-read-only [data-order-line-status] { pointer-events: none; opacity: .7; }
.login-card { width: min(440px, 100%); padding: 30px; border-radius: 18px; background: #fff; box-shadow: 0 30px 100px rgb(0 0 0 / 45%); }
.login-logo { display: block; width: min(100%, 330px); margin-bottom: 26px; padding: 14px; border-radius: 10px; background: #000; }
.login-card h1 { margin: 2px 0 22px; font-size: 2.3rem; }
.login-form { display: grid; gap: 14px; }
.login-form .primary, .login-card > button { width: 100%; margin-top: 6px; }
.login-message { color: var(--muted); line-height: 1.5; }
.authenticated-user { display: flex; align-items: center; gap: 8px; padding-right: 8px; color: #fff; font-size: .84rem; font-weight: 700; }
.authenticated-user button { border-color: #555; background: #1b1b1b; color: #fff; }
.database-status { padding: 8px 10px; border: 1px solid #555; border-radius: 99px; color: #d7d7d7; font-size: .75rem; white-space: nowrap; }
.database-status[data-state="online"] { border-color: #4f7569; color: #d9fff2; background: #18352c; }
.database-status[data-state="error"] { border-color: #8e4848; color: #ffdede; background: #3b1c1c; }
.last-sync { color: #d7d7d7; font-size: .72rem; white-space: nowrap; }
header, main { width: min(1120px, calc(100% - 32px)); margin-inline: auto; }
header { display: flex; justify-content: space-between; align-items: end; margin-top: 24px; padding: 22px 24px; gap: 20px; background: #000; border-radius: 16px; color: #fff; }
h1 { margin: 4px 0; font-size: clamp(2rem, 4vw, 3.2rem); letter-spacing: -.04em; }
.brand-block { display: flex; align-items: center; gap: 24px; min-width: 0; }
.brand-logo { display: block; width: clamp(230px, 32vw, 410px); height: auto; }
.brand-copy { padding-left: 24px; border-left: 1px solid #404040; }
.eyebrow { color: #bdbdbd; font-weight: 750; text-transform: uppercase; letter-spacing: .11em; font-size: .75rem; }
.eyebrow.dark { color: var(--muted); margin: 0 0 4px; }
.subtitle, .empty { color: var(--muted); }
button, .button, input, select, textarea { font: inherit; }
button, .button { border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 10px 14px; cursor: pointer; }
button:hover, .button:hover { border-color: #9eaaa7; }
.primary { color: white; background: var(--brand); border-color: #444; font-weight: 700; }
.primary:hover { background: var(--brand-dark); }
header .primary { color: #111; background: #fff; border-color: #fff; }
header .primary:hover { background: #d9d9d9; }
.header-actions { display: flex; align-items: end; gap: 10px; }
.language-picker { color: #d0d0d0; }
.language-picker select { min-width: 112px; border-color: #555; background: #1b1b1b; color: #fff; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 14px; }
.stats article, .panel { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 30px rgb(20 45 38 / 5%); }
.stats article { padding: 20px; }
.stats span { display: block; font-size: 1.8rem; font-weight: 760; }
.stats small { color: var(--muted); }
.stat-action { padding: 0 !important; }
.stat-action button { width: 100%; height: 100%; padding: 20px; border: 0; border-radius: 14px; text-align: left; }
.stat-action button:not(:disabled):hover { background: #e4e4e4; }
.stat-action button:disabled { cursor: default; opacity: 1; }
.anomaly-panel { border-color: #b8b8b8; }
.panel { padding: 20px; margin-bottom: 14px; }
.module-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 14px; padding: 5px; width: fit-content; background: #d8d8d8; border-radius: 11px; }
.stock-table { margin-top: 20px; }
.module-nav button { border: 0; background: transparent; }
.module-nav button.active { background: #111; color: #fff; box-shadow: 0 2px 8px rgb(0 0 0 / 16%); font-weight: 750; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section-head h2 { margin: 0 0 4px; }
.section-head p { margin: 0; }
.toolbar { display: grid; grid-template-columns: 1fr 200px; gap: 14px; align-items: end; margin-bottom: 20px; }
label { display: grid; gap: 6px; font-size: .84rem; font-weight: 650; color: #4a5754; }
input, select, textarea { width: 100%; border: 1px solid #cdd7d4; border-radius: 8px; padding: 10px 11px; background: white; color: var(--ink); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
legend { padding: 0 7px; font-weight: 750; color: var(--ink); }
.field-help { margin: 0 0 14px; color: var(--muted); font-size: .84rem; }
.input-with-unit { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.shipping-result { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 20px; }
input[readonly] { background: var(--wash); color: var(--muted); }
.shipping-result article { padding: 14px; border-radius: 10px; background: var(--wash); }
.shipping-result small, .shipping-result strong { display: block; }
.shipping-result strong { margin-top: 5px; font-size: 1.25rem; }
.price-breakdown { display: grid; gap: 8px; margin-top: 20px; }
.price-step { display: flex; justify-content: space-between; gap: 16px; padding: 12px 14px; background: var(--wash); border-radius: 9px; }
.price-step.total { color: #fff; background: #111; font-size: 1.08rem; }
.settings-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 24px; }
.settings-columns > section { border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.section-head.compact { align-items: start; margin-bottom: 14px; }
.section-head.compact h3 { margin: 0 0 4px; }
.margin-list { display: grid; gap: 9px; }
.margin-row { display: grid; grid-template-columns: 32px 1fr 110px 42px; gap: 8px; align-items: center; }
.margin-order { color: var(--muted); text-align: center; font-weight: 750; }
.margin-row button { padding-inline: 10px; }
.exchange-field { max-width: 430px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgb(0 0 0 / 12%); border-color: #333; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
td:last-child { text-align: right; white-space: nowrap; }
.badge { display: inline-block; padding: 4px 8px; border-radius: 99px; background: #e4e4e4; color: #222; font-size: .78rem; font-weight: 700; }
.empty { text-align: center; padding: 42px 10px; }
.quality summary { cursor: pointer; font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
output { display: block; white-space: pre-wrap; padding: 12px; border-radius: 8px; background: var(--wash); font: .82rem ui-monospace, SFMono-Regular, Menlo, monospace; }
dialog { width: min(680px, calc(100% - 24px)); border: 0; border-radius: 16px; padding: 0; box-shadow: 0 24px 90px rgb(0 0 0 / 28%); }
.wide-dialog { width: min(1040px, calc(100% - 24px)); }
.quote-lines-fieldset { margin-top: 18px; }
.quote-line-editor { display: grid; grid-template-columns: 1.2fr 2fr 1fr .7fr .6fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 16px; }
.order-line-editor { grid-template-columns: 1.5fr .8fr .7fr .8fr 1fr auto; }
.attachment-editor { display: flex; align-items: end; gap: 10px; margin-bottom: 14px; }
.attachment-editor label:first-child { min-width: 190px; }
.attachment-file-button { display: block; color: var(--ink); }
.attachment-list { display: grid; gap: 8px; }
.attachment-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; }
.attachment-row small { color: var(--muted); }
dialog::backdrop { background: rgb(15 28 24 / 55%); }
dialog form { padding: 24px; }
.dialog-head, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0 0 20px; }
.icon { border: 0; font-size: 1.7rem; padding: 2px 8px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.wide { grid-column: 1 / -1; }
.dialog-actions { justify-content: flex-end; margin-top: 20px; }
.error { min-height: 1.2em; color: var(--danger); font-weight: 650; }
.notice { margin-top: 16px; padding: 12px 14px; border-radius: 9px; background: #fff7df; color: #674d00; }
.notice:empty { display: none; }
.notice p { margin: 5px 0; }
.danger { color: var(--danger); }
@media (max-width: 720px) {
  header, main { width: min(100% - 16px, 1120px); }
  header { align-items: stretch; flex-direction: column; margin-top: 8px; padding: 16px; gap: 14px; border-radius: 12px; }
  .header-actions { align-items: stretch; flex-direction: column; }
  .authenticated-user { justify-content: space-between; }
  .database-status { text-align: center; }
  .last-sync { text-align: center; }
  .header-actions .primary { flex: 1; }
  .brand-block { align-items: flex-start; flex-direction: column; gap: 12px; }
  .brand-copy { padding: 0; border: 0; }
  .brand-logo { width: 100%; max-width: 390px; }
  .module-nav { flex-wrap: nowrap; width: 100%; overflow-x: auto; padding: 5px; -webkit-overflow-scrolling: touch; }
  .module-nav button { flex: 0 0 auto; min-height: 44px; white-space: nowrap; }
  .panel { padding: 15px; }
  .section-head { align-items: stretch; flex-direction: column; }
  .stats, .toolbar, .grid, .settings-columns { grid-template-columns: 1fr; }
  .margin-row { grid-template-columns: 28px 1fr 90px 40px; }
  .quote-line-editor { grid-template-columns: 1fr; }
  .shipping-result { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 680px; }
  dialog { max-height: calc(100dvh - 16px); width: calc(100% - 16px); overflow-y: auto; border-radius: 12px; }
  dialog form { padding: 16px; }
  fieldset { min-width: 0; padding: 11px; }
  .dialog-actions { align-items: stretch; flex-direction: column; }
  .dialog-actions button { width: 100%; min-height: 44px; }
  .actions > button, .actions > .button { flex: 1 1 100%; min-height: 44px; text-align: center; }
  .attachment-editor, .attachment-row { align-items: stretch; flex-direction: column; }
  .attachment-editor label:first-child { min-width: 0; }
  button, .button, input, select, textarea { min-height: 44px; }
  .login-card { padding: 20px; }
  .auth-gate { padding: 12px; }
}
