:root {
  color-scheme: dark;
  --bg: #131715;
  --surface: #202622;
  --surface-2: #293028;
  --line: #38423b;
  --muted: #b0baae;
  --paper: #eeeade;
  --ink: #202821;
  --orange: #ff7548;
  --mint: #bcf590;
  --danger: #ffb39a;
  --radius: 18px;
  font-family: Arial, Helvetica, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--paper);
  font-size: 16px;
  line-height: 1.5;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 4px;
}

a { color: inherit; }
h1, h2, h3, p, dl, dd { margin: 0; }
[hidden] { display: none !important; }

.eyebrow, .status-tag, .sidebar-label, .page-heading > span, .panel-heading > span,
.sheet-view > span, .sheet-view > small, .topbar, .page-footer {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--paper);
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -1px;
  text-decoration: none;
}

.brand-mark {
  width: 31px;
  height: 34px;
  background: var(--orange);
  clip-path: polygon(0 0, 100% 0, 100% 23%, 62% 23%, 62% 100%, 38% 100%, 38% 23%, 0 23%);
}

.brand small {
  display: block;
  margin-top: -3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: .19em;
  text-transform: uppercase;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .08em;
}

.status-tag--mint { color: var(--mint); }
.status-tag--orange { color: #ffbca5; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
  border-radius: 9px;
  padding: 12px 20px;
  background: var(--mint);
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
  transition: transform .2s ease, background .2s ease;
}

.button:hover { transform: translateY(-2px); background: #d0ffb0; }
.button--dark { background: #292b20; color: #fff1de; }
.button--dark:hover { background: #424632; }
.button--google { width: 100%; background: white; }
.google-g { color: #4285f4; font-size: 21px; font-weight: 900; }

.text-link {
  display: inline-block;
  margin-top: 20px;
  color: var(--muted);
  font-size: 12px;
  text-underline-offset: 4px;
}

.button-link { border: 0; padding: 0; background: none; text-align: left; }
.button-link:hover { color: var(--mint); }

/* Authentication */
.auth-body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 14% 30%, rgba(255, 117, 72, .07), transparent 27rem),
    radial-gradient(circle at 80% 80%, rgba(188, 245, 144, .05), transparent 30rem),
    var(--bg);
}

.auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1420px, 100%);
  margin: auto;
  padding: 30px 6%;
}

.auth-stage, .request-stage {
  display: grid;
  grid-template-columns: 1.12fr .88fr;
  align-items: center;
  gap: 8%;
  width: min(1320px, 100%);
  min-height: calc(100vh - 104px);
  margin: auto;
  padding: 35px 8% 72px;
}

.request-stage { min-height: calc(100vh - 104px); }
.auth-intro, .request-copy { position: relative; isolation: isolate; }
.auth-intro::before, .request-copy::before {
  position: absolute;
  z-index: -1;
  inset: -70px;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 42px 42px;
  content: "";
  mask-image: radial-gradient(ellipse, black, transparent 70%);
}

.auth-intro h1, .request-copy h1 {
  max-width: 620px;
  margin: 20px 0;
  font-size: clamp(48px, 6vw, 84px);
  font-weight: 650;
  letter-spacing: -.065em;
  line-height: 1.01;
}

.auth-intro h1 em, .request-copy h1 em { color: var(--orange); font-style: normal; }
.auth-intro > p:last-of-type, .request-copy > p:last-of-type { max-width: 390px; color: var(--muted); }

.engineering-seal {
  position: relative;
  width: 340px;
  height: 230px;
  margin-top: 24px;
}

.seal-ring, .seal-orbit {
  position: absolute;
  top: 50%; left: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.seal-orbit {
  width: 220px; height: 220px;
  border: 1px dashed #65735e;
  animation: spin 100s linear infinite;
}

.seal-ring {
  width: 172px; height: 172px;
  border: 34px repeating-linear-gradient(45deg, rgba(255,117,72,.18) 0 4px, rgba(255,117,72,.48) 4px 6px);
  outline: 1px solid var(--orange);
  animation: spin-centered 75s linear infinite;
}

.seal-ring i {
  position: absolute;
  width: 13px; height: 13px;
  border: 1px solid var(--orange);
  border-radius: 50%;
  background: var(--bg);
}
.seal-ring i:nth-child(1) { top: -25px; left: calc(50% - 6px); }
.seal-ring i:nth-child(2) { top: calc(50% - 6px); right: -25px; }
.seal-ring i:nth-child(3) { bottom: -25px; left: calc(50% - 6px); }
.seal-ring i:nth-child(4) { top: calc(50% - 6px); left: -25px; }
.seal-axis { position: absolute; display: block; background: #67745f; opacity: .65; }
.seal-axis-x { top: 50%; left: 12px; width: 316px; height: 1px; }
.seal-axis-y { top: 12px; left: 50%; width: 1px; height: 206px; }
.engineering-seal b { position: absolute; top: 50%; right: 0; color: var(--muted); font: 10px ui-monospace, monospace; }
.diagram-label { color: var(--muted); font: 10px ui-monospace, monospace; letter-spacing: .1em; }

.auth-card {
  position: relative;
  border: 1px solid #42493d;
  border-radius: 22px;
  padding: 36px;
  background: linear-gradient(145deg, #293028, #1b211c);
  box-shadow: 0 35px 90px rgba(0, 0, 0, .22);
}

.auth-card::before { position: absolute; top: -2px; left: 36px; width: 70px; height: 3px; background: var(--mint); content: ""; }
.auth-card h2 { margin: 19px 0 9px; font-size: 29px; letter-spacing: -.04em; }
.auth-card > p { margin-bottom: 25px; color: var(--muted); font-size: 14px; }
.divider { height: 1px; margin: 27px 0; background: var(--line); }
.security-note { display: flex; gap: 12px; align-items: flex-start; margin: 0 !important; font-size: 12px !important; }
.security-note span { color: var(--mint); }

.message { margin: 0 0 20px; border: 1px solid #795448; border-radius: 10px; padding: 13px 15px; background: #38241f; color: #ffd0c0; font-size: 13px; }
.message--success { border-color: #60784d; background: #263621; color: var(--mint); }

.identity-card { display: flex; align-items: center; gap: 12px; margin: 22px 0; border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.identity-card > span, .user-card > span { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; background: var(--mint); color: var(--ink); font-size: 11px; font-weight: 800; }
.identity-card strong, .identity-card small { display: block; overflow-wrap: anywhere; }
.identity-card strong { font-size: 13px; }
.identity-card small { color: var(--muted); font-size: 11px; }
.auth-card label { display: block; margin: 0 0 8px; font-size: 12px; font-weight: 750; }
.auth-card label small { color: var(--muted); font-weight: 400; }
.auth-card textarea { width: 100%; resize: vertical; min-height: 100px; border: 1px solid #626b60; border-radius: 8px; padding: 12px; background: #151a16; color: var(--paper); }
.auth-card form .button { width: 100%; margin-top: 15px; }

/* Portal shell */
.app-shell { display: grid; grid-template-columns: 226px minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--line); padding: 30px 20px 22px; background: #171c18; }
.sidebar .brand { margin: 0 9px 52px; }
.sidebar-label { margin: 0 0 13px 14px; color: var(--muted); font-size: 9px; letter-spacing: .15em; text-transform: uppercase; }
.nav { display: grid; gap: 7px; }
.nav button { display: flex; align-items: center; gap: 12px; border-radius: 8px; padding: 13px 14px; background: transparent; color: var(--muted); text-align: left; font-size: 13px; }
.nav button:hover { background: #282f28; color: var(--paper); }
.nav button[aria-current="page"] { background: var(--mint); color: var(--ink); font-weight: 750; }
.nav button > span { width: 18px; font-size: 20px; line-height: 1; }
.nav button small { margin-left: auto; font: 8px ui-monospace, monospace; }
.nav button b { display: grid; place-items: center; min-width: 20px; height: 20px; margin-left: auto; border-radius: 50%; background: var(--orange); color: var(--ink); font-size: 10px; }
.sidebar-bottom { margin-top: auto; padding: 70px 12px 0; }
.user-card { display: flex; align-items: center; gap: 10px; margin-top: 25px; }
.user-card strong, .user-card small { display: block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card strong { font-size: 12px; }
.user-card small { color: var(--muted); font-size: 9px; }
.logout-button { margin-top: 16px; padding: 0; background: none; color: var(--muted); font-size: 11px; }
.logout-button:hover { color: var(--paper); }

.workspace { min-width: 0; padding: 0 42px 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; height: 87px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.topbar > span strong { color: var(--paper); font-weight: 400; }
.topbar i { margin: 0 7px; font-style: normal; }
.topbar > div { display: flex; align-items: center; gap: 13px; }
.topbar > div > b { color: var(--paper); font-size: 10px; letter-spacing: .08em; }

.page { animation: reveal .35s ease both; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 35px 0 27px; }
.page-heading h1 { margin-top: 11px; font-size: clamp(30px, 3.7vw, 47px); line-height: 1.08; letter-spacing: -.06em; }
.page-heading > div > p:last-child { margin-top: 10px; color: var(--muted); font-size: 13px; }
.page-heading > span { color: var(--muted); font-size: 11px; }

.material-strip { display: grid; grid-template-columns: 1.6fr 1fr 1fr; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.material-strip > div { padding: 17px 22px; }
.material-strip > div + div { border-left: 1px solid var(--line); }
.material-strip small { display: block; margin-bottom: 5px; color: var(--muted); font: 9px ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; }
.material-strip strong { font-size: 13px; font-weight: 500; }

.calculator-grid { display: grid; grid-template-columns: minmax(0, 1.13fr) minmax(280px, .87fr); overflow: hidden; border-radius: var(--radius); }
.input-panel { padding: 31px; background: var(--paper); color: var(--ink); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading h2 { font-size: 23px; letter-spacing: -.04em; }
.panel-heading span { color: #66705f; font-size: 10px; }
.input-panel > p { max-width: 370px; margin: 7px 0 24px; color: #626b5e; font-size: 12px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.fields label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 750; }
.input-wrap { position: relative; }
.input-wrap input { width: 100%; min-width: 0; border: 1px solid #b7bdac; border-radius: 7px; padding: 14px 44px 14px 15px; background: #f9f7ef; color: var(--ink); font-size: 25px; letter-spacing: -.04em; }
.input-wrap input[aria-invalid="true"] { border-color: #a03f2f; }
.input-wrap span { position: absolute; top: 21px; right: 13px; color: #626b5e; font: 11px ui-monospace, monospace; }
.presets { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.presets button { border: 1px solid #c1c5b6; border-radius: 5px; padding: 5px 9px; background: transparent; color: #53604f; font-size: 10px; }
.presets button:hover { background: #d9e1c9; }
.form-error { min-height: 22px; margin-top: 9px; color: #9e3021; font-size: 12px; }

.sheet-view { position: relative; display: grid; place-items: center; height: 154px; overflow: hidden; border: 1px solid #c7cebc; border-radius: 8px; background-color: #e1e4d6; background-image: linear-gradient(rgba(103,125,100,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(103,125,100,.08) 1px, transparent 1px); background-size: 15px 15px; }
.sheet { position: relative; width: 144px; height: 120px; border: 1px solid #8f9d83; background: #d0d8c0; }
.cutout { position: absolute; top: 0; left: 0; min-width: 2px; min-height: 2px; background: var(--orange); box-shadow: 0 0 0 1px #ae5739; transition: width .35s ease, height .35s ease; }
.sheet-view > span, .sheet-view > small { position: absolute; bottom: 9px; color: #53604f; font-size: 9px; }
.sheet-view > span { left: 12px; }
.sheet-view > small { right: 12px; }

.result-panel { position: relative; display: flex; flex-direction: column; overflow: hidden; padding: 33px; background: var(--orange); color: #282317; }
.result-panel::before { position: absolute; top: 20px; right: -150px; width: 230px; height: 230px; border: 40px solid rgba(120,57,16,.08); border-radius: 50%; content: ""; pointer-events: none; }
.result-panel .eyebrow { color: #59351e; }
.result { margin-top: 27px; font-size: clamp(44px, 5.7vw, 78px); font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.065em; line-height: 1.1; }
.currency { margin-top: 5px; font-size: 13px; }
.result-note { max-width: 280px; margin: 20px 0 25px; color: #603723; font-size: 12px; }
.calculation { display: grid; gap: 11px; margin-top: auto; border-top: 1px solid rgba(129,58,52,.25); padding-top: 16px; }
.calculation div { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; }
.calculation dt { font-weight: 400; }
.calculation dd { font: 12px ui-monospace, monospace; font-weight: 750; }
.result-panel .button { margin-top: 24px; font-size: 12px; }

.under-grid { display: grid; grid-template-columns: 1.13fr .87fr; gap: 20px; margin-top: 20px; }
.basis-card, .warehouse-preview, .technical, .empty-panel, .admin-card { border: 1px solid var(--line); border-radius: 12px; }
.basis-card { padding: 22px; }
.basis-card h3 { margin-bottom: 15px; font-size: 13px; }
.basis-card > div { display: flex; justify-content: space-between; gap: 12px; }
.basis-card > div p small, .basis-card > div p strong { display: block; }
.basis-card > div p small { color: var(--muted); font-size: 10px; }
.basis-card > div p strong { font-size: 13px; font-weight: 500; }
.basis-card > p { margin-top: 15px; color: var(--muted); font-size: 10px; }
.warehouse-preview { display: flex; flex-direction: column; justify-content: space-between; padding: 23px; background: #293524; border-color: #47563b; }
.warehouse-preview h3 { margin: 10px 0 5px; font-size: 22px; letter-spacing: -.04em; }
.warehouse-preview p { color: #bac9ae; font-size: 11px; }
.technical { margin-top: 18px; padding: 20px; color: var(--muted); font-size: 12px; }
.technical p + p { margin-top: 10px; }

.empty-panel { margin-bottom: 20px; padding: 45px; background: var(--surface); }
.empty-panel h2 { margin: 18px 0 10px; font-size: 33px; letter-spacing: -.05em; }
.empty-panel > p { max-width: 540px; color: var(--muted); font-size: 14px; }
.large-icon { color: var(--mint); font-size: 38px; }
.warehouse-boxes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 180px; margin: 32px 0; }
.warehouse-boxes span { height: 45px; border: 1px solid #637757; border-top: 7px solid #839775; background: #35432e; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 20px; }
.admin-card { overflow: hidden; background: var(--surface); }
.admin-card > header { display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); padding: 18px 22px; }
.admin-card > header h2 { font-size: 14px; }
.admin-card > header span { color: var(--muted); font-size: 11px; }
.request-row, .user-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 22px; }
.request-row + .request-row, .user-row + .user-row { border-top: 1px solid var(--line); }
.request-row strong, .user-row strong, .request-row small, .user-row small { display: block; overflow-wrap: anywhere; }
.request-row strong, .user-row strong { font-size: 13px; }
.request-row small, .user-row small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.request-reason { max-width: 440px; margin-top: 7px !important; color: #d3d9ce !important; }
.request-actions { display: flex; gap: 7px; flex: 0 0 auto; }
.request-actions button { min-height: 34px; border-radius: 7px; padding: 7px 10px; background: var(--mint); color: var(--ink); font-size: 10px; font-weight: 750; }
.request-actions button:last-child { background: #412f28; color: #ffd2c1; }
.role-label { border: 1px solid var(--line); border-radius: 5px; padding: 4px 7px; color: var(--muted); font: 9px ui-monospace, monospace; text-transform: uppercase; }
.empty-copy { padding: 26px 22px; color: var(--muted); font-size: 12px; }
.admin-note { margin-top: 22px; color: var(--muted); font-size: 12px; }

.page-footer { display: flex; justify-content: space-between; gap: 20px; padding: 25px 0 0; color: var(--muted); font-size: 9px; }
.toast { position: fixed; z-index: 20; bottom: 25px; left: 50%; width: max-content; max-width: calc(100% - 32px); transform: translateX(-50%); border: 1px solid #6a8557; border-radius: 10px; padding: 13px 20px; background: #293c23; color: #e1ffd0; box-shadow: 0 15px 45px rgba(0,0,0,.35); font-size: 13px; }

@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes spin-centered { to { transform: translate(-50%, -50%) rotate(-360deg); } }
@keyframes reveal { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 1500px) { .workspace { width: 100%; max-width: 1320px; margin: auto; } }

@media (max-width: 1000px) {
  .auth-stage, .request-stage { gap: 5%; padding-right: 5%; padding-left: 5%; }
  .auth-card { padding: 28px; }
  .app-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .sidebar { padding-right: 12px; padding-left: 12px; }
  .workspace { padding: 0 25px 25px; }
  .input-panel, .result-panel { padding: 25px; }
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: block; border-right: 0; border-bottom: 1px solid var(--line); padding: 11px 12px; }
  .sidebar .brand, .sidebar-label, .sidebar-bottom { display: none; }
  .nav { display: flex; }
  .nav button { flex: 1; justify-content: center; padding: 11px 7px; font-size: 11px; }
  .nav button small { display: none; }
  .workspace { padding: 0 18px 20px; }
  .topbar { height: 62px; }
  .topbar > div > b { display: none; }
  .calculator-grid, .under-grid { grid-template-columns: 1fr; }
  .result-panel { min-height: 360px; }
}

@media (max-width: 620px) {
  .auth-header { padding: 21px 24px; }
  .auth-header > .status-tag { font-size: 8px; }
  .auth-stage, .request-stage { grid-template-columns: 1fr; gap: 24px; min-height: auto; padding: 12px 24px 40px; }
  .auth-intro h1, .request-copy h1 { margin: 14px 0; font-size: 52px; }
  .auth-intro > p:last-of-type, .request-copy > p:last-of-type { font-size: 14px; }
  .engineering-seal { position: absolute; z-index: -1; right: -70px; bottom: -60px; width: 190px; height: 180px; opacity: .28; }
  .seal-orbit { width: 150px; height: 150px; }
  .seal-ring { width: 112px; height: 112px; border-width: 23px; }
  .seal-axis-x { left: 5px; width: 180px; }
  .seal-axis-y { top: 5px; height: 170px; }
  .diagram-label { display: none; }
  .auth-card { padding: 26px; }
  .page-heading { padding: 27px 0 20px; }
  .page-heading h1 { font-size: 36px; }
  .page-heading > span { display: none; }
  .material-strip { grid-template-columns: 1fr 1fr; }
  .material-strip > div:first-child { grid-column: 1 / -1; border-bottom: 1px solid var(--line); }
  .material-strip > div:nth-child(2) { border-left: 0; }
  .material-strip > div { padding: 12px 16px; }
  .fields { grid-template-columns: 1fr 1fr; gap: 10px; }
  .input-panel, .result-panel { padding: 24px; }
  .result { font-size: 67px; }
  .basis-card > div { gap: 7px; }
  .basis-card > div p strong { font-size: 11px; }
  .request-row { align-items: flex-start; flex-direction: column; }
  .page-footer { font-size: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; transition: none !important; }
}

@media print {
  body { background: white; color: black; }
  .sidebar, .topbar, .page-footer, .under-grid, .presets, .result-panel .button, .technical { display: none !important; }
  .app-shell { display: block; }
  .workspace { padding: 0; }
  .calculator-grid { grid-template-columns: 1fr 1fr; }
  .input-panel, .result-panel { border: 1px solid #aaa; background: white !important; color: black !important; }
  .material-strip { background: white; color: black; }
  .result-panel .eyebrow, .result-panel .result-note, .input-panel > p { color: #333; }
}
