:root {
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: #172033;
  background: #f4f7fb;
  font-synthesis: none;
  --ink: #172033;
  --muted: #667085;
  --line: #dde5f0;
  --surface: #ffffff;
  --canvas: #f4f7fb;
  --primary: #1677ff;
  --primary-dark: #0b63e5;
  --primary-soft: #eaf3ff;
  --electric: #28d7ff;
  --blue: #1677ff;
  --blue-soft: #eaf3ff;
  --cyan: #008fd5;
  --cyan-soft: #e8f8ff;
  --success: #129b65;
  --success-soft: #e9f8f1;
  --amber: #c77700;
  --amber-soft: #fff4df;
  --red: #d83f4b;
  --red-soft: #ffebed;
  --purple: #008fd5;
  --purple-soft: #e8f8ff;
  --sidebar: #101d35;
  --sidebar-active: #17365f;
  --shadow: 0 18px 46px rgba(32, 56, 96, .12);
  --shadow-soft: 0 1px 2px rgba(22, 43, 77, .05);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button, input, select, textarea { transition: border-color .16s ease, background-color .16s ease, box-shadow .16s ease, color .16s ease; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
svg { width: 18px; height: 18px; stroke-width: 1.75; flex: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px 16px; background: var(--sidebar); color: #fff; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: #fff; background: var(--primary); box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), 0 6px 16px rgba(22,119,255,.28); font-weight: 800; font-size: 13px; }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 14px; font-weight: 800; }
.brand-copy small { color: #8fa5c7; font-size: 11px; }
.nav-list { display: grid; gap: 4px; }
.nav-item { width: 100%; min-height: 42px; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 6px; padding: 0 11px; color: #afc2df; background: transparent; text-align: left; font-size: 13px; }
.nav-item:hover { color: #fff; background: rgba(22,119,255,.12); }
.nav-item.active { color: #fff; background: var(--sidebar-active); box-shadow: inset 3px 0 var(--electric); }
.nav-item.active svg { color: var(--electric); }
.nav-item span:nth-child(2) { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.nav-count { margin-left: auto; min-width: 22px; height: 20px; display: grid; place-items: center; padding: 0 6px; border-radius: 10px; color: #d8e7ff; background: rgba(255,255,255,.1); font-size: 11px; }
.nav-count.alert { color: #fff; background: #d98400; }
.sidebar-footer { margin-top: auto; display: grid; gap: 8px; }
.user-row { display: grid; grid-template-columns: 34px 1fr 16px; align-items: center; gap: 9px; border-top: 1px solid rgba(255,255,255,.12); padding: 15px 8px 0; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; overflow: hidden; border: 0; padding: 0; border-radius: 50%; color: #0a4eb5; background: #dcebff; font-size: 12px; font-weight: 800; }
.avatar-upload:hover { box-shadow: 0 0 0 2px var(--electric); }
.avatar img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center; }
.user-row strong, .user-row small { display: block; }
.user-row strong { font-size: 12px; }
.user-row small { margin-top: 2px; color: #8fa5c7; font-size: 11px; }
.user-row svg { color: #7f96ba; width: 15px; }

.main-area { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: rgba(244, 247, 251, .96); backdrop-filter: blur(12px); }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 170px; }
.eyebrow { display: block; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.topbar h1 { margin: 3px 0 0; font-size: 20px; line-height: 1.2; letter-spacing: 0; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.menu-button { display: none !important; }
.search-box { width: min(330px, 26vw); height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: #8793a8; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
.segmented { display: inline-flex; height: 34px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #edf2f8; }
.segment { min-width: 36px; border: 0; border-radius: 4px; padding: 0 8px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 700; }
.segment.active { color: var(--primary); background: #fff; box-shadow: 0 1px 4px rgba(22,43,77,.12); }
.fx-rate { min-width: 112px; color: var(--muted); font-size: 9px; font-weight: 700; white-space: nowrap; }
.fx-rate::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: var(--primary); }
.fx-rate.stale::before { background: var(--amber); }
.icon-button { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--surface); }
.icon-button:hover { border-color: #b7cef0; color: var(--primary); background: var(--primary-soft); }
.notification-button span { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border: 2px solid #fff; border-radius: 50%; background: var(--red); }
.primary-button, .secondary-button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 6px; padding: 0 14px; font-size: 12px; font-weight: 700; }
.primary-button { border: 1px solid var(--primary); color: #fff; background: var(--primary); }
.primary-button:hover { background: var(--primary-dark); }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: #fff; }
.secondary-button:hover { border-color: #adc7ee; color: var(--primary); background: #f5f9ff; }

.content { padding: 24px 28px 40px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; font-size: 15px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.text-button { display: inline-flex; align-items: center; gap: 5px; border: 0; padding: 5px; color: var(--primary); background: transparent; font-size: 12px; font-weight: 700; }
.period-tabs { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.period-tabs button { min-height: 28px; border: 0; border-radius: 4px; padding: 0 10px; color: var(--muted); background: transparent; font-size: 11px; }
.period-tabs button.active { color: #fff; background: var(--primary); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow-soft); }
.metric { min-width: 0; padding: 18px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.metric-head svg { width: 17px; color: var(--primary); }
.metric strong { display: block; margin-top: 10px; overflow-wrap: anywhere; font-size: clamp(20px, 2.2vw, 29px); line-height: 1.05; }
.metric-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); font-size: 10px; }
.trend { padding: 2px 5px; border-radius: 4px; color: var(--primary); background: var(--primary-soft); font-weight: 800; }
.trend.negative { color: var(--red); background: var(--red-soft); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .85fr); gap: 18px; margin-top: 20px; }
.panel { min-width: 0; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-soft); overflow: hidden; }
.dashboard-grid > * { min-width: 0; }
.panel-header { min-height: 57px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 14px; }
.panel-header p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.panel-body { padding: 16px; }
.panel + .panel { margin-top: 18px; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.data-table th { height: 38px; padding: 0 12px; color: var(--muted); background: #f8fafd; font-size: 10px; text-align: left; font-weight: 700; white-space: nowrap; }
.data-table td { min-height: 52px; padding: 12px; border-top: 1px solid #edf1f7; vertical-align: middle; }
.data-table tbody tr:hover { background: #f5f9ff; }
.order-id { color: var(--primary); font-weight: 800; white-space: nowrap; }
.company-cell strong, .company-cell small { display: block; }
.company-cell strong { max-width: 210px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
.company-cell small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.money { white-space: nowrap; font-weight: 700; }
.status { display: inline-flex; align-items: center; gap: 5px; min-height: 23px; padding: 0 7px; border-radius: 4px; font-size: 9px; font-weight: 800; white-space: nowrap; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.production { color: var(--blue); background: var(--blue-soft); }
.status.shipping { color: var(--purple); background: var(--purple-soft); }
.status.payment { color: var(--amber); background: var(--amber-soft); }
.status.risk { color: var(--red); background: var(--red-soft); }
.status.done { color: var(--success); background: var(--success-soft); }
.owner-chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.owner-chip span { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--primary); font-size: 8px; font-weight: 800; }
.progress-track { width: 78px; height: 5px; border-radius: 3px; background: #e5ebf4; overflow: hidden; }
.progress-track i { display: block; height: 100%; border-radius: 3px; background: var(--primary); }
.progress-label { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }

.risk-list { display: grid; }
.risk-item { display: grid; grid-template-columns: 30px 1fr auto; align-items: start; gap: 10px; padding: 13px 0; border-bottom: 1px solid #edf1f7; }
.risk-item:first-child { padding-top: 0; }
.risk-item:last-child { padding-bottom: 0; border-bottom: 0; }
.risk-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; color: var(--amber); background: var(--amber-soft); }
.risk-icon.high { color: var(--red); background: var(--red-soft); }
.risk-icon svg { width: 15px; }
.risk-copy strong { display: block; font-size: 11px; }
.risk-copy p { margin: 4px 0 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.due { padding-top: 2px; color: var(--red); font-size: 9px; font-weight: 800; white-space: nowrap; }

.cashflow-list { display: grid; gap: 14px; }
.cashflow-row { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 10px; font-size: 10px; }
.cashflow-row > span:first-child { color: var(--muted); }
.flow-bar { height: 7px; border-radius: 4px; background: #e8edf5; overflow: hidden; }
.flow-bar i { display: block; height: 100%; border-radius: 4px; background: var(--primary); }
.flow-bar i.out { background: var(--amber); }
.goal-block { padding: 15px 16px; border-top: 1px solid var(--line); background: #f7faff; }
.goal-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 9px; font-size: 10px; }
.goal-top strong { font-size: 12px; }

.page-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.filter-row { display: flex; gap: 7px; flex-wrap: wrap; }
.filter-select { height: 34px; border: 1px solid var(--line); border-radius: 6px; padding: 0 28px 0 9px; color: var(--ink); background: #fff; font-size: 10px; }
.summary-strip { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.summary-strip > div { padding: 14px 16px; border-right: 1px solid var(--line); }
.summary-strip > div:last-child { border-right: 0; }
.summary-strip span, .summary-strip strong { display: block; }
.summary-strip span { color: var(--muted); font-size: 9px; }
.summary-strip strong { margin-top: 5px; font-size: 16px; }

.customer-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.customer-contact { display: grid; gap: 3px; min-height: 30px; color: var(--muted); font-size: 10px; }
.crm-form, .target-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; padding: 18px; }
.crm-form .field.full { grid-column: 1 / -1; }
.crm-form footer { display: flex; justify-content: flex-end; gap: 8px; grid-column: 1 / -1; }
.target-form { grid-template-columns: repeat(5, minmax(120px, 1fr)) auto; align-items: end; }
.target-form .primary-button { min-height: 38px; white-space: nowrap; }
.quotation-form { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 14px; align-items: end; margin-bottom: 18px; padding: 18px; }
.quotation-form .primary-button { min-height: 38px; white-space: nowrap; }
.quote-convert { display: inline-flex; align-items: center; gap: 6px; min-width: 240px; }
.quote-convert input { width: 128px; }
.customer-card { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: #fff; }
.customer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.customer-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.customer-logo { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; color: #0b5fd7; background: #e3efff; font-size: 11px; font-weight: 800; }
.customer-identity strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.customer-identity small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.customer-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.customer-stats span, .customer-stats strong { display: block; }
.customer-stats span { color: var(--muted); font-size: 9px; }
.customer-stats strong { margin-top: 4px; font-size: 12px; }
.customer-next { display: flex; align-items: center; gap: 7px; margin-top: 14px; color: var(--muted); font-size: 9px; }
.customer-next svg { width: 14px; color: var(--amber); }

.task-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.task-column { min-width: 0; }
.task-column-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; font-size: 11px; font-weight: 800; }
.task-column-head span { min-width: 22px; height: 20px; display: grid; place-items: center; border-radius: 10px; color: var(--primary); background: var(--primary-soft); font-size: 9px; }
.task-card { margin-bottom: 8px; border: 1px solid var(--line); border-radius: 7px; padding: 13px; background: #fff; }
.task-card.high { border-left: 3px solid var(--red); }
.task-card.medium { border-left: 3px solid var(--amber); }
.task-card strong { display: block; font-size: 11px; line-height: 1.45; }
.task-card p { margin: 7px 0 10px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.task-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-meta span { color: var(--muted); font-size: 9px; }

.chart-area { height: 230px; display: flex; align-items: flex-end; gap: 20px; padding: 24px 16px 12px; border-bottom: 1px solid var(--line); }
.bar-group { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 5px; position: relative; border-bottom: 1px solid #dbe4f0; }
.bar { width: min(24px, 35%); min-height: 3px; border-radius: 3px 3px 0 0; background: var(--primary); }
.bar.cost { background: #7c8ca5; }
.bar-group label { position: absolute; bottom: -28px; color: var(--muted); font-size: 9px; }
.chart-legend { display: flex; align-items: center; gap: 15px; padding: 20px 16px 13px; color: var(--muted); font-size: 9px; }
.chart-legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 2px; background: var(--primary); }
.chart-legend span:last-child::before { background: #7c8ca5; }

.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-state svg { width: 30px; height: 30px; margin-bottom: 8px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(10, 25, 52, .52); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(620px, 100%); max-height: calc(100vh - 40px); overflow: auto; border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.order-workspace-modal { width: min(880px, 100%); background: var(--canvas); }
.order-workspace-modal .modal-header { position: sticky; top: 0; z-index: 8; background: #fff; }
.small-modal { width: min(430px, 100%); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 4px 0 0; font-size: 18px; }
.order-form { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 22px; }
.order-workspace-form { grid-template-columns: 1fr; gap: 14px; padding: 18px 20px 20px; }
.order-create-section { overflow: visible; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.order-create-section .detail-section-head { border-radius: 8px 8px 0 0; }
.order-create-section .detail-section-head h3 { display: flex; align-items: center; gap: 7px; }
.order-create-section .detail-section-head h3 svg { width: 15px; height: 15px; color: var(--primary); }
.order-step { min-width: 28px; color: #7b879b; font-size: 10px; font-weight: 800; text-align: right; }
.order-create-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; padding: 14px; }
.order-create-grid.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.initial-status { display: flex; align-items: center; gap: 9px; padding-top: 1px; }
.initial-status small { color: var(--muted); font-size: 9px; font-weight: 500; }
.order-workflow-preview { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); padding: 6px 14px 14px; }
.order-workflow-preview > span { min-width: 0; display: grid; justify-items: center; gap: 7px; padding: 10px 6px; border-right: 1px solid var(--line); color: var(--muted); text-align: center; }
.order-workflow-preview > span:last-child { border-right: 0; }
.order-workflow-preview svg { width: 17px; height: 17px; color: var(--primary); }
.order-workflow-preview b { font-size: 9px; font-weight: 700; }
.order-workspace-form > .form-note { grid-column: auto; }
.order-workspace-form > .modal-footer { position: sticky; bottom: -20px; z-index: 7; grid-column: auto; margin: 0 -20px -20px; padding: 13px 20px; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); }
.field { display: grid; gap: 7px; color: #44516a; font-size: 10px; font-weight: 700; }
.field.full, .form-note.full, .modal-footer.full { grid-column: 1 / -1; }
.field input, .field select { width: 100%; height: 40px; border: 1px solid #d5dfec; border-radius: 6px; padding: 0 10px; outline: 0; color: var(--ink); background: #fff; font-size: 12px; }
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.customer-combobox { position: relative; }
.customer-combobox > label { color: #44516a; font-size: 10px; font-weight: 700; }
.customer-selection-hint { color: var(--muted); font-size: 9px; font-weight: 500; line-height: 1.4; }
.customer-selection-hint.selected { color: var(--primary); }
.customer-suggestions { position: absolute; top: 65px; right: 0; left: 0; z-index: 6; max-height: 244px; overflow-y: auto; border: 1px solid #d5dfec; border-radius: 6px; background: #fff; box-shadow: 0 12px 28px rgba(24, 54, 98, .16); }
.customer-suggestions[hidden] { display: none; }
.customer-suggestion { display: grid; width: 100%; gap: 4px; padding: 10px 12px; border: 0; border-bottom: 1px solid #edf1f7; color: var(--ink); background: #fff; text-align: left; cursor: pointer; }
.customer-suggestion:last-child { border-bottom: 0; }
.customer-suggestion:hover, .customer-suggestion.active { background: var(--primary-soft); }
.customer-suggestion strong { font-size: 11px; font-weight: 750; }
.customer-suggestion span { overflow: hidden; color: var(--muted); font-size: 9px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.customer-suggestion-empty { padding: 12px; color: var(--muted); font-size: 10px; font-weight: 500; }
.form-note { display: flex; gap: 8px; padding: 11px; border-radius: 6px; color: #405677; background: var(--primary-soft); font-size: 10px; line-height: 1.5; }
.form-note svg { width: 15px; color: var(--primary); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 5px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 200; display: flex; align-items: center; gap: 9px; padding: 12px 15px; border-radius: 7px; color: #fff; background: #12315f; box-shadow: var(--shadow); font-size: 11px; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.auth-gate { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 20px; background: #eef3fa; }
.auth-gate[hidden] { display: none; }
.auth-card { width: min(420px, 100%); border: 1px solid var(--line); border-radius: 8px; padding: 28px; background: #fff; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 34px; }
.auth-brand .brand-mark { color: #fff; }
.auth-brand strong { font-size: 14px; }
.auth-card h2 { margin: 6px 0 8px; font-size: 23px; }
.auth-card > p { margin: 0 0 22px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.auth-form { display: grid; gap: 14px; }
.auth-switch { justify-content: center; width: 100%; }
.auth-data-note { display: flex; align-items: flex-start; gap: 9px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.65; }
.auth-data-note svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; color: var(--primary); }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .7fr); gap: 18px; align-items: start; }
.settings-section { overflow: hidden; }
.settings-side { display: grid; gap: 18px; }
.settings-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; padding: 18px; border-bottom: 1px solid var(--line); }
.settings-form .primary-button { min-height: 38px; white-space: nowrap; }
.download-qr { display: grid; justify-items: center; gap: 12px; padding: 24px; text-align: center; }
.download-qr code { max-width: 100%; overflow-wrap: anywhere; color: var(--muted); font-size: 10px; }
.qr-box { width: 174px; min-height: 174px; display: grid; place-items: center; padding: 9px; border: 1px solid var(--line); background: #fff; }
.qr-box img, .qr-box canvas { display: block; width: 156px; height: 156px; }
.invite-result { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 24px; align-items: center; margin-top: 18px; padding: 22px; border: 1px solid #b9d4fb; border-radius: 8px; background: #f3f8ff; }
.invite-result h3 { margin: 5px 0 6px; font-size: 16px; }
.invite-result p { max-width: 680px; margin: 0 0 14px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.invite-result dl { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 7px 12px; margin: 0; font-size: 11px; }
.invite-result dt { color: var(--muted); }
.invite-result dd { margin: 0; overflow-wrap: anywhere; }
.invite-result code { padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--text); font-size: 12px; }
.permission-panel { display: grid; justify-items: center; gap: 8px; padding: 52px 20px; text-align: center; }
.permission-panel > svg { width: 28px; height: 28px; color: var(--primary); }
.permission-panel h3, .permission-panel p { margin: 0; }
.permission-panel p { color: var(--muted); font-size: 11px; }
.restricted-value { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 600; }
.restricted-value svg { width: 13px; height: 13px; }
.permission-note { margin: 18px; padding: 12px; border: 1px solid var(--line); background: #f7f9fc; color: var(--muted); font-size: 11px; }
.member-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; }
.admin-export { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px; }
.admin-export > div { display: flex; align-items: center; gap: 10px; }
.admin-export > div > svg { width: 20px; color: var(--primary); }
.admin-export span { display: grid; gap: 2px; }
.admin-export small { color: var(--muted); font-size: 9px; }
.auth-submit { width: 100%; min-height: 42px; margin-top: 4px; }
.auth-error { margin: 0 !important; padding: 9px 10px; border-radius: 6px; color: var(--red) !important; background: var(--red-soft); font-size: 10px !important; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 89; background: rgba(10, 25, 52, .36); }
.drawer-backdrop[hidden] { display: none; }
.detail-drawer { position: fixed; top: 0; right: 0; z-index: 90; width: min(760px, 100vw); height: 100vh; display: flex; flex-direction: column; transform: translateX(102%); background: var(--canvas); box-shadow: -16px 0 44px rgba(19, 43, 82, .18); transition: transform .2s ease; }
.detail-drawer.open { transform: translateX(0); }
.detail-drawer-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: #fff; }
.detail-drawer-header h2 { margin: 4px 0 0; font-size: 18px; }
.detail-drawer-body { min-height: 0; overflow-y: auto; padding: 18px 20px 36px; }
.detail-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.detail-summary div { padding: 13px; border-right: 1px solid var(--line); }
.detail-summary div:last-child { border-right: 0; }
.detail-summary span, .detail-summary strong { display: block; }
.detail-summary span { color: var(--muted); font-size: 9px; }
.detail-summary strong { margin-top: 5px; overflow-wrap: anywhere; font-size: 12px; }
.detail-section { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.detail-section-head { min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.detail-section-head h3 { margin: 0; font-size: 12px; }
.detail-section-head p { margin: 3px 0 0; color: var(--muted); font-size: 9px; }
.compact-button { min-height: 30px; padding: 0 9px; }
.detail-form { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--line); background: #f8faff; }
.detail-form.open { display: grid; }
.detail-form .field input, .detail-form .field select { height: 35px; font-size: 10px; }
.detail-form textarea { min-height: 64px; resize: vertical; border: 1px solid #d5dfec; border-radius: 6px; padding: 9px; font: inherit; font-size: 10px; }
.detail-form footer { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.detail-list { padding: 0 14px; }
.product-row, .purchase-row { display: grid; grid-template-columns: minmax(0, 1.5fr) .8fr .8fr 1fr auto; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #edf1f7; font-size: 10px; }
.product-row:last-child, .purchase-row:last-child { border-bottom: 0; }
.product-row strong, .product-row small, .purchase-row strong, .purchase-row small { display: block; }
.product-row small, .purchase-row small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.milestone-list { padding: 6px 14px 10px; }
.milestone-row { position: relative; display: grid; grid-template-columns: 25px minmax(0, 1fr) auto; gap: 10px; min-height: 58px; padding: 9px 0; }
.milestone-row:not(:last-child)::after { content: ""; position: absolute; left: 12px; top: 39px; bottom: -9px; width: 1px; background: var(--line); }
.milestone-marker { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); background: #e9eef6; }
.milestone-marker.done { color: #fff; background: var(--success); }
.milestone-marker.active { color: var(--amber); background: var(--amber-soft); }
.milestone-marker.blocked { color: var(--red); background: var(--red-soft); }
.milestone-marker svg { width: 13px; }
.milestone-copy strong, .milestone-copy small { display: block; }
.milestone-copy strong { font-size: 10px; }
.milestone-copy small { margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.milestone-actions { display: flex; align-items: start; gap: 5px; }
.milestone-actions select { height: 29px; border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; background: #fff; font-size: 9px; }
.communication-row { padding: 13px 0; border-bottom: 1px solid #edf1f7; }
.communication-row:last-child { border-bottom: 0; }
.communication-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.communication-top strong { font-size: 10px; }
.communication-top span { color: var(--muted); font-size: 9px; }
.communication-row p { margin: 7px 0 0; font-size: 10px; line-height: 1.55; }
.communication-next { color: var(--primary); }
.attachment-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) 34px 34px; gap: 9px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.attachment-row:last-child { border-bottom: 0; }
.attachment-row > svg { width: 16px; color: var(--primary); }
.attachment-row > span { display: grid; min-width: 0; gap: 3px; }
.attachment-row strong, .attachment-row small { overflow-wrap: anywhere; }
.attachment-row small { color: var(--muted); font-size: 9px; }
.shipment-row { display: grid; grid-template-columns: 1.15fr .8fr .8fr .8fr 1.35fr 104px; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.shipment-row:last-child { border-bottom: 0; }
.shipment-row > span { display: grid; min-width: 0; gap: 3px; }
.shipment-row strong, .shipment-row small { overflow-wrap: anywhere; }
.shipment-row small { color: var(--muted); font-size: 9px; }
.shipment-row select { width: 100%; min-width: 0; }
.detail-empty { padding: 20px 14px; color: var(--muted); text-align: center; font-size: 10px; }
.amount-stack strong, .amount-stack small { display: block; white-space: nowrap; }
.amount-stack small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.overdue-text { color: var(--red); font-weight: 800; }
.transaction-actions { display: flex; justify-content: flex-end; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .customer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .target-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quotation-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .search-box { display: none; }
  .fx-rate { display: none; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 232px; transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: grid !important; }
  .topbar { padding: 10px 16px; }
  .topbar-actions .notification-button { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .settings-grid, .invite-result { grid-template-columns: 1fr; }
  .settings-form { grid-template-columns: 1fr; }
  .crm-form, .target-form { grid-template-columns: 1fr 1fr; }
  .quotation-form { grid-template-columns: 1fr 1fr; }
  .task-board { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 32px; }
}

@media (max-width: 580px) {
  .topbar { align-items: center; gap: 8px; }
  .topbar-left { min-width: 0; }
  .topbar-left .eyebrow { display: none; }
  .topbar h1 { max-width: 100px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 16px; }
  .topbar-actions { gap: 5px; }
  .topbar-actions .primary-button { width: 38px; padding: 0; }
  .topbar-actions .primary-button span { display: none; }
  .segmented { height: 32px; }
  .segment { min-width: 30px; padding: 0 5px; font-size: 9px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .metric:nth-child(2) { border-bottom: 1px solid var(--line); }
  .customer-grid { grid-template-columns: 1fr; }
  .crm-form, .target-form { grid-template-columns: 1fr; }
  .quotation-form { grid-template-columns: 1fr; }
  .order-form { grid-template-columns: 1fr; padding: 17px; }
  .order-workspace-form { padding: 12px; }
  .order-create-grid, .order-create-grid.three-columns { grid-template-columns: 1fr; }
  .order-workflow-preview { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .order-workflow-preview > span:nth-child(3) { border-right: 0; }
  .order-workflow-preview > span:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .order-workspace-form > .modal-footer { bottom: -12px; margin: 0 -12px -12px; padding: 12px; }
  .field.full, .form-note.full, .modal-footer.full { grid-column: auto; }
  .summary-strip { grid-template-columns: 1fr; }
  .summary-strip > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .chart-area { gap: 8px; }
  .detail-drawer { left: 0; right: auto; width: 100vw; max-width: 100vw; }
  .detail-drawer-header { min-width: 0; padding: 12px; }
  .detail-drawer-header > div { min-width: 0; }
  .detail-drawer-header h2 { overflow-wrap: anywhere; font-size: 15px; }
  .detail-drawer-body { padding: 14px 12px 28px; overflow-x: hidden; }
  .detail-summary { grid-template-columns: repeat(2, 1fr); }
  .detail-summary div:nth-child(2) { border-right: 0; }
  .detail-summary div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .detail-form { grid-template-columns: 1fr; }
  .detail-form footer { grid-column: auto; }
  .product-row, .purchase-row { grid-template-columns: 1fr auto; }
  .product-row > *, .purchase-row > * { min-width: 0; overflow-wrap: anywhere; }
  .product-row > :nth-child(3), .purchase-row > :nth-child(3) { display: none; }
  .milestone-row { grid-template-columns: 25px minmax(0, 1fr); }
  .milestone-actions { grid-column: 2; }
  .shipment-row { grid-template-columns: 1fr 1fr; }
  .shipment-row > :nth-child(5), .shipment-row > :nth-child(6) { grid-column: 1 / -1; }
}

