:root {
  font-family: "Segoe UI", Arial, sans-serif;
  color: #172d31;
  background: #f4f6f5;
  font-synthesis: none;
  --ink: #17383d;
  --muted: #647478;
  --line: #d7ddda;
  --paper: #ffffff;
  --soft: #edf1ef;
  --orange: #e86242;
  --orange-dark: #c54b2f;
  --green: #24795d;
  --amber: #986215;
  --red: #a93932;
  --shadow: 0 6px 22px rgba(23, 56, 61, 0.08);
}

@font-face {
  font-family: "TPD New Order";
  src: url("./assets/fonts/new-order-regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "TPD New Order";
  src: url("./assets/fonts/new-order-bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "TPD Uniwars";
  src: url("./assets/fonts/uniwars-bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 226px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--ink); color: white;
  display: flex; flex-direction: column; padding: 22px 14px;
}
.brand { padding: 4px 8px 22px; border-bottom: 1px solid rgba(255,255,255,.14); }
.brand strong { display: block; font-size: 18px; }
.brand span { color: #b9c9c7; font-size: 12px; }
.nav { display: grid; gap: 5px; padding-top: 18px; }
.nav button {
  border: 0; background: transparent; color: #dce7e5; padding: 11px 12px;
  text-align: left; border-radius: 6px; display: flex; align-items: center; gap: 10px;
}
.nav button:hover, .nav button.active { background: rgba(255,255,255,.12); color: white; }
.nav .icon { width: 20px; text-align: center; }
.user-panel { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.14); }
.user-panel small { color: #b9c9c7; display: block; margin: 3px 0 10px; }

.main { min-width: 0; }
.topbar {
  min-height: 64px; background: var(--paper); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 10px 24px;
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 19px; margin: 0; letter-spacing: 0; }
.status-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.content { padding: 22px 24px 40px; max-width: 1500px; margin: auto; }

.btn {
  min-height: 38px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); color: var(--ink); padding: 8px 13px; font-weight: 600;
}
.btn:hover { border-color: #9baaa7; }
.btn:disabled { cursor: wait; opacity: .72; }
.btn.primary { background: var(--orange); color: white; border-color: var(--orange); }
.btn.primary:hover { background: var(--orange-dark); }
.btn.danger { color: var(--red); }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 13px; }

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(125deg, #17383d 0 44%, #edf1ef 44% 100%);
}
.login-panel {
  width: min(880px, 100%); display: grid; grid-template-columns: 1.1fr .9fr;
  background: white; box-shadow: 0 18px 60px rgba(0,0,0,.18);
}
.login-intro { background: var(--ink); color: white; padding: 54px 44px; }
.login-intro h1 { margin: 0 0 14px; font-size: 32px; line-height: 1.15; }
.login-intro p { color: #c9d8d6; line-height: 1.55; }
.login-form { padding: 48px 40px; display: flex; flex-direction: column; justify-content: center; }
.login-form h2 { margin: 0 0 6px; }
.login-form > p { color: var(--muted); margin: 0 0 22px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 700; color: #394e52; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid #bdc9c6; border-radius: 5px; background: white;
  padding: 10px 11px; color: var(--ink);
}
.field textarea { resize: vertical; min-height: 98px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(232,98,66,.22); border-color: var(--orange);
}
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.form-actions .btn.primary { flex: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 0 14px; }
.time-input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.time-input-row label { display: flex; align-items: center; gap: 7px; font-weight: 600; color: var(--muted); }
.time-input-row input { min-width: 0; }
.message { border-left: 4px solid var(--amber); background: #fff7e8; padding: 10px 12px; margin: 12px 0; }
.message.error { border-color: var(--red); background: #fff0ef; color: #742923; }
.message.success { border-color: var(--green); background: #edf8f3; color: #195842; }

.page-header { display: flex; gap: 15px; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; }
.page-header h2 { margin: 0 0 4px; font-size: 24px; }
.page-header p { margin: 0; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar input, .toolbar select { border: 1px solid var(--line); border-radius: 5px; padding: 8px 10px; background: white; }
.count-button {
  min-width: 36px; min-height: 32px; border: 1px solid #b8c7c3; border-radius: 5px;
  background: white; color: var(--ink); font-weight: 700;
}
.count-button:hover { border-color: var(--orange); color: var(--orange-dark); }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(150px,1fr)); gap: 12px; margin-bottom: 18px; }
.metric { background: var(--paper); border: 1px solid var(--line); padding: 16px; box-shadow: var(--shadow); }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 28px; margin-top: 6px; }
.metric.alert strong { color: var(--red); }

.panel { background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.panel-title { padding: 13px 15px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.panel-title h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 15px; }
.split { display: grid; grid-template-columns: minmax(420px, 1.2fr) minmax(340px, .8fr); gap: 14px; }
.product-list-panel { margin-top: 14px; }
.product-list-scroll {
  height: clamp(265px, 38vh, 380px);
  overflow: auto;
  overscroll-behavior: contain;
}
.product-list-scroll table { min-width: 980px; }
.product-list-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 var(--line);
}
.product-list-scroll tbody tr { height: 52px; }
.panel.is-collapsed .panel-title { border-bottom: 0; }

.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; min-width: 680px; }
th, td { border-bottom: 1px solid var(--line); text-align: left; padding: 10px 11px; vertical-align: top; }
th { background: var(--soft); color: #3c5357; font-size: 12px; text-transform: uppercase; font-weight: 700; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7faf8; }
tbody tr.selected { background: #eaf2ef; box-shadow: inset 4px 0 var(--orange); }
.badge { display: inline-block; border-radius: 999px; padding: 3px 8px; background: var(--soft); font-size: 12px; font-weight: 700; }
.badge.green { color: var(--green); background: #e7f4ee; }
.badge.amber { color: var(--amber); background: #fff2dc; }
.badge.red { color: var(--red); background: #fdebea; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 32px; text-align: center; }
.detail-grid { display: grid; grid-template-columns: 125px 1fr; gap: 10px 12px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.order-items { display: grid; gap: 10px; margin: 10px 0 14px; }
.order-item { border: 1px solid var(--line); border-radius: 6px; padding: 10px; display: grid; gap: 4px; background: #fbfcfc; }
.order-item span, .order-item small { color: var(--muted); }
.privacy-note { background: #edf3f1; border: 1px solid #d4dfdc; padding: 10px 12px; color: #496064; font-size: 13px; }
.stock-summary { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 10px; }
.stock-summary div { background: var(--soft); border-left: 3px solid var(--orange); padding: 11px 12px; }
.stock-summary span { display: block; color: var(--muted); font-size: 12px; }
.stock-summary strong { display: block; font-size: 22px; margin-top: 4px; }
.stock-positive { color: var(--green); font-weight: 700; }
.stock-negative { color: var(--red); font-weight: 700; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.empty.compact { padding: 18px; }
.field small { color: var(--muted); }
.keyword-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.keyword-chips span {
  display: inline-block; padding: 2px 6px; border: 1px solid #c8d5d2;
  background: #f4f7f6; color: #435b5f; font-size: 11px; border-radius: 4px;
}
.keyword-fieldset { border: 1px solid var(--line); margin: 2px 0 14px; padding: 12px; }
.keyword-fieldset legend { color: #394e52; font-size: 13px; font-weight: 700; padding: 0 5px; }
.keyword-options { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 7px 12px; margin-bottom: 13px; }
.keyword-options label { font-size: 13px; }
.schedule-fieldset { border: 1px solid var(--line); margin: 2px 0 14px; padding: 12px; }
.schedule-fieldset legend { color: #394e52; font-size: 13px; font-weight: 700; padding: 0 5px; }
.schedule-fieldset .muted { margin: 0; font-size: 13px; }

.mobile-nav { display: none; }
.setup-code { font-family: Consolas, monospace; overflow-wrap: anywhere; background: var(--soft); padding: 8px; }
.qr { max-width: 200px; width: 100%; display: block; margin: 10px auto; }

.quote-portal {
  min-height: 100vh;
  background: #f4f6f5;
  color: var(--ink);
  font-family: "TPD New Order", "Segoe UI", Arial, sans-serif;
}
.tpd-site-header {
  min-height: 166px;
  background: var(--ink);
  color: #fff;
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr auto;
  align-items: center;
  gap: clamp(18px, 4vw, 48px);
  padding: 30px clamp(20px, 4vw, 58px);
  z-index: 2;
}
.tpd-site-logo {
  display: inline-flex;
  align-items: center;
  width: min(305px, 100%);
}
.tpd-site-logo img {
  display: block;
  width: 100%;
  height: auto;
}
.tpd-site-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(18px, 3vw, 46px);
  flex-wrap: wrap;
}
.tpd-site-nav a,
.tpd-site-cta {
  color: #fff;
  text-decoration: none;
  font-family: "TPD New Order", "Segoe UI", Arial, sans-serif;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}
.tpd-site-nav a:hover {
  color: #f5b19d;
}
.tpd-site-cta {
  background: #f15a24;
  border-radius: 7px;
  padding: 18px 24px;
  text-align: center;
}
.tpd-site-cta:hover {
  background: var(--orange-dark);
}
.tpd-site-footer {
  position: relative;
  overflow: hidden;
  background: var(--ink);
  color: #fff;
  margin-top: 54px;
}
.tpd-footer-slope {
  position: relative;
  height: 154px;
  background: #f4f6f5;
  overflow: hidden;
}
.tpd-footer-slope::before,
.tpd-footer-slope::after {
  content: "";
  position: absolute;
  inset: 30px -4vw auto -4vw;
  height: 150px;
  clip-path: polygon(0 0, 82% 52%, 100% 3%, 100% 100%, 0 100%);
}
.tpd-footer-slope::before {
  background: #f15a24;
}
.tpd-footer-slope::after {
  top: 38px;
  background: var(--ink);
}
.tpd-footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 70px clamp(22px, 5vw, 70px) 78px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 280px) minmax(220px, 1fr);
  gap: clamp(34px, 7vw, 100px);
  align-items: center;
}
.tpd-footer-wordmark {
  display: block;
  width: min(330px, 100%);
  height: auto;
  margin-bottom: 28px;
}
.tpd-footer-contact p,
.tpd-footer-hours p {
  margin: 0 0 20px;
  font-family: "TPD New Order", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}
.tpd-footer-contact a {
  color: #f15a24;
}
.tpd-footer-mascot {
  display: flex;
  justify-content: center;
}
.tpd-footer-mascot img {
  display: block;
  max-width: 230px;
  width: 100%;
  height: auto;
  mix-blend-mode: screen;
}
.tpd-footer-hours h2 {
  margin: 0 0 32px;
  color: white;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
}
.tpd-socials {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 250px;
}
.tpd-socials a {
  width: 47px;
  height: 47px;
  border-radius: 6px;
  background: #648c92;
  display: grid;
  place-items: center;
  color: #cfd8d6;
  text-decoration: none;
  font-family: Arial, sans-serif;
  font-size: 28px;
  font-weight: 700;
  text-transform: uppercase;
}
.tpd-socials a:hover {
  background: #f15a24;
  color: #fff;
}
.tpd-socials img {
  width: 29px;
  height: 29px;
  object-fit: contain;
  opacity: .9;
}
.quote-hero {
  position: relative;
  min-height: 260px;
  background: var(--ink);
  color: white;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 58px clamp(18px, 5vw, 72px) 126px;
  overflow: visible;
}
.quote-hero::before,
.quote-hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 116px;
  clip-path: polygon(0 100%, 50% 0, 100% 100%, 100% 100%, 0 100%);
  pointer-events: none;
}
.quote-hero::before {
  bottom: 7px;
  background: #f15a24;
}
.quote-hero::after {
  bottom: -1px;
  background: #f4f6f5;
}
.quote-hero.confirmation {
  min-height: 230px;
}
.quote-hero h1 {
  margin: 0 0 10px;
  font-size: clamp(34px, 6vw, 68px);
  line-height: 1;
  letter-spacing: 0;
  font-family: "TPD New Order", "Segoe UI", Arial, sans-serif;
  font-weight: 700;
}
.quote-hero p {
  max-width: 660px;
  margin: 0;
  color: #d8e5e3;
  line-height: 1.55;
  font-size: 17px;
}
.quote-kicker {
  margin: 0 0 10px;
  color: #f5b19d;
  font-weight: 700;
}
.quote-staff-link {
  color: var(--ink);
  background: white;
  border: 1px solid rgba(23,56,61,.15);
  border-radius: 6px;
  padding: 10px 13px;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}
.quote-workspace {
  max-width: 1180px;
  margin: -82px auto 0;
  padding: 0 18px 44px;
  position: relative;
  z-index: 1;
}
.quote-workspace.confirmation {
  max-width: 860px;
}
.quote-banner {
  max-width: 1180px;
  margin: -34px auto 52px;
  padding: 13px 18px;
  border-left: 4px solid var(--amber);
  background: #fff7e8;
}
.quote-banner.success {
  border-color: var(--green);
  background: #edf8f3;
  color: #195842;
}
.quote-form {
  display: grid;
  gap: 14px;
}
.quote-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.quote-part-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
  margin-top: 14px;
}
.quote-file-list {
  display: grid;
  gap: 8px;
}
.quote-file-list.empty,
.quote-part-settings .empty {
  color: var(--muted);
  background: var(--soft);
  border: 1px solid var(--line);
  padding: 12px;
}
.quote-file-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: white;
  padding: 10px 12px;
  cursor: pointer;
}
.quote-file-row.selected {
  border-color: var(--orange);
  box-shadow: inset 3px 0 0 var(--orange);
}
.quote-file-row small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}
.quote-part-settings {
  border: 1px solid var(--line);
  background: #fff;
  padding: 14px;
  position: sticky;
  top: 12px;
}
.quote-part-settings h3 {
  margin: 0 0 6px;
}
.form-grid.single {
  grid-template-columns: 1fr;
}
.quote-viewer {
  display: block;
  width: 100%;
  height: clamp(340px, 50vw, 620px);
  margin-top: 14px;
  border: 1px solid var(--line);
  background: var(--soft);
  touch-action: none;
  image-rendering: auto;
}
.quote-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-weight: 700;
  color: #394e52;
}
.quote-check input {
  width: 18px;
  height: 18px;
}
.quote-analysis {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.quote-analysis > div {
  background: var(--soft);
  border-left: 3px solid var(--orange);
  padding: 12px;
}
.quote-analysis span,
.quote-total span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.quote-analysis strong,
.quote-total strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
}
.quote-analysis small,
.quote-total small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}
.quote-analysis .message {
  grid-column: 1 / -1;
  margin: 0;
}
.quote-total {
  background: #17383d;
  color: white;
  padding: 16px;
  margin-top: 4px;
}
.quote-total span,
.quote-total small {
    color: #cbd9d7;
  }
.quote-saving {
  color: #f6d1c6;
  font-weight: 700;
}
.quote-saving.warning {
  color: #ffd2cc;
}
.upload-status {
  border-left: 4px solid var(--amber);
  background: #fff7e8;
  padding: 12px;
  margin: 12px 0;
}
.upload-label {
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.upload-bar {
  height: 12px;
  border: 1px solid var(--line);
  background: white;
  overflow: hidden;
}
.upload-bar span {
  display: block;
  height: 100%;
  background: var(--orange);
  transition: width .2s ease;
}
.upload-detail {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}
.quote-direct-link {
  margin: 10px 0 0;
}
.link-button {
  border: 0;
  background: transparent;
  color: var(--orange-dark);
  padding: 0;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; padding-bottom: 62px; }
  .sidebar { display: none; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(54px, 1fr)); position: fixed; z-index: 20;
    left: 0; right: 0; bottom: 0; background: var(--ink); padding: 5px;
  }
  .mobile-nav button { border: 0; background: transparent; color: #cbd9d7; padding: 6px 2px; font-size: 11px; }
  .mobile-nav button.active { color: white; background: rgba(255,255,255,.12); }
  .mobile-nav .icon { display: block; font-size: 18px; margin-bottom: 2px; }
  .split { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(130px,1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .stock-summary { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .keyword-options { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .quote-part-layout { grid-template-columns: 1fr; }
  .quote-part-settings { position: static; }
  .quote-hero {
    background: #17383d;
    align-items: flex-start;
    flex-direction: column;
    padding-bottom: 104px;
  }
  .quote-hero::before,
  .quote-hero::after {
    height: 82px;
  }
  .quote-analysis { grid-template-columns: 1fr; }
  .tpd-site-header {
    grid-template-columns: 1fr;
    justify-items: center;
    min-height: 0;
    padding: 24px 18px 30px;
  }
  .tpd-site-logo {
    width: min(285px, 86vw);
  }
  .tpd-site-nav {
    gap: 14px 24px;
  }
  .tpd-site-nav a,
  .tpd-site-cta {
    font-size: 17px;
  }
  .tpd-site-cta {
    padding: 14px 18px;
  }
  .tpd-footer-inner {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .tpd-footer-wordmark,
  .tpd-socials {
    margin-left: auto;
    margin-right: auto;
  }
  .tpd-footer-mascot img {
    max-width: 190px;
  }
}

@media (max-width: 650px) {
  .topbar { padding: 10px 14px; }
  .topbar h1 { font-size: 16px; }
  .content { padding: 16px 12px 28px; }
  .login-wrap { padding: 0; background: var(--ink); }
  .login-panel { min-height: 100vh; grid-template-columns: 1fr; }
  .login-intro { padding: 30px 24px; }
  .login-intro h1 { font-size: 25px; }
  .login-form { padding: 30px 24px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { padding: 12px; }
  .metric strong { font-size: 22px; }
  .detail-grid { grid-template-columns: 95px 1fr; }
  .tpd-site-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(110px, 1fr));
    width: 100%;
    justify-items: center;
  }
  .tpd-site-nav a {
    font-size: 16px;
  }
  .tpd-site-cta {
    width: min(280px, 100%);
  }
  .tpd-footer-slope {
    height: 72px;
  }
  .tpd-footer-slope::after {
    top: 18px;
  }
  .tpd-footer-inner {
    padding-bottom: 46px;
  }
}
