/* ==========================================================================
   Seago Marine Enterprise Design System v2.0
   Aesthetic: Modern B2B AI Workbench (Linear / Stripe / Feishu Pro inspired)
   ========================================================================== */

:root,
html[data-sg-theme="airy"] {
  --sg-bg: #f6f8fb;
  --sg-surface: #ffffff;
  --sg-surface-2: #f8fafc;
  --sg-surface-3: #f1f5f9;
  --sg-ink: #0f172a;
  --sg-ink-2: #334155;
  --sg-mut: #64748b;
  --sg-line: #e2e8f0;
  --sg-line-strong: #cbd5e1;
  --sg-primary: #2563eb;
  --sg-primary-light: #3b82f6;
  --sg-primary-hover: #1d4ed8;
  --sg-primary-soft: #eff6ff;
  --sg-primary-border: #bfdbfe;
  --sg-success: #059669;
  --sg-success-soft: #ecfdf5;
  --sg-warn: #d97706;
  --sg-warn-soft: #fffbeb;
  --sg-danger: #dc2626;
  --sg-danger-soft: #fef2f2;
  --sg-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --sg-shadow-card: 0 1px 3px rgba(15, 23, 42, 0.04), 0 6px 16px rgba(15, 23, 42, 0.025);
  --sg-shadow-pop: 0 20px 48px -12px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.05);

  /* Sidebar tokens (Airy Light Sidebar default) */
  --sg-rail-bg: #ffffff;
  --sg-rail-border: #e2e8f0;
  --sg-rail-text: #334155;
  --sg-rail-muted: #64748b;
  --sg-rail-hover-bg: #f1f5f9;
  --sg-rail-hover-text: #0f172a;
  --sg-rail-active-bg: #eff6ff;
  --sg-rail-active-text: #2563eb;
  --sg-rail-brand-sub: #64748b;

  /* Bridge legacy variables across all pages */
  --ink: var(--sg-ink);
  --mut: var(--sg-mut);
  --line: var(--sg-line);
  --teal: var(--sg-primary);
  --deep: #0f172a;
  --bg: var(--sg-bg);
}

/* Preset 2: Deep Ocean Pro Sidebar (Linear / Stripe Midnight Rail) */
html[data-sg-theme="ocean"] {
  --sg-rail-bg: #0f172a;
  --sg-rail-border: #1e293b;
  --sg-rail-text: #cbd5e1;
  --sg-rail-muted: #94a3b8;
  --sg-rail-hover-bg: #1e293b;
  --sg-rail-hover-text: #f8fafc;
  --sg-rail-active-bg: #2563eb;
  --sg-rail-active-text: #ffffff;
  --sg-rail-brand-sub: #94a3b8;
}

/* Preset 3: Nordic Emerald */
html[data-sg-theme="emerald"] {
  --sg-primary: #0d9488;
  --sg-primary-light: #14b8a6;
  --sg-primary-hover: #0f766e;
  --sg-primary-soft: #f0fdfa;
  --sg-primary-border: #99f6e4;
  --sg-rail-bg: #0b2226;
  --sg-rail-border: #15373d;
  --sg-rail-text: #cbd5e1;
  --sg-rail-muted: #94a3b8;
  --sg-rail-hover-bg: #15383e;
  --sg-rail-hover-text: #ffffff;
  --sg-rail-active-bg: #0d9488;
  --sg-rail-active-text: #ffffff;
  --sg-rail-brand-sub: #88b5b2;
  --teal: #0d9488;
}

/* Global Typography & Smooth Surface */
html {
  font: 14.5px/1.55 "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif !important;
  color: var(--sg-ink) !important;
  background-color: var(--sg-bg) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background:
    radial-gradient(ellipse 90% 340px at 50% -120px, rgba(37, 99, 235, 0.055), transparent),
    var(--sg-bg) !important;
  color: var(--sg-ink) !important;
}

h1 {
  font-size: clamp(21px, 2vw, 25px) !important;
  font-weight: 700 !important;
  letter-spacing: -0.025em !important;
  color: var(--sg-ink) !important;
}

h2 {
  font-size: 17px !important;
  font-weight: 650 !important;
  letter-spacing: -0.015em !important;
  color: var(--sg-ink) !important;
}

h3 {
  font-size: 15px !important;
  font-weight: 600 !important;
  color: var(--sg-ink) !important;
}

/* Modern Cards & Panels */
.panel,
aside,
.inquiry-detail,
.funnel-card,
.kpi,
.card {
  background: var(--sg-surface) !important;
  border: 1px solid var(--sg-line) !important;
  border-radius: 14px !important;
  box-shadow: var(--sg-shadow-card) !important;
}

.inquiry-detail > #panel {
  border: 0 !important;
  border-top: 1px solid var(--sg-line) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.head,
.panelhead,
.panel-head,
.workflow-head,
.toolbar {
  border-color: var(--sg-line) !important;
}

/* Refined Buttons */
button:not(.mail):not(.metric):not(.card):not(.f-step),
a.btn {
  border-radius: 8px !important;
  border: 1px solid var(--sg-line-strong);
  background: var(--sg-surface);
  color: var(--sg-ink-2);
  font-size: 13.5px;
  font-weight: 600;
  padding: 6px 13px;
  box-shadow: var(--sg-shadow-sm);
  transition: all 0.14s cubic-bezier(0.16, 1, 0.3, 1);
}

button:not(:disabled):not(.primary):not(.mail):not(.metric):hover,
a.btn:not(.primary):hover {
  border-color: var(--sg-primary) !important;
  color: var(--sg-primary) !important;
  background: var(--sg-primary-soft);
}

button:not(:disabled):active {
  transform: translateY(0.5px);
}

button.primary,
a.btn.primary {
  background: linear-gradient(180deg, var(--sg-primary-light) 0%, var(--sg-primary) 100%) !important;
  border-color: var(--sg-primary) !important;
  color: #ffffff !important;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.18) !important;
}

button.primary:not(:disabled):hover,
a.btn.primary:hover {
  background: var(--sg-primary-hover) !important;
  border-color: var(--sg-primary-hover) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.26) !important;
}

/* Inputs, Selects & Textareas */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  border: 1px solid var(--sg-line-strong) !important;
  border-radius: 8px !important;
  background-color: var(--sg-surface) !important;
  color: var(--sg-ink) !important;
  font-size: 13.5px !important;
  transition: border-color 0.14s ease, box-shadow 0.14s ease !important;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: none !important;
  border-color: var(--sg-primary) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14) !important;
}

/* Modern Data Tables & Spreadsheet Grids */
table th {
  background: var(--sg-surface-2) !important;
  color: #475569 !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--sg-line) !important;
}

table td {
  border-color: #edf2f7 !important;
  color: var(--sg-ink) !important;
}

tbody tr:hover td {
  background-color: #f8fbff !important;
}

/* Keep spreadsheet grid cells sleek like Airtable / Feishu Sheets */
.cost-grid input:not([type="checkbox"]):not(:disabled),
.cost-grid select:not(:disabled),
.offer-grid input:not([type="checkbox"]):not(:disabled),
.review-sheet input:not([type="checkbox"]),
.review-sheet textarea {
  border-radius: 6px !important;
  border-color: #dbe3ee !important;
  background: #ffffff !important;
}

.supplier-comparison thead th,
.cost-grid th,
.review-sheet th {
  background: #f1f5f9 !important;
}

.supplier-comparison td:has(:checked) {
  background: var(--sg-primary-soft) !important;
  box-shadow: inset 0 0 0 1px var(--sg-primary-border);
}

/* Modern Pill Tags & Status Badges */
.tag,
.badge {
  border-radius: 999px !important;
  padding: 2.5px 10px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em;
}

.tag:not([class*="progress-"]):not(.warn):not(.change):not(.late) {
  background: #ecfdf5 !important;
  color: #047857 !important;
  border: 1px solid #a7f3d0;
}

.tag.warn,
.badge.wait,
.tag.progress-review,
.tag.progress-incomplete {
  background: #fffbeb !important;
  color: #b45309 !important;
  border: 1px solid #fde68a;
}

.tag.change,
.tag.progress-waiting,
.tag.progress-costing {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border: 1px solid #bfdbfe;
}

.tag.progress-ready {
  background: #eef2ff !important;
  color: #4338ca !important;
  border: 1px solid #c7d2fe;
}

.tag.progress-done {
  background: #ecfdf5 !important;
  color: #047857 !important;
  border: 1px solid #a7f3d0;
}

.tag.progress-update {
  background: #fef2f2 !important;
  color: #b91c1c !important;
  border: 1px solid #fecaca;
}

/* Inquiry Header Banner & Stats Cards */
.current-inquiry {
  background: linear-gradient(135deg, #f8fbff 0%, #eff6ff 100%) !important;
  border-bottom: 1px solid var(--sg-line) !important;
  padding: 16px 22px !important;
}

.current-reference strong {
  color: var(--sg-ink) !important;
  font-size: 19px !important;
  letter-spacing: -0.02em;
}

.hero-pill,
.meta-pill {
  background: #ffffff !important;
  border: 1px solid var(--sg-line) !important;
  color: var(--sg-ink-2) !important;
  border-radius: 999px !important;
  padding: 2px 9px !important;
  font-size: 12px !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.hero-pill.crit,
.meta-pill.crit {
  background: #fef2f2 !important;
  border-color: #fecaca !important;
  color: #dc2626 !important;
}

.hero-pill.urg,
.meta-pill.urg {
  background: #fffbeb !important;
  border-color: #fde68a !important;
  color: #d97706 !important;
}

.inquiry-stats {
  background: var(--sg-surface-2) !important;
  padding: 14px 20px !important;
  border-bottom: 1px solid var(--sg-line);
}

.inquiry-stats button {
  background: var(--sg-surface) !important;
  border: 1px solid var(--sg-line) !important;
  border-radius: 10px !important;
  padding: 10px 14px !important;
  box-shadow: var(--sg-shadow-sm) !important;
}

.inquiry-stats button[aria-pressed="true"] {
  background: var(--sg-primary-soft) !important;
  border-color: var(--sg-primary) !important;
  color: var(--sg-primary) !important;
  box-shadow: 0 0 0 1px var(--sg-primary) !important;
}

.list-filters {
  background: var(--sg-surface) !important;
}

/* 5-Stage Progress Track Dots */
.stage-track .finished .stage-dot {
  background: #dcfce7 !important;
  border-color: #22c55e !important;
  color: #15803d !important;
}

.stage-track .finished:not(:last-child)::after {
  background: #22c55e !important;
}

.stage-track .current {
  color: var(--sg-primary) !important;
}

.stage-track .current .stage-dot {
  background: var(--sg-primary) !important;
  border-color: var(--sg-primary) !important;
  box-shadow: 0 0 0 4px var(--sg-primary-soft) !important;
}

/* Animated Frosted Modals */
dialog:not([aria-label="工作台导航"]) {
  border: 1px solid var(--sg-line) !important;
  border-radius: 16px !important;
  box-shadow: var(--sg-shadow-pop) !important;
  background: var(--sg-surface) !important;
}

dialog:not([aria-label="工作台导航"])::backdrop {
  background: rgba(15, 23, 42, 0.42) !important;
  backdrop-filter: blur(4px);
}

.actions {
  background: var(--sg-surface-2) !important;
}

.fieldNote {
  background: var(--sg-primary-soft) !important;
  border-left: 3px solid var(--sg-primary) !important;
  border-radius: 0 8px 8px 0;
  color: #1e3a8a;
}

.quote-stage-ribbon button.locked {
  opacity: 0.52 !important;
  cursor: not-allowed !important;
  background: #f1f5f9 !important;
  border-style: dashed !important;
  color: #94a3b8 !important;
}

.role-boundary-bar {
  margin: 0;
  padding: 10px 20px;
  background: linear-gradient(90deg, #eff6ff 0%, #f8fafc 100%);
  border-bottom: 1px solid #dbeafe;
  color: #1e40af;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.role-scope-strip {
  margin: 0;
  padding: 9px 20px;
  background: #f0f7ff;
  border-bottom: 1px solid #dbeafe;
  color: #1e3a8a;
  font-size: 12.8px;
  font-weight: 550;
}

/* Refined Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
