:root {
  --paper: #f4f0e8;
  --paper-deep: #e8e1d5;
  --ink: #19201d;
  --muted: #6b706b;
  --line: #d9d2c7;
  --green: #234c3b;
  --green-deep: #17372b;
  --lime: #cce76d;
  --white: #fffdf8;
  --danger: #b24638;
  --shadow: 0 22px 60px rgba(41, 48, 42, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { min-height: 100vh; margin: 0; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(204, 231, 109, .75);
  outline-offset: 2px;
}

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

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, .9fr) minmax(480px, 1.1fr); }
.login-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(3rem, 7vw, 7rem); background: var(--white); }
.brand-mark { display: grid; place-items: center; width: 62px; height: 62px; margin-bottom: 2.5rem; border-radius: 18px 18px 18px 5px; background: var(--green); color: var(--lime); font: 700 30px/1 Georgia, serif; }
.brand-mark-small { width: 42px; height: 42px; margin: 0; border-radius: 13px 13px 13px 4px; font-size: 21px; }
.eyebrow { margin: 0 0 .65rem; font-size: .7rem; font-weight: 800; letter-spacing: .16em; color: var(--green); }
.eyebrow-light { color: var(--lime); }
.login-panel h1 { max-width: 570px; margin: 0; font: 500 clamp(2.5rem, 5vw, 5rem)/.98 Georgia, serif; letter-spacing: -.045em; }
.login-copy { max-width: 470px; margin: 1.5rem 0 2.5rem; color: var(--muted); font-size: 1.05rem; }
.stack-form { display: grid; gap: 1rem; max-width: 430px; }
label { display: grid; gap: .45rem; }
label > span { font-size: .76rem; font-weight: 750; letter-spacing: .02em; color: #3f4843; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: .85rem .95rem; background: var(--white); color: var(--ink); transition: border-color .18s, box-shadow .18s; }
input:hover, select:hover, textarea:hover { border-color: #aaa599; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(35, 76, 59, .09); outline: none; }
textarea { resize: vertical; }
.button { min-height: 44px; border: 0; border-radius: 10px; padding: .74rem 1rem; font-weight: 800; transition: transform .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .6; cursor: wait; transform: none; }
.button-primary { background: var(--green); color: white; }
.button-primary:hover { background: var(--green-deep); }
.button-secondary { border: 1px solid var(--line); background: var(--white); color: var(--ink); }
.button-wide { width: 100%; margin-top: .35rem; }
.login-help { max-width: 430px; margin: 1.25rem 0 0; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.login-help a { color: var(--green); font-weight: 750; }
.login-aside { display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: clamp(3rem, 7vw, 7rem); background: var(--green); color: white; }
.aside-number { align-self: flex-end; font: 400 9rem/1 Georgia, serif; color: rgba(204, 231, 109, .18); }
.login-aside h2 { max-width: 680px; margin: 0; font: 500 clamp(2.2rem, 4vw, 4.8rem)/1.02 Georgia, serif; letter-spacing: -.04em; }
.feature-list { display: flex; flex-wrap: wrap; gap: .75rem; margin: 2.5rem 0 0; padding: 0; list-style: none; }
.feature-list li { border: 1px solid rgba(255,255,255,.2); border-radius: 999px; padding: .55rem .85rem; color: #e9efe9; font-size: .82rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 1.4rem; background: var(--green-deep); color: white; z-index: 20; }
.brand-block { display: flex; align-items: center; gap: .85rem; padding-bottom: 2rem; }
.brand-block strong, .brand-block span { display: block; }
.brand-block strong { font-size: 1rem; letter-spacing: .12em; }
.brand-block span { color: #9eb0a7; font-size: .78rem; }
.nav-list { display: grid; gap: .4rem; }
.nav-item { display: flex; align-items: center; gap: .9rem; width: 100%; border: 0; border-radius: 10px; padding: .85rem .9rem; background: transparent; color: #b9c4bd; text-align: left; font-weight: 700; }
.nav-item:hover { background: rgba(255,255,255,.06); color: white; }
.nav-item.is-active { background: var(--lime); color: var(--green-deep); }
.nav-index { font-size: .64rem; letter-spacing: .12em; opacity: .65; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 1rem; }
.user-card { display: flex; align-items: center; gap: .75rem; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: rgba(204,231,109,.15); color: var(--lime); font-size: .72rem; font-weight: 900; }
.user-card strong, .user-card span { display: block; }
.user-card strong { font-size: .84rem; }
.user-card div > span { margin-top: .12rem; color: #91a096; font-size: .7rem; }
.text-button { border: 0; padding: .8rem 0 0; background: transparent; color: #8fa097; font-size: .75rem; }
.text-button:hover { color: white; }

.workspace { min-width: 0; padding: 0 clamp(1.2rem, 4vw, 4rem) 4rem; }
.topbar { display: flex; align-items: center; gap: 1.25rem; min-height: 122px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font: 500 clamp(2rem, 4vw, 3.6rem)/1 Georgia, serif; letter-spacing: -.03em; }
.topbar .button { margin-left: auto; }
.menu-button { display: none; border: 0; background: transparent; font-size: 1.4rem; }
.page { display: none; padding-top: 2rem; }
.page.is-active { display: block; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 1rem; margin-bottom: 1rem; }
.stat-card { min-height: 148px; display: flex; flex-direction: column; padding: 1.35rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,253,248,.65); }
.stat-card-accent { background: var(--lime); border-color: var(--lime); }
.stat-card span { color: var(--muted); font-size: .74rem; font-weight: 750; }
.stat-card strong { margin: auto 0 .35rem; font: 500 2.35rem/1 Georgia, serif; }
.stat-card small { color: var(--muted); font-size: .72rem; }
.section-card { border: 1px solid var(--line); border-radius: 14px; background: var(--white); box-shadow: 0 1px 0 rgba(32,40,35,.03); overflow: hidden; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.4rem; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 0; font: 500 1.7rem/1.1 Georgia, serif; }
.search-field { width: min(320px, 45%); }
.search-field input { background: var(--paper); }
.count-pill { border-radius: 999px; padding: .45rem .7rem; background: var(--paper); color: var(--muted); font-size: .75rem; font-weight: 700; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 1rem 1.35rem; border-bottom: 1px solid #ebe6dd; text-align: left; }
th { color: var(--muted); font-size: .65rem; letter-spacing: .09em; text-transform: uppercase; }
td { font-size: .82rem; }
td strong { display: block; font-size: .85rem; }
td small { display: block; margin-top: .2rem; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: .4rem; border-radius: 999px; padding: .36rem .58rem; font-size: .68rem; font-weight: 800; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-draft { background: #eeece7; color: #6a6d68; }
.status-sent, .status-confirmed { background: #e7eef9; color: #35619b; }
.status-signed { background: #e2f0e5; color: #27623e; }
.status-in_production { background: #f8edd5; color: #97651f; }
.status-shipped { background: #e9e2f5; color: #664b91; }
.status-delivered { background: #e2f0e5; color: #34734d; }
.status-cancelled { background: #f5e2df; color: var(--danger); }
.empty-state { display: grid; place-items: center; gap: .35rem; min-height: 240px; padding: 2rem; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--ink); font: 500 1.3rem Georgia, serif; }
.catalog-grid, .supplier-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.product-card, .supplier-card { min-height: 210px; padding: 1.4rem; background: var(--white); }
.product-image { display: grid; place-items: center; height: 145px; margin: -1.4rem -1.4rem 1.2rem; overflow: hidden; background: var(--paper); color: #9a9c97; font: 500 2.6rem Georgia, serif; }
.product-image img { width: 100%; height: 100%; object-fit: cover; }
.product-card h3, .supplier-card h3 { margin: 0; font: 500 1.25rem/1.2 Georgia, serif; }
.product-meta, .supplier-meta { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .9rem; }
.product-meta span, .supplier-meta span { padding: .35rem .5rem; border-radius: 6px; background: var(--paper); color: var(--muted); font-size: .67rem; font-weight: 700; }
.supplier-card { min-height: 180px; }
.supplier-card p { color: var(--muted); font-size: .8rem; line-height: 1.55; }
.supplier-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.supplier-card-header .eyebrow { margin-bottom: .45rem; }
.card-action { border: 1px solid var(--line); border-radius: 8px; padding: .42rem .58rem; background: transparent; color: var(--green); font-size: .68rem; font-weight: 800; }
.card-action:hover { background: var(--paper); }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; }
.modal-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(20, 29, 24, .66); backdrop-filter: blur(4px); }
.modal-panel { position: relative; width: min(790px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto; border-radius: 18px; background: var(--white); box-shadow: var(--shadow); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.5rem 1.7rem; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font: 500 2rem/1 Georgia, serif; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--paper); color: var(--ink); font-size: 1.5rem; }
.modal-form { padding: 1.7rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-span-2 { grid-column: span 2; }
.calculation-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 1.4rem; overflow: hidden; border-radius: 12px; background: rgba(255,255,255,.18); }
.calculation-strip div { padding: 1rem; background: var(--green); color: white; }
.calculation-strip span, .calculation-strip strong { display: block; }
.calculation-strip span { margin-bottom: .5rem; color: #b9c9bf; font-size: .68rem; font-weight: 750; text-transform: uppercase; }
.calculation-strip strong { color: var(--lime); font: 500 1.8rem Georgia, serif; }
.modal-actions { display: flex; justify-content: flex-end; gap: .65rem; margin-top: 1.5rem; }
.order-detail-panel { width: min(900px, 100%); }
.order-detail-content { display: grid; gap: 1rem; padding: 1.7rem; }
.order-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.order-summary div { min-height: 86px; padding: 1rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--white); }
.order-summary div:nth-child(3n) { border-right: 0; }
.order-summary div:nth-last-child(-n+3) { border-bottom: 0; }
.order-summary span, .order-summary strong { display: block; }
.order-summary span { margin-bottom: .45rem; color: var(--muted); font-size: .66rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.order-summary strong { font-size: .82rem; line-height: 1.45; }
.workflow-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, auto); align-items: center; gap: 1.5rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.workflow-card-accent { border-color: rgba(35, 76, 59, .28); background: #f6f8ef; }
.workflow-card h3, .documents-section h3 { margin: 0 0 .45rem; font: 500 1.25rem/1.15 Georgia, serif; }
.workflow-card p:not(.eyebrow) { max-width: 570px; margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.55; }
.workflow-card .button { max-width: 280px; }
.upload-form { display: grid; gap: .75rem; min-width: 280px; }
.documents-section { padding: 1.25rem; border: 1px solid var(--line); border-radius: 12px; }
.documents-list { display: grid; gap: .55rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.documents-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem; border-radius: 9px; background: var(--paper); }
.documents-list strong, .documents-list span { display: block; }
.documents-list strong { font-size: .78rem; }
.documents-list span { max-width: 580px; margin-top: .25rem; color: var(--muted); font-size: .68rem; overflow-wrap: anywhere; }
.documents-list code { display: inline-block; margin-top: .32rem; color: var(--green); font-size: .62rem; }
.documents-empty { margin: 1rem 0 0; color: var(--muted); font-size: .78rem; }
.toast { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 200; max-width: 380px; border-radius: 10px; padding: .85rem 1rem; background: var(--green-deep); color: white; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .18s, transform .18s; font-size: .82rem; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--danger); }

@media (max-width: 980px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-panel { min-height: 100vh; padding: 3rem clamp(1.5rem, 8vw, 5rem); }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 248px; transition: transform .2s; }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow); }
  .menu-button { display: block; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid .stat-card:last-child { grid-column: span 2; }
  .catalog-grid, .supplier-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workflow-card { grid-template-columns: 1fr; }
  .workflow-card .button { max-width: none; }
  .upload-form { min-width: 0; }
}

@media (max-width: 640px) {
  .workspace { padding-inline: 1rem; }
  .topbar { min-height: 100px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 2rem; }
  .topbar .button { padding-inline: .8rem; font-size: .75rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .stats-grid .stat-card:last-child { grid-column: auto; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .search-field { width: 100%; }
  .catalog-grid, .supplier-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-span-2 { grid-column: auto; }
  .order-summary { grid-template-columns: 1fr; }
  .order-summary div, .order-summary div:nth-child(3n), .order-summary div:nth-last-child(-n+3) { border-right: 0; border-bottom: 1px solid var(--line); }
  .order-summary div:last-child { border-bottom: 0; }
  .documents-list li { align-items: flex-start; flex-direction: column; }
  .modal { padding: 0; }
  .modal-panel { width: 100%; max-height: 100vh; min-height: 100vh; border-radius: 0; }
}
