/* ============================================
   QBid — Design tokens & global styles
   ============================================ */

:root {
  /* Brand */
  --primary: #1E3A8A;          /* deep navy / trust */
  --primary-700: #1E40AF;
  --primary-50:  #EEF2FB;
  --primary-100: #DCE4F5;

  --action:  #3B82F6;          /* CTA blue */
  --action-600: #2563EB;
  --action-50:  #EFF6FF;

  /* Semantic */
  --success: #10B981;
  --success-50: #ECFDF5;
  --warn:    #F59E0B;
  --warn-50: #FFFBEB;
  --danger:  #EF4444;
  --danger-50: #FEF2F2;
  --violet:  #8B5CF6;
  --violet-50: #F5F3FF;

  /* Neutrals */
  --bg:      #F8FAFC;          /* page background */
  --bg-2:    #F1F5F9;
  --card:    #FFFFFF;
  --border:  #E2E8F0;
  --border-strong: #CBD5E1;
  --hover:   #F8FAFC;
  --text:    #1E293B;
  --text-2:  #64748B;
  --text-3:  #94A3B8;

  /* Surfaces dark (for war room, hero callouts) */
  --ink:     #0F172A;
  --ink-2:   #1E293B;

  /* Radii */
  --r-sm: 6px;
  --r:    8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04), 0 1px 1px rgba(15,23,42,.03);
  --shadow:    0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.04);
  --shadow-md: 0 4px 16px rgba(15,23,42,.08), 0 1px 3px rgba(15,23,42,.05);

  /* Type */
  --font-sans: "Noto Sans TC", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-num:  "Inter", "Noto Sans TC", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "tnum" 1, "ss01" 1;
}

/* Tabular numerals for dense data */
.num, .mono { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.mono { font-family: var(--font-mono); }
.tnum { font-variant-numeric: tabular-nums; }

h1,h2,h3,h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ============================================
   Layout — App shell
   ============================================ */

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.app--collapsed { grid-template-columns: 64px 1fr; }

.sidebar {
  background: #FFFFFF;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 20;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar__logo {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--action) 100%);
  display: grid; place-items: center; color: white;
  font-weight: 700; font-size: 14px; font-family: var(--font-num);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
}
.sidebar__name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; min-width: 0; flex: 1; white-space: nowrap; }
.sidebar__name small { display: block; font-weight: 500; font-size: 10px; color: var(--text-3); letter-spacing: .08em; margin-top: 1px; white-space: nowrap; }

.sidebar__sect {
  padding: 8px 8px 4px;
}
.sidebar__sect-label {
  padding: 8px 12px 6px;
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-3); font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-radius: var(--r);
  font-size: 13px; color: var(--text); cursor: pointer;
  position: relative;
}
.nav-item:hover { background: var(--bg-2); }
.nav-item.is-active { background: var(--primary-50); color: var(--primary-700); font-weight: 600; }
.nav-item.is-active::before {
  content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 3px;
  border-radius: 2px; background: var(--primary);
}
.nav-item__icon { width: 16px; height: 16px; flex: 0 0 16px; color: var(--text-2); }
.nav-item.is-active .nav-item__icon { color: var(--primary-700); }
.nav-item__badge {
  margin-left: auto; font-size: 10px; padding: 1px 6px; border-radius: 99px;
  background: var(--danger); color: white; font-weight: 600;
}
.nav-item__sub { margin-left: auto; font-size: 12px; color: var(--text-3); font-family: var(--font-num); }

.sidebar__foot {
  margin-top: auto; padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #4F46E5, #06B6D4);
  display: grid; place-items: center; color: white;
  font-size: 12px; font-weight: 700; font-family: var(--font-num);
  flex: 0 0 28px;
}
.avatar--sm { width: 22px; height: 22px; font-size: 10px; flex-basis: 22px; }
.avatar--lg { width: 36px; height: 36px; font-size: 13px; flex-basis: 36px; }

/* ============================================
   Top bar
   ============================================ */
.topbar {
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
}
.crumbs { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.crumbs__sep { color: var(--text-3); }
.crumbs__cur { color: var(--text); font-weight: 500; }

.search {
  margin-left: 16px; flex: 1; max-width: 480px;
  position: relative;
}
.search input {
  width: 100%; height: 34px; padding: 0 12px 0 32px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg); font: inherit;
  outline: none;
}
.search input:focus { background: var(--card); border-color: var(--action); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.search__icon { position: absolute; left: 10px; top: 9px; color: var(--text-3); }
.search__kbd { position: absolute; right: 8px; top: 7px; font-size: 10px; padding: 2px 5px; background: var(--card); border: 1px solid var(--border); border-radius: 4px; color: var(--text-2); font-family: var(--font-mono); }

.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ============================================
   Buttons
   ============================================ */
.btn {
  height: 34px; padding: 0 14px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--card);
  color: var(--text); font: inherit; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s, transform .04s;
}
.btn:hover { background: var(--hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--action); border-color: var(--action); color: white;
}
.btn--primary:hover { background: var(--action-600); border-color: var(--action-600); }
.btn--navy {
  background: var(--primary); border-color: var(--primary); color: white;
}
.btn--navy:hover { background: var(--primary-700); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--bg-2); }
.btn--danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn--danger-ghost:hover { background: var(--danger-50); }
.btn--lg { height: 44px; padding: 0 18px; font-size: 15px; }
.btn--sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn--icon { width: 34px; padding: 0; justify-content: center; }
.btn--block { width: 100%; justify-content: center; }

/* ============================================
   Badges & chips
   ============================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; font-size: 12px; font-weight: 500;
  border-radius: 99px; line-height: 18px;
  background: var(--bg-2); color: var(--text-2);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }
.badge--navy { background: var(--primary-50); color: var(--primary-700); }
.badge--blue { background: var(--action-50); color: var(--action-600); }
.badge--green { background: var(--success-50); color: #047857; }
.badge--amber { background: var(--warn-50); color: #B45309; }
.badge--red { background: var(--danger-50); color: #B91C1C; }
.badge--violet { background: var(--violet-50); color: #6D28D9; }
.badge--ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.badge--solid-red { background: var(--danger); color: white; }
.badge--solid-amber { background: var(--warn); color: white; }
.badge--solid-green { background: var(--success); color: white; }
.badge--sq { border-radius: 4px; padding: 2px 7px; font-weight: 600; font-size: 11px; letter-spacing: .04em; }

/* ============================================
   Cards & panels
   ============================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card__hd {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.card__hd h3 { font-size: 14px; font-weight: 600; }
.card__hd .sub { font-size: 12px; color: var(--text-3); margin-left: 6px; }
.card__bd { padding: 16px; }
.card__ft { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

/* Dense data card variants */
.card--ink {
  background: linear-gradient(180deg, #0F172A 0%, #1E293B 100%);
  color: white;
  border: 1px solid #1E293B;
}
.card--ink .card__hd { border-color: rgba(255,255,255,.08); }
.card--ink .sub { color: #94A3B8; }

/* ============================================
   Tabs
   ============================================ */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 10px 14px;
  font-size: 14px; color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary-700); border-color: var(--primary); font-weight: 600; }
.tab .count { font-size: 12px; color: var(--text-3); font-family: var(--font-num); }

/* ============================================
   Forms
   ============================================ */
.input, .select, .textarea {
  width: 100%; height: 36px;
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 0 12px; font: inherit; background: var(--card);
  outline: none;
}
.textarea { height: auto; padding: 8px 10px; line-height: 1.5; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--action); box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.label {
  font-size: 12px; color: var(--text-2); font-weight: 500;
  letter-spacing: .02em; margin-bottom: 4px; display: block;
}
.checkbox {
  appearance: none; width: 14px; height: 14px; border: 1px solid var(--border-strong);
  border-radius: 3px; display: inline-grid; place-items: center;
  background: var(--card); flex: 0 0 14px;
  vertical-align: middle;
}
.checkbox:checked { background: var(--action); border-color: var(--action); }
.checkbox:checked::after { content: ""; width: 8px; height: 5px; border-left: 2px solid white; border-bottom: 2px solid white; transform: rotate(-45deg) translate(1px,-1px); }
.checkbox--sm { width: 12px; height: 12px; }

.switch {
  width: 32px; height: 18px; background: var(--border-strong);
  border-radius: 99px; position: relative; cursor: pointer; flex: 0 0 32px;
  transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; left: 2px; top: 2px;
  width: 14px; height: 14px; background: white; border-radius: 50%;
  transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch.is-on { background: var(--action); }
.switch.is-on::after { transform: translateX(14px); }

/* ============================================
   Tables — dense
   ============================================ */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-weight: 500; color: var(--text-2);
  font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  padding: 10px 12px; background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.tbl td {
  padding: 14px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--bg); }
.tbl--compact td { padding: 10px 12px; }
.tbl--compact th { padding: 9px 12px; }
.tbl .right { text-align: right; }
.tbl .right.mono, .tbl .num { font-variant-numeric: tabular-nums; }

/* ============================================
   Filter sidebar (P03)
   ============================================ */
.filters {
  width: 280px; flex: 0 0 280px;
  background: var(--card); border-right: 1px solid var(--border);
  height: calc(100vh - 56px); overflow-y: auto;
  position: sticky; top: 56px;
}
.filters__sect { border-bottom: 1px solid var(--border); padding: 12px 16px; }
.filters__hd {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: var(--text);
  cursor: pointer; user-select: none;
}
.filters__hd .meta { font-size: 12px; color: var(--text-3); font-weight: 400; }
.filters__bd { margin-top: 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); cursor: pointer;
}
.chip:hover { background: var(--bg-2); }
.chip.is-on { background: var(--action-50); border-color: var(--action); color: var(--action-600); font-weight: 500; }
.chip__close { color: var(--text-3); font-size: 12px; }

/* range slider styling */
input[type=range] {
  appearance: none; width: 100%; height: 4px;
  background: var(--border); border-radius: 99px;
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  appearance: none; width: 14px; height: 14px;
  background: var(--action); border-radius: 50%;
  border: 2px solid white; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

/* ============================================
   Money & figures
   ============================================ */
.money { font-family: var(--font-num); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.money--lg { font-size: 22px; }
.money--xl { font-size: 28px; }
.money--xxl { font-size: 36px; line-height: 1.05; }
.money small { font-size: .55em; font-weight: 500; color: var(--text-3); margin-left: 2px; }

.kpi {
  padding: 16px;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--card);
}
.kpi__label { font-size: 12px; color: var(--text-2); letter-spacing: .04em; text-transform: uppercase; font-weight: 600; }
.kpi__value { font-family: var(--font-num); font-size: 26px; font-weight: 600; margin-top: 6px; letter-spacing: -.02em; }
.kpi__delta { font-size: 12px; color: var(--success); margin-top: 4px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.kpi__delta--down { color: var(--danger); }
.kpi__spark { margin-top: 8px; }

/* Countdown */
.count-pill {
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  padding: 2px 8px; border-radius: 4px; font-weight: 600; font-size: 12px;
}
.count-pill--green { background: var(--success-50); color: #047857; }
.count-pill--amber { background: var(--warn-50); color: #B45309; }
.count-pill--red { background: var(--danger-50); color: #B91C1C; }

/* ============================================
   Tender card (shared element)
   ============================================ */
.tender-card {
  display: grid; grid-template-columns: 1fr auto;
  gap: 6px 16px; padding: 16px; border-bottom: 1px solid var(--border);
  background: var(--card); cursor: pointer;
  transition: background .12s;
}
.tender-card:hover { background: var(--bg); }
.tender-card.is-active { background: var(--action-50); }
.tender-card__head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.tender-card__title { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.4; margin-top: 2px; text-wrap: pretty; }
.tender-card__meta { display: flex; align-items: center; gap: 14px; margin-top: 8px; font-size: 13px; color: var(--text-2); }
.tender-card__meta .m { display: inline-flex; align-items: center; gap: 4px; }
.tender-card__tags { display: flex; align-items: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.tender-card__act { display: flex; align-items: flex-start; gap: 6px; }

/* ============================================
   Utilities
   ============================================ */
.row { display: flex; align-items: center; gap: 8px; }
.row--between { justify-content: space-between; }
.col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.grow { flex: 1; }
.shrink-0 { flex: 0 0 auto; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.muted { color: var(--text-2); }
.mute2 { color: var(--text-3); }
.fw5 { font-weight: 500; }
.fw6 { font-weight: 600; }
.fw7 { font-weight: 700; }
.t-xs { font-size: 13px; } .t-sm { font-size: 14px; } .t-md { font-size: 15px; } .t-lg { font-size: 18px; }
.tl { text-align: left; } .tr { text-align: right; } .tc { text-align: center; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.divider-v { width: 1px; background: var(--border); align-self: stretch; }
.dotline { background-image: linear-gradient(to right, var(--border) 50%, transparent 0%); background-size: 6px 1px; background-repeat: repeat-x; background-position: bottom; height: 1px; }
.scroll-x { overflow-x: auto; }
.scroll-y { overflow-y: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Grid helpers */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

/* Page wrapper */
.page { padding: 32px 36px; max-width: 1400px; margin: 0 auto; }
.page--wide { max-width: 1600px; }
.page--full { max-width: none; padding: 0; }
.page__hd { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page__title { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.page__sub { font-size: 13px; color: var(--text-2); margin-top: 4px; }

/* H-scroll obscure scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }
::-webkit-scrollbar-track { background: transparent; }

/* Selection */
::selection { background: rgba(59,130,246,.25); }

/* ============================================
   Animations
   ============================================ */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.shimmer {
  background: linear-gradient(90deg, transparent 0%, rgba(59,130,246,.08) 40%, rgba(59,130,246,.18) 50%, rgba(59,130,246,.08) 60%, transparent 100%);
  background-size: 200% 100%; animation: shimmer 2.2s linear infinite;
}
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(59,130,246,.4); }
  100% { box-shadow: 0 0 0 12px rgba(59,130,246,0); }
}
.pulse-ring { animation: pulse-ring 1.8s infinite; }

@keyframes blink { 50% { opacity: .2; } }
.blink { animation: blink 1.2s infinite; }

@keyframes ticker {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* AI typing dots */
.dots span {
  display: inline-block; width: 4px; height: 4px; border-radius: 50%;
  background: var(--action); margin-right: 2px;
  animation: blink 1.4s infinite;
}
.dots span:nth-child(2){ animation-delay: .2s; }
.dots span:nth-child(3){ animation-delay: .4s; }

/* Risk colored left border list items */
.risk-item {
  display: grid; grid-template-columns: 4px 1fr auto; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--card);
}
.risk-item__bar { background: var(--border); border-radius: 2px; }
.risk-item--high   .risk-item__bar { background: var(--danger); }
.risk-item--med    .risk-item__bar { background: var(--warn); }
.risk-item--low    .risk-item__bar { background: var(--success); }

/* Progress bar */
.bar {
  height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden;
  position: relative;
}
.bar__fill { height: 100%; background: var(--action); border-radius: 99px; }
.bar--lg { height: 8px; }

/* Tooltip */
.has-tip { position: relative; }
.tip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: white; font-size: 11px; padding: 4px 8px; border-radius: 4px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 100; }
.has-tip:hover .tip { opacity: 1; }
