
:root {
  color-scheme: light;
  --ink: #171714;
  --muted: #706e65;
  --paper: #f4f1e9;
  --card: #fffdf8;
  --line: #ddd8cc;
  --accent: #ed6237;
  --accent-soft: #ffe4d8;
  --green: #23734d;
  --green-soft: #dff3e8;
  --blue: #315c8c;
  --blue-soft: #e5eef8;
  --red: #9d301f;
  --red-soft: #fde7e2;
  --shadow: 0 18px 50px rgba(32, 27, 18, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); min-height: 100vh; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.auth-pending .topbar, .auth-pending .shell { display: none; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, rgba(237, 98, 55, .16), transparent 34%),
    radial-gradient(circle at 88% 82%, rgba(35, 115, 77, .12), transparent 30%),
    var(--paper);
}
.auth-card {
  width: min(100%, 420px);
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.auth-mark { margin-bottom: 28px; }
.auth-card h1 { font-size: 46px; margin: 12px 0; }
.auth-card > p { margin: 0 0 25px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .button { margin-top: 6px; }
.auth-status { display: block; min-height: 20px; margin-top: 12px; color: #a33d20; font-size: 12px; text-align: center; }

.topbar {
  height: 74px;
  padding: 0 clamp(22px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(23, 23, 20, 0.1);
  background: rgba(244, 241, 233, 0.92);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 12px; background: var(--ink); color: white; font-weight: 800;
  box-shadow: 4px 4px 0 var(--accent);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: -0.02em; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 1px; }

.account {
  display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--muted); font-size: 12px;
}
.account-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.account-actions { display: flex; align-items: center; gap: 8px; }
.logout-button { border: 0; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; padding: 8px; }
.logout-button:hover { color: var(--ink); }

.shell { max-width: 1700px; margin: 0 auto; padding: 54px clamp(20px, 3vw, 48px) 72px; }
.hero { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 30px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0.18em; }
h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(38px, 5vw, 68px); line-height: 0.98; letter-spacing: -0.055em; margin: 12px 0 14px; }
.hero p { margin: 0; color: var(--muted); font-size: 15px; }
.hero-actions { display: flex; align-items: center; gap: 8px; }

.button {
  min-height: 42px; border-radius: 12px; padding: 0 17px; border: 1px solid transparent;
  cursor: pointer; font-weight: 750; font-size: 13px; transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: wait; transform: none; }
.button-primary { background: var(--ink); color: white; box-shadow: 0 6px 16px rgba(23, 23, 20, .18); }
.button-primary:hover { background: #2f2e29; }
.button-accent { background: var(--accent); color: white; box-shadow: 0 6px 16px rgba(237, 98, 55, .22); }
.button-secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.button-wide { width: 100%; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 13px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 17px 18px; }
.stat span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.stat strong { display: block; font-family: Georgia, serif; font-size: 31px; margin-top: 7px; letter-spacing: -.04em; }

.workspace { display: grid; grid-template-columns: minmax(420px, 460px) minmax(760px, 1fr); gap: 18px; align-items: start; }
.orders-panel, .detail-panel { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.orders-panel { position: sticky; top: 92px; height: min(760px, calc(100vh - 116px)); min-height: 520px; display: flex; flex-direction: column; }
.panel-head { padding: 13px 16px 11px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.order-search { position: relative; display: block; }
.order-search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 18px; pointer-events: none; }
.order-search input { width: 100%; height: 40px; padding: 0 12px 0 35px; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--ink); outline: none; }
.order-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.order-search input::placeholder { color: #99958a; }
.panel-filter-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter { border: 0; background: transparent; color: var(--muted); padding: 8px 10px; border-radius: 9px; cursor: pointer; font-size: 12px; font-weight: 750; }
.filter.is-active { background: var(--ink); color: white; }
.result-count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.order-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.order-card { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; padding: 18px; transition: background .16s ease; }
.order-card:last-child { border-bottom: 0; }
.order-card:hover, .order-card.is-selected { background: #faf6ed; }
.order-card.is-selected { box-shadow: inset 3px 0 0 var(--accent); }
.order-card-top, .order-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.order-card-statuses, .detail-statuses { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.order-identity { display: grid; gap: 3px; }
.order-name { font-family: Georgia, serif; font-weight: 700; font-size: 20px; }
.order-kind { color: var(--muted); font-size: 11px; font-weight: 750; }
.order-card-bottom { margin-top: 13px; color: var(--muted); font-size: 12px; }
.order-card-meta { display: flex; gap: 13px; min-width: 0; }
.order-card-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status { display: inline-flex; align-items: center; min-height: 28px; padding: 0 9px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .03em; white-space: nowrap; }
.status-awaiting_approval { background: var(--accent-soft); color: #a33d20; }
.status-approved_for_production { background: var(--blue-soft); color: var(--blue); }
.status-supplier_received, .status-production_started { background: #f0ead8; color: #765d1d; }
.status-tracking_added { background: var(--green-soft); color: var(--green); }
.status-refund-pending, .status-refund-partially_refunded, .status-refund-refunded, .status-refund-failed { background: var(--red-soft); color: var(--red); }

.detail-panel { min-height: 560px; }
.detail-empty, .loading, .empty-list { min-height: 540px; display: grid; place-content: center; text-align: center; padding: 40px; color: var(--muted); }
.detail-empty h2, .empty-list h2 { color: var(--ink); margin: 14px 0 5px; font-family: Georgia, serif; font-size: 25px; }
.detail-empty p, .empty-list p { max-width: 340px; margin: 0; font-size: 13px; line-height: 1.6; }
.empty-icon { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto; border-radius: 17px; background: var(--accent-soft); color: var(--accent); font-size: 26px; }
.detail-content { padding: 20px; }
.detail-title { display: flex; justify-content: space-between; gap: 15px; align-items: start; margin-bottom: 18px; }
.detail-title h2 { font-family: Georgia, serif; font-size: 32px; margin: 0 0 5px; letter-spacing: -.03em; }
.detail-title p { color: var(--muted); font-size: 12px; margin: 0; }
.detail-columns { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(320px, 380px); gap: 16px; align-items: start; }
.detail-preview-column, .detail-sidebar { min-width: 0; }
.detail-preview-column { position: sticky; top: 92px; }
.detail-sidebar .detail-grid { grid-template-columns: 1fr; margin-top: 0; }
.detail-sidebar .action-card { margin-top: 12px; }
.preview { position: relative; border-radius: 17px; overflow: hidden; background: #ece7dc; border: 1px solid var(--line); }
.preview-head { min-height: 58px; padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fffefa; border-bottom: 1px solid var(--line); }
.preview-head strong { display: block; font-size: 13px; }
.preview-head span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.preview-badge { flex: 0 0 auto; border-radius: 999px; padding: 6px 8px; background: var(--green-soft); color: var(--green) !important; font-size: 10px !important; font-weight: 800; }
.preview-switcher { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; padding: 10px 11px; background: #faf6ed; border-bottom: 1px solid var(--line); }
.preview-tab { min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 800; }
.preview-tab:hover { border-color: var(--ink); color: var(--ink); }
.preview-tab.is-active { border-color: var(--ink); background: var(--ink); color: white; }
.preview-media { min-height: 300px; display: grid; place-items: center; background: white; }
.preview img { width: 100%; height: min(52vw, 680px); min-height: 360px; object-fit: contain; display: block; background: white; }
.preview-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; padding: 11px; background: #faf6ed; border-top: 1px solid var(--line); }
.preview-link { min-height: 40px; border: 1px solid var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--ink); background: white; text-decoration: none; font-size: 11px; font-weight: 750; }
.preview-link:hover { border-color: var(--ink); }
.preview-placeholder { color: var(--muted); font-size: 13px; text-align: center; padding: 30px; }
.readiness { display: flex; gap: 7px; flex-wrap: wrap; margin: 14px 0 0; }
.readiness span { font-size: 11px; font-weight: 750; border-radius: 999px; padding: 7px 9px; background: #eee9df; color: var(--muted); }
.readiness span.is-ready { background: var(--green-soft); color: var(--green); }
.readiness span.is-final-output { background: var(--blue-soft); color: var(--blue); }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.detail-grid.is-single { grid-template-columns: 1fr; }
.info-card, .action-card { border: 1px solid var(--line); background: #fffefa; border-radius: 15px; padding: 15px; }
.info-card h3, .action-card h3 { margin: 0 0 11px; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.product-config-item + .product-config-item { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.product-config-group { margin-top: 11px; padding: 10px 11px; border-radius: 10px; background: #faf6ed; }
.product-config-group + .product-config-group { margin-top: 8px; }
.product-config-group h4 { margin: 0 0 7px; color: var(--muted); font-size: 11px; font-weight: 800; }
.info-card p { margin: 4px 0; font-size: 12px; line-height: 1.5; }
.info-card strong { font-size: 13px; }
.action-card { margin-top: 14px; background: #faf6ed; }
.action-card p { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 0 0 13px; }
.field { display: grid; gap: 6px; margin-bottom: 10px; }
.field label { color: var(--muted); font-size: 11px; font-weight: 700; }
.field input, .field select { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); padding: 0 11px; outline: none; }
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.download-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 13px; }
.download-row.is-single { grid-template-columns: 1fr; }
.download { min-height: 42px; border: 1px solid var(--line); border-radius: 11px; display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); background: white; font-size: 12px; font-weight: 750; }
.download:hover { border-color: var(--ink); }
.danger-note { color: #a33d20 !important; background: var(--accent-soft); border-radius: 9px; padding: 9px; }
.refund-alert { margin: 0 0 16px; padding: 12px 14px; border: 1px solid #efb5aa; border-radius: 12px; background: var(--red-soft); color: var(--red); font-size: 12px; font-weight: 750; line-height: 1.5; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: 380px; background: var(--ink); color: white; border-radius: 13px; padding: 13px 16px; box-shadow: var(--shadow); font-size: 12px; transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s ease; z-index: 20; }
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast.is-error { background: #9d301f; }

@media (max-width: 1280px) {
  .workspace { grid-template-columns: 1fr; }
  .orders-panel { position: static; height: 520px; min-height: 0; }
  .detail-columns { grid-template-columns: minmax(420px, 1fr) minmax(320px, 380px); }
  .detail-preview-column { position: static; }
}
@media (max-width: 820px) {
  .detail-columns { grid-template-columns: 1fr; }
  .preview img { height: min(90vw, 620px); }
}
@media (max-width: 700px) {
  .topbar { padding: 0 17px; }
  .brand small { display: none; }
  .account { max-width: 48vw; overflow: hidden; }
  .account span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .logout-button { display: none; }
  .auth-card { padding: 28px 22px; }
  .shell { padding: 34px 14px 50px; }
  .hero { align-items: start; }
  .hero .button { padding: 0 12px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .workspace { display: block; }
  .orders-panel { height: 480px; }
  .detail-panel { margin-top: 14px; }
  .detail-grid { grid-template-columns: 1fr; }
  .filters { flex-wrap: nowrap; overflow-x: auto; }
  .panel-filter-row { align-items: start; flex-direction: column; }
}
