/* ── Reset & base ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f0f2f5;
  --surface:   #ffffff;
  --border:    #e0e4ea;
  --primary:   #1a6fc4;
  --primary-h: #155da0;
  --accent:    #0ea87a;
  --danger:    #d93025;
  --text:      #1a1d23;
  --muted:     #6b7280;
  --radius:    10px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ─────────────────────────────────────── */
.site-header {
  background: var(--primary);
  color: #fff;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  position: sticky; top: 0; z-index: 100;
}
.header-inner { display:flex; align-items:center; justify-content:space-between; width:100%; }
.logo { font-size:16px; font-weight:700; letter-spacing:.5px; }
.site-header nav { display:flex; gap:20px; align-items:center; }
.site-header nav a { color:#ffffffcc; font-size:13px; transition:color .15s; }
.site-header nav a:hover { color:#fff; text-decoration:none; }
.btn-logout { background:#ffffff22; padding:4px 12px; border-radius:6px; }
.btn-logout:hover { background:#ffffff33; }

/* ── Main wrap ───────────────────────────────────── */
.main-wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px; }

/* ── Flash messages ─────────────────────────────── */
.flash {
  padding: 10px 16px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 13px;
}
.flash-error   { background:#fde8e8; color:#b91c1c; border:1px solid #fca5a5; }
.flash-success { background:#dcfce7; color:#166534; border:1px solid #86efac; }

/* ── Card ────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}
.card h2 { font-size:15px; font-weight:700; margin-bottom:16px; color:var(--text); }
.card h3 { font-size:14px; font-weight:600; margin-bottom:10px; color:var(--text); }

/* ── Auth card ───────────────────────────────────── */
.auth-card {
  max-width: 420px; margin: 60px auto;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 36px 40px;
}
.auth-card h1 { font-size:22px; margin-bottom:8px; }
.auth-hint { color:var(--muted); margin-bottom:24px; font-size:13px; }
.token-ok { color: var(--accent); font-weight:600; margin-bottom:16px; font-size:13px; }

/* ── Form fields ────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display:block; font-size:13px; font-weight:600;
  color:var(--muted); margin-bottom:6px; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 14px; color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,111,196,.12);
}
select:disabled { background: #f5f5f5; color: var(--muted); }

/* ── Buttons ────────────────────────────────────── */
.btn-primary {
  display:inline-block; padding:10px 22px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 7px;
  font-size:14px; font-weight:600; cursor:pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--primary-h); }
.btn-primary:disabled { background:#9db8d9; cursor:not-allowed; }
.btn-primary.btn-full { width:100%; margin-top:4px; }
.btn-secondary {
  display:inline-block; padding:10px 22px;
  background:#f3f4f6; color:var(--text);
  border:1px solid var(--border); border-radius:7px;
  font-size:14px; cursor:pointer; margin-left:8px;
}
.btn-secondary:hover { background:#e5e7eb; text-decoration:none; }
.btn-sm {
  padding: 4px 10px; font-size:12px;
  background:#f3f4f6; border:1px solid var(--border);
  border-radius:5px; cursor:pointer;
}
.btn-sm:hover { background:#e5e7eb; }
.btn-danger { background:#fee2e2; border-color:#fca5a5; color:var(--danger); }
.btn-danger:hover { background:#fecaca; }

/* ── Period buttons ─────────────────────────────── */
.period-buttons { display:flex; flex-wrap:wrap; gap:6px; }
.period-btn {
  padding:5px 12px; border:1px solid var(--border);
  border-radius:20px; background:#f3f4f6;
  font-size:13px; cursor:pointer; transition:all .15s;
}
.period-btn.active {
  background: var(--primary); color:#fff;
  border-color: var(--primary);
}
.period-btn:hover:not(.active) { background:#e5e7eb; }

/* ── Autocomplete ───────────────────────────────── */
.autocomplete-wrap { position:relative; }
.suggestions-list {
  position:absolute; top:100%; left:0; right:0;
  background:var(--surface); border:1px solid var(--border);
  border-radius:7px; box-shadow:var(--shadow);
  max-height:220px; overflow-y:auto; z-index:200;
  list-style:none; padding:4px 0;
}
.suggestions-list.hidden { display:none; }
.suggestions-list li {
  padding:8px 14px; cursor:pointer; font-size:13px;
  border-bottom:1px solid #f5f5f5;
}
.suggestions-list li:hover { background:#f0f4ff; }

/* ── Quote layout ───────────────────────────────── */
.quote-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 768px) {
  .quote-layout { grid-template-columns: 1fr; }
}
.quote-form-panel { position:sticky; top:72px; }
.quote-result-panel { display:flex; flex-direction:column; gap:20px; }

/* ── Placeholder ────────────────────────────────── */
.placeholder-msg {
  text-align:center; padding:60px 20px;
  color:var(--muted); font-size:15px;
  background:var(--surface); border-radius:var(--radius);
  border:2px dashed var(--border);
}

/* ── Result card ────────────────────────────────── */
.result-card.hidden { display:none; }

/* Distribution bar */
.dist-block { margin-bottom:20px; }
.dist-label { font-size:12px; color:var(--muted); margin-bottom:8px; }
.dist-bar-wrap { }
.dist-bar {
  display:flex; align-items:center; gap:8px;
  height:28px; margin-bottom:6px;
}
.dist-range {
  flex:1; height:14px; background:#dbeafe; border-radius:4px;
  position:relative; display:flex; align-items:center; justify-content:center;
}
.dist-median {
  width:3px; height:22px; background:var(--primary);
  border-radius:2px; position:absolute; left:50%;
}
.dist-min, .dist-max { font-size:12px; color:var(--muted); white-space:nowrap; }
.dist-labels {
  display:flex; justify-content:space-between;
  font-size:11px; color:var(--muted);
}
.dist-labels strong { color:var(--primary); font-size:13px; }

.unit-note { font-size:12px; color:var(--muted); margin-bottom:16px; }

/* Rec grid */
.rec-block { background:#f8faff; border-radius:8px; padding:16px; margin-bottom:16px; }
.rec-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:10px; margin-bottom:12px; }
.rec-item {
  background:var(--surface); border:1px solid var(--border);
  border-radius:7px; padding:10px 14px;
}
.rec-item.highlight { border-color:var(--primary); background:#eff6ff; }
.rec-label { display:block; font-size:11px; color:var(--muted); margin-bottom:3px; }
.rec-value { font-size:18px; font-weight:700; color:var(--text); }
.rec-value small { font-size:11px; font-weight:400; color:var(--muted); }
.rec-item.highlight .rec-value { color:var(--primary); }

.price-range {
  font-size:13px; color:var(--muted); margin-bottom:10px;
  display:flex; align-items:center; gap:6px; flex-wrap:wrap;
}
.range-low  { color:#15803d; font-weight:600; }
.range-high { color:#b45309; font-weight:600; }
.range-sep  { color:var(--muted); }
.strategy-note { font-size:12px; color:var(--muted); font-style:italic; }

/* Customer block */
.customer-block { margin-top:16px; padding-top:16px; border-top:1px solid var(--border); }
.customer-list { list-style:none; display:flex; flex-direction:column; gap:4px; }
.customer-list li {
  display:flex; justify-content:space-between;
  font-size:13px; padding:4px 0;
  border-bottom:1px solid #f5f5f5;
}
.cname { color:var(--text); }
.ccnt  { color:var(--muted); font-size:12px; }

/* AI block */
.ai-text { min-height:60px; }
.ai-body { font-size:14px; line-height:1.8; color:var(--text); }
.loading-text { color:var(--muted); font-style:italic; }
.error-text   { color:var(--danger); }
.muted        { color:var(--muted); }

/* Spinner */
.spinner {
  display:inline-block; width:14px; height:14px;
  border:2px solid #ddd; border-top-color:var(--primary);
  border-radius:50%; animation:spin .7s linear infinite;
  vertical-align:middle; margin-left:8px;
}
.spinner.hidden { display:none; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ── Admin ──────────────────────────────────────── */
.admin-wrap { max-width:860px; }
.admin-wrap h1 { font-size:20px; margin-bottom:20px; }
.admin-wrap .card { margin-bottom:20px; }
.admin-wrap h2 { font-size:15px; margin-bottom:14px; }
.inline-form { display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.inline-form input { flex:1; min-width:120px; }
.checkbox-label { display:flex; align-items:center; gap:6px; font-size:13px; cursor:pointer; }
.checkbox-label input { width:auto; }

.data-table { width:100%; border-collapse:collapse; font-size:13px; }
.data-table th {
  text-align:left; padding:8px 12px;
  background:#f8f9fa; border-bottom:2px solid var(--border);
  font-weight:600; color:var(--muted);
}
.data-table td { padding:9px 12px; border-bottom:1px solid var(--border); }
.data-table tr:hover td { background:#f8faff; }
.actions { display:flex; gap:8px; }

/* ── Admin data status ──────────────────────── */
.data-status { margin-bottom:16px; }
.status-row  { display:flex; align-items:center; gap:10px; padding:6px 0;
               border-bottom:1px solid var(--border); font-size:13px; }
.status-row.warn { color:#b45309; }
.status-label { font-weight:600; color:var(--muted); min-width:80px; }
.badge-ok   { color:#166534; background:#dcfce7; padding:2px 8px; border-radius:10px; font-size:12px; }
.badge-warn { color:#92400e; background:#fef3c7; padding:2px 8px; border-radius:10px; font-size:12px; }

.upload-area { margin-top:16px; }
.upload-row  { display:flex; gap:10px; align-items:center; margin-bottom:8px; }
.file-label  { display:flex; align-items:center; gap:8px; cursor:pointer;
               padding:8px 14px; border:1px solid var(--border);
               border-radius:7px; background:#f3f4f6; font-size:13px; }
.file-label input[type=file] { display:none; }
.file-label:hover { background:#e5e7eb; }
.hint { font-size:12px; color:var(--muted); line-height:1.6; }

/* ── Match badges ───────────────────────────── */
.match-badge {
  background:#eff6ff; border:1px solid #bfdbfe;
  color:#1e40af; border-radius:7px;
  padding:8px 14px; font-size:13px; margin-bottom:14px;
}
.no-match-badge {
  background:#f8faff; border:1px solid var(--border);
  color:var(--muted); border-radius:7px;
  padding:8px 14px; font-size:13px; margin-bottom:14px;
}
.all-ref {
  font-size:12px; color:var(--muted);
  background:#f9fafb; border-radius:6px;
  padding:6px 12px; margin-bottom:10px;
}

/* ── Customer table ─────────────────────────── */
.customer-block { margin-top:16px; padding-top:16px; border-top:1px solid var(--border); }
.cust-table { width:100%; border-collapse:collapse; font-size:13px; }
.cust-table th { text-align:left; padding:6px 10px;
  background:#f8f9fa; border-bottom:2px solid var(--border);
  font-weight:600; color:var(--muted); }
.cust-table td { padding:7px 10px; border-bottom:1px solid var(--border); }
.cust-table tr:hover td { background:#f8faff; }
.highlight-row td { background:#eff6ff !important; font-weight:500; }

/* ── Dist labels (simplified) ───────────────── */
.dist-labels {
  display:flex; justify-content:space-between;
  font-size:12px; color:var(--muted);
  margin-top:6px; flex-wrap:wrap; gap:4px;
}
.dist-labels strong { color:var(--primary); font-size:14px; }

/* ── 修复 dist-block ────────────────────────── */
.dist-block {
  background: #f8faff;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 14px;
}
.dist-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 600;
}
.dist-labels {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
}
.dist-labels span {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  padding: 6px 4px;
  background: var(--surface);
  border-radius: 5px;
  border: 1px solid var(--border);
}
.dist-labels strong {
  display: block;
  font-size: 15px;
  color: var(--primary);
  margin-top: 2px;
}

/* ── 修复 price-range ───────────────────────── */
.price-range {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 14px;
  margin-bottom: 10px;
}
.range-low  { color: #15803d; font-weight: 700; font-size: 15px; }
.range-high { color: #b45309; font-weight: 700; font-size: 15px; }
.range-sep  { color: var(--muted); font-size: 16px; }

/* ── 修复 cust-table ────────────────────────── */
.customer-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.customer-block h3 {
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.cust-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}
.cust-table th {
  text-align: center;
  padding: 8px 10px;
  background: #f3f4f6;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
}
.cust-table th:first-child { text-align: left; }
.cust-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f0f0f0;
  text-align: center;
  vertical-align: middle;
}
.cust-table td:first-child { text-align: left; font-weight: 500; }
.cust-table tr:last-child td { border-bottom: none; }
.cust-table tr:hover td { background: #f8faff; }
.highlight-row td { background: #eff6ff !important; }
.highlight-row td:first-child { color: var(--primary); }

/* ── strategy-note 间距 ─────────────────────── */
.strategy-note {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

/* ── unit-note 间距 ─────────────────────────── */
.unit-note {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
  padding: 6px 12px;
  background: #f0fdf4;
  border-radius: 5px;
  border-left: 3px solid var(--accent);
}

/* ── Match badge extras ─────────────────────── */
.match-cust-list {
  font-size: 12px;
  color: #3b5bdb;
  margin-top: 4px;
  display: block;
}

/* ── Cross-bandwidth block ──────────────────── */
.crossbw-block {
  margin-top: 16px;
  padding: 14px 16px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
}
.crossbw-block h3 {
  font-size: 13px;
  color: #92400e;
  margin-bottom: 8px;
}
.crossbw-note {
  font-size: 12px;
  color: #78350f;
  margin-bottom: 10px;
}

/* ── Match badge warn variant ───────────────── */
.match-badge-warn {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}
.match-badge-warn .match-cust-list {
  color: #78350f;
}

/* ── Match badge line breaks ────────────────── */
.match-badge br { display: block; margin-top: 4px; }

/* ── Cross-bw primary variant ───────────────── */
.crossbw-primary {
  background: #eff6ff;
  border-color: #93c5fd;
}
.crossbw-primary h3 { color: var(--primary); }
.crossbw-primary .crossbw-note { color: #1e40af; }

/* ── Bandwidth input row ────────────────────── */
.bw-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.bw-input-row input[type=number] {
  flex: 1;
}
.bw-input-row select {
  width: 70px;
  flex-shrink: 0;
}

/* ── Bandwidth hint ─────────────────────────── */
.bw-hint {
  font-size: 12px;
  margin-top: 6px;
  padding: 5px 10px;
  border-radius: 5px;
}
.bw-hint.hidden { display: none; }
.bw-hint.info   { background: #f0f4ff; color: var(--muted); }
.bw-hint.ok     { background: #dcfce7; color: #166534; }
.bw-hint.warn   { background: #fef3c7; color: #92400e; }

/* ── Interpolation notice ───────────────────── */
.interp-notice {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 12px;
  color: #78350f;
  margin-bottom: 14px;
}

/* ── Bandwidth input row ────────────────────── */
.bw-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.bw-input-row input[type=number] {
  flex: 1;
}
.bw-input-row select {
  width: 70px;
  flex-shrink: 0;
}

/* ── Bandwidth hint ─────────────────────────── */
.bw-hint {
  font-size: 12px;
  margin-top: 6px;
  padding: 5px 10px;
  border-radius: 5px;
}
.bw-hint.hidden { display: none; }
.bw-hint.info   { background: #f0f4ff; color: var(--muted); }
.bw-hint.ok     { background: #dcfce7; color: #166534; }
.bw-hint.warn   { background: #fef3c7; color: #92400e; }

/* ── Interpolation notice ───────────────────── */
.interp-notice {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 12px;
  color: #78350f;
  margin-bottom: 14px;
}

/* ── Fix bw-input-row layout ────────────────── */
.bw-input-row {
  display: flex !important;
  flex-direction: row !important;
  gap: 8px;
  align-items: center;
}
.bw-input-row input[type=number] {
  flex: 1;
  width: auto !important;
}
.bw-input-row select {
  width: 70px !important;
  flex-shrink: 0;
}
