/* FKM Order Portal */
:root {
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1d2330;
  --muted: #6b7280;
  --faint: #9ca3af;
  --border: #e5e7eb;
  --line: #f0f1f3;
  --primary: #714b67;
  --primary-dark: #5c3c54;
  --primary-soft: #f6eff4;
  --accent: #017e84;
  --accent-soft: #e6f4f4;
  --success: #1e7a3c; --success-soft: #e7f6ec;
  --error: #b42318;   --error-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- Header */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 2rem; height: 60px; padding: 0 1.5rem; background: #fff; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 700; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; }
.brand small { color: var(--muted); font-weight: 500; }
.topbar nav { display: flex; gap: .25rem; flex: 1; }
.topbar nav a { color: var(--muted); padding: .45rem .9rem; border-radius: 8px; font-weight: 500; }
.topbar nav a:hover { color: var(--text); background: var(--bg); }
.topbar nav a.active { color: var(--primary); background: var(--primary-soft); }
.userbox { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .9rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.avatar.lg { width: 44px; height: 44px; font-size: 1rem; }
@media (max-width: 700px) { .userbox .who { display: none; } .topbar { gap: 1rem; padding: 0 1rem; } .brand small { display: none; } }

.container { max-width: 1320px; margin: 0 auto; padding: 1.5rem; }

/* ---------- Page head */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { margin: .25rem 0 0; }
.back { display: inline-block; font-size: .9rem; margin-bottom: .35rem; }
.head-actions { display: flex; gap: .5rem; }
.title-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* ---------- Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.1rem; }
.card-head { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head .grow { flex: 1; }
.card-body { padding: 1.25rem; }
.chip { display: inline-block; background: var(--bg); color: var(--muted); border-radius: 99px; padding: 2px 10px; font-size: .78rem; font-weight: 600; }

/* ---------- Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; font-size: .92rem; padding: .55rem 1rem; border-radius: 8px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.btn-lg { padding: .85rem 1.2rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* ---------- Forms */
label { display: block; font-size: .85rem; font-weight: 600; color: #374151; margin-bottom: .35rem; }
input, select, textarea { font: inherit; font-size: .95rem; width: 100%; padding: .6rem .75rem; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(1,126,132,.12); }
input[type="search"] { padding-left: 2.2rem; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E") no-repeat .75rem center; }
.field-error { color: var(--error); font-size: .85rem; margin-top: .35rem; }
.mt { margin-top: 1rem; }

/* ---------- Quotation page layout */
.q-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.q-aside { position: sticky; top: 80px; }
@media (max-width: 1050px) { .q-layout { grid-template-columns: 1fr; } .q-aside { position: static; } }
@media (max-width: 700px) { .container { padding: 1rem; } }


/* Upload page */
.upload-page { max-width: 900px; margin: 0 auto; }
.page-head.center { justify-content: center; text-align: center; }
.page-head.center p { max-width: 640px; margin-left: auto; margin-right: auto; }
.upload-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .upload-grid { grid-template-columns: 1fr; } }
.file-drop { display: flex; align-items: center; gap: .9rem; padding: 1.1rem 1.2rem; border: 1.5px dashed #cfd3da; border-radius: 10px; background: #fafbfc; cursor: pointer; font-weight: 400; color: var(--text); margin-bottom: 0; transition: border-color .15s, background .15s; }
.file-drop .grow { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.file-drop:hover, .file-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.file-drop.has-file { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.file-drop.missing { border-color: var(--error); background: var(--error-soft); }
.file-icon { font-size: 1.8rem; }
.upload-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.25rem; }

/* Preview */
.excel-result { margin-top: .9rem; padding: .7rem .9rem; border-radius: 8px; font-size: .9rem; background: var(--bg); }
.excel-result.warn { background: #fff6e0; color: #8a5a00; }
.excel-result.error { background: var(--error-soft); color: var(--error); }
.excel-result ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.pv-warnings { margin: 0 1.25rem 1rem; }
.pv-values { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.pv-values div { display: flex; flex-direction: column; gap: .15rem; padding: .8rem 1rem; border-radius: 10px; background: var(--bg); }
.pv-values span { color: var(--muted); font-size: .85rem; }
.pv-values strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.pv-values .pv-total { background: var(--primary-soft); }
.pv-values .pv-total strong { color: var(--primary); font-size: 1.4rem; }
.pv-note { padding: 0 1.25rem 1.1rem; }
@media (max-width: 600px) { .pv-values { grid-template-columns: 1fr; } }

/* Files on a quotation */
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.file-list li:last-child { border-bottom: 0; }
.file-list a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: .5rem; margin-top: .75rem; }
.thumbs a { display: block; aspect-ratio: 1; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.thumbs img { width: 100%; height: 100%; object-fit: contain; }

/* Customer picker */
.autocomplete { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.12); max-height: 320px; overflow: auto; z-index: 40; min-width: 300px; }
.ac-list li { display: flex; align-items: center; gap: .65rem; padding: .5rem .6rem; border-radius: 7px; cursor: pointer; }
.ac-list li:hover, .ac-list li.hl { background: var(--primary-soft); }
.ac-list li div { display: flex; flex-direction: column; min-width: 0; }
.ac-list li small { color: var(--muted); }
.ac-list li.empty { color: var(--muted); cursor: default; }

/* Product lines */
.segmented { display: inline-flex; background: var(--bg); border-radius: 8px; padding: 3px; }
.segmented button { border: 0; background: none; font: inherit; font-size: .85rem; font-weight: 600; color: var(--muted); padding: .35rem .75rem; border-radius: 6px; cursor: pointer; }
.segmented button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

.lines { width: 100%; border-collapse: collapse; font-size: .92rem; }
.lines th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: .6rem .75rem; border-bottom: 1px solid var(--border); background: #fafafb; }
.lines td { padding: .5rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lines tr.is-zero .p-name, .lines tr.is-zero .line-total { color: var(--muted); }
.lines tr.is-set td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.lines .p-name { font-weight: 500; }
.lines .p-meta { display: flex; gap: .4rem; align-items: center; margin-top: .15rem; font-size: .78rem; color: var(--muted); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); padding: 0 5px; border-radius: 4px; font-size: .75rem; color: var(--muted); }
.lines .section td { background: #fafafb; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: #374151; }
.lines .note td { font-style: italic; color: var(--muted); }
.tag { display: inline-block; background: var(--bg); border-radius: 99px; padding: 1px 8px; font-size: .75rem; white-space: nowrap; color: #4b5563; }
.empty-row td { text-align: center; color: var(--muted); padding: 2rem; }
.table-scroll { overflow-x: auto; }

/* Summary aside */
.summary-list { list-style: none; margin: 0; padding: 0; }
.summary-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; font-size: .9rem; }
.summary-list li span:first-child { color: var(--muted); }
.summary-list li span:last-child { text-align: right; font-weight: 500; }
.summary-list .missing { color: var(--error) !important; }
.totals { border-top: 1px solid var(--line); margin-top: .6rem; padding-top: .6rem; }
.totals .grand { border-top: 1px solid var(--border); margin-top: .4rem; padding-top: .7rem; font-size: 1.25rem; }
.totals .grand span { color: var(--text) !important; font-weight: 700 !important; }
.aside-note { font-size: .8rem; color: var(--muted); margin: .75rem 0 0; }

/* ---------- Status pills */
.status { display: inline-flex; align-items: center; gap: .35rem; padding: 3px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-draft { background: #eef2ff; color: #4338ca; }
.status-sent { background: #e0f2fe; color: #0369a1; }
.status-sale { background: var(--success-soft); color: var(--success); }
.status-cancel { background: var(--error-soft); color: var(--error); }

/* ---------- List page */
.list-tools { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list-tools input[type="search"] { max-width: 320px; }
.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
.list th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: .7rem 1.25rem; border-bottom: 1px solid var(--border); background: #fafafb; }
.list td { padding: .85rem 1.25rem; border-bottom: 1px solid var(--line); }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover { background: #fafafb; }
.empty-state { text-align: center; padding: 3.5rem 1rem; color: var(--muted); }
.empty-state .big { font-size: 2.5rem; margin-bottom: .5rem; }
.empty-state h2 { color: var(--text); margin-bottom: .4rem; }

/* ---------- Detail page */
.facts { margin: 0; }
.facts div { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; text-align: right; }

/* Confirm + manufacturing */
.confirm-panel { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(113,75,103,.12); }
.confirm-panel h2 { margin-bottom: .5rem; }
.confirm-panel p { margin: 0 0 1rem; max-width: 720px; }
.mo-list { list-style: none; margin: 0; padding: 0; }
.mo-list li { display: flex; align-items: center; gap: .6rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.mo-list li:last-child { border-bottom: 0; }
.mo-list li div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.status-mo-confirmed { background: #e0f2fe; color: #0369a1; }
.status-mo-progress, .status-mo-to_close { background: #fff6e0; color: #8a5a00; }
.status-mo-done { background: var(--success-soft); color: var(--success); }
.status-mo-cancel { background: var(--error-soft); color: var(--error); }

/* Manufacturing */
.avail { display: inline-block; font-size: .8rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.avail-available { background: var(--success-soft); color: var(--success); }
.avail-expected { background: #e0f2fe; color: #0369a1; }
.avail-late, .avail-unavailable { background: var(--error-soft); color: var(--error); }
.progress-steps { display: flex; list-style: none; margin: 0 0 1.25rem; padding: 0; gap: .5rem; flex-wrap: wrap; }
.progress-steps li { display: flex; align-items: center; gap: .5rem; padding: .4rem .9rem .4rem .45rem; border-radius: 99px; background: #fff; border: 1px solid var(--border); color: var(--muted); font-size: .88rem; font-weight: 500; }
.progress-steps li span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); font-size: .8rem; font-weight: 700; }
.progress-steps li.done { color: var(--success); border-color: #bfe5cb; background: var(--success-soft); }
.progress-steps li.done span { background: var(--success); color: #fff; }
.progress-steps li.current { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.progress-steps li.current span { background: var(--primary); color: #fff; }

/* ---------- Flash / toasts */
.flashes { position: fixed; top: 72px; right: 1.25rem; z-index: 50; display: flex; flex-direction: column; gap: .5rem; max-width: 420px; }
.flash { display: flex; align-items: flex-start; gap: .75rem; padding: .85rem 1rem; border-radius: 10px; background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--accent); box-shadow: 0 10px 30px rgba(0,0,0,.12); font-size: .92rem; animation: slidein .25s ease; }
.flash span { flex: 1; }
.flash button { background: none; border: 0; font-size: 1.1rem; cursor: pointer; color: var(--muted); line-height: 1; }
.flash-success { border-left-color: var(--success); }
.flash-error { border-left-color: var(--error); }
.flash-warning { border-left-color: #e0a100; }
@keyframes slidein { from { transform: translateY(-8px); opacity: 0; } }

/* ---------- Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(circle at 20% 20%, #f6eff4, transparent 50%), radial-gradient(circle at 80% 80%, #e6f4f4, transparent 50%), var(--bg); }
.login-card { width: 100%; max-width: 400px; padding: 2rem; display: flex; flex-direction: column; gap: 1rem; }
.login-card .brand { font-size: 1.15rem; }
.login-card p { margin: 0; }

/* ---------- Error page */
.error-box { max-width: 560px; margin: 3rem auto; text-align: center; padding: 2.5rem 2rem; }
