/* Palette built around Freelancer's sky blue on a deep navy base */
:root {
  color-scheme: dark;
  --bg: #0a1020;
  --bg-glow: #0f1d3a;
  --surface: #101a2e;
  --surface-2: #16223b;
  --surface-3: #1c2a47;
  --border: #22314f;
  --border-strong: #2f4268;
  --text: #e8eef8;
  --muted: #8a9bb8;
  --faint: #5d6f8f;
  --accent: #29b2fe;
  --accent-strong: #139ff0;
  --accent-soft: rgba(41, 178, 254, 0.14);
  --green: #2fd07a;
  --green-soft: rgba(47, 208, 122, 0.14);
  --amber: #ffb547;
  --amber-soft: rgba(255, 181, 71, 0.14);
  --red: #ff6b6b;
  --red-soft: rgba(255, 107, 107, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; scrollbar-color: var(--border-strong) transparent; scrollbar-width: thin; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 10% -10%, var(--bg-glow), transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.5 Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 16px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 8px; letter-spacing: -0.01em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.accent { color: var(--accent); }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 10px 24px;
  background: rgba(10, 16, 32, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { display: block; border-radius: 8px; }
.brand-sub { color: var(--faint); font-size: 11px; display: block; margin-top: -2px; }
.tabs { display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.tab {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active { color: #fff; background: var(--surface-3); }
.badge {
  background: var(--accent);
  color: #04121f;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 0 6px;
  line-height: 17px;
}
.status { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.busy { background: var(--accent); animation: pulse 1s infinite; }
.dot.err { background: var(--red); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- panels & forms ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.panel-head p { margin: 4px 0 0; }
.wide { max-width: 980px; margin: 24px auto; }
.wide h2 { margin-top: 18px; }
.wide h2:first-child { margin-top: 0; }

.setup {
  max-width: 420px;
  margin: 12vh auto;
  padding: 32px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.setup h2 { font-size: 20px; margin: 4px 0 0; }
.setup p { margin: 0; }
.setup img { border-radius: 14px; }

input, select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  margin-top: 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; line-height: 1.55; }
input[type="range"] { padding: 0; accent-color: var(--accent); border: 0; background: none; box-shadow: none; }
label { display: block; margin-bottom: 14px; font-size: 12px; font-weight: 500; color: var(--muted); }
label > input, label > select { color: var(--text); font-size: 14px; font-weight: 400; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 100px; }
.row.center { align-items: center; }

.group { margin-bottom: 14px; }
.group-label { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; }

/* toggle switch */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text); font-size: 13px; font-weight: 400; }
.switch input { display: none; }
.switch span {
  width: 32px; height: 18px; border-radius: 999px; background: var(--surface-3);
  position: relative; flex: 0 0 auto; transition: background 0.15s;
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s;
}
.switch input:checked + span { background: var(--accent-strong); }
.switch input:checked + span::after { transform: translateX(14px); background: #fff; }
.row .switch { flex: 0 0 auto; margin-bottom: 0; margin-top: 18px; }

/* segmented control */
.segmented { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; margin-top: 6px; }
.segmented button {
  flex: 1; background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px;
  padding: 5px 8px; border-radius: 6px; cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--surface-3); color: #fff; }
#tracker-filter { display: inline-flex; margin: 4px 0 14px; }
#tracker-filter button { flex: 0 0 auto; padding: 5px 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none !important;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); }
.btn.danger { color: var(--red); border-color: var(--red-soft); background: none; }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.block { width: 100%; }

/* skill chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 12px; cursor: pointer; user-select: none;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--border-strong); }
.chip.on { border-color: rgba(41, 178, 254, 0.5); color: #dff3ff; background: var(--accent-soft); }
.chip .x { color: var(--faint); border-radius: 50%; width: 16px; text-align: center; }
.chip .x:hover { color: var(--red); }

/* ---------- feed layout ---------- */
#view-feed {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 18px;
  padding: 18px 24px;
  align-items: start;
}
#view-feed.no-detail { grid-template-columns: 290px minmax(0, 1fr); }
.filters, .detail { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow-y: auto; }

.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 11px; font-size: 12px; color: var(--muted);
}
.pill b { color: var(--text); font-weight: 600; }
.pill.blue b { color: var(--accent); }
.pill.green b { color: var(--green); }

.project {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  position: relative;
}
.project:hover { border-color: var(--border-strong); background: #121e35; }
.project.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.project.new::before {
  content: "NEW"; position: absolute; top: -8px; right: 14px;
  background: var(--accent); color: #04121f; font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px; letter-spacing: 0.04em;
}
.project-title { font-weight: 600; font-size: 14.5px; line-height: 1.35; color: #f3f7fd; }

/* score ring */
.ring {
  --v: 0; --c: var(--faint);
  width: 50px; height: 50px; border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--v) * 1%), var(--surface-3) 0);
  display: grid; place-items: center;
}
.ring span {
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--c);
}
.ring.high { --c: var(--green); }
.ring.mid { --c: var(--amber); }
.ring.low { --c: var(--faint); }
.ring-label { font-size: 10px; color: var(--faint); text-align: center; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.tagpill {
  font-size: 12px; border-radius: 6px; padding: 1px 8px; background: var(--surface-2); color: var(--muted);
  border: 1px solid transparent; white-space: nowrap;
}
.tagpill.money { color: #dff3ff; background: var(--accent-soft); }
.tagpill.good { color: var(--green); background: var(--green-soft); }
.tagpill.warn { color: var(--amber); background: var(--amber-soft); }
.tagpill.bad { color: var(--red); background: var(--red-soft); }
.preview { color: var(--muted); font-size: 13px; margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.tag { font-size: 11px; border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; color: var(--faint); }
.tag.match { border-color: rgba(47, 208, 122, 0.4); color: var(--green); }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.skeleton {
  height: 118px; border-radius: var(--radius); margin-bottom: 10px; border: 1px solid var(--border);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- detail panel ---------- */
.detail-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.detail-head h2 { font-size: 18px; line-height: 1.3; margin: 0; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.detail .actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 6px; }
.detail .hint { font-size: 12px; color: var(--faint); margin-bottom: 18px; }
.section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); margin: 20px 0 10px; }
.desc {
  white-space: pre-wrap; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 13px; max-height: 340px; overflow-y: auto; color: #cfd9ea;
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 0 0 14px; }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat b { display: block; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.good b { color: var(--green); }
.stat.warn b { color: var(--amber); }
.stat.bad b { color: var(--red); }
.stat.blue b { color: var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow-x: auto; }

.status-badge { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.status-badge.pending { color: var(--accent); background: var(--accent-soft); }
.status-badge.replied { color: var(--amber); background: var(--amber-soft); }
.status-badge.won { color: var(--green); background: var(--green-soft); }
.status-badge.lost { color: var(--red); background: var(--red-soft); }
.status-badge.skipped { color: var(--muted); background: var(--surface-2); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 10px 18px; z-index: 30; box-shadow: var(--shadow); font-weight: 500;
}

code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; background: var(--surface-2); border-radius: 4px; padding: 1px 5px; color: #cfe9ff; }

/* fee / limits strip */
.infostrip { display: flex; flex-wrap: wrap; gap: 6px 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.infostrip b { color: var(--text); font-weight: 600; }

/* bidder table with expandable proposals */
tr.expandable { cursor: pointer; }
tr.expandable.open td { background: rgba(41, 178, 254, 0.05); }
tr.mine td { background: var(--green-soft); }
.caret { color: var(--faint); font-size: 11px; display: inline-block; transition: transform 0.15s; }
tr.open .caret { transform: rotate(180deg); }
tr.proposal td { background: var(--bg); }
.proposal-text { white-space: pre-wrap; font-size: 12.5px; color: #cfd9ea; max-height: 260px; overflow-y: auto; padding: 4px 2px; }

details.winner { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--bg); }
details.winner summary { cursor: pointer; padding: 9px 12px; font-size: 13px; font-weight: 500; }
details.winner[open] summary { border-bottom: 1px solid var(--border); }
details.winner .proposal-text { padding: 10px 12px; }

@media (max-width: 1100px) {
  #view-feed, #view-feed.no-detail { grid-template-columns: 1fr; padding: 16px; }
  .filters, .detail { position: static; max-height: none; }
  .topbar { flex-wrap: wrap; gap: 12px; padding: 10px 16px; }
  .wide { margin: 16px; }
}

/* ---------- top bar: countdown, refresh, volume ---------- */
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar-right .status { margin-left: 0; }
.countdown { color: var(--faint); font-variant-numeric: tabular-nums; }
.icon-btn.loud { color: var(--amber); }
.vol-wrap { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 8px); width: 280px; z-index: 40;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.popover p { margin: 6px 0 10px; }
.popover .row { gap: 6px; margin-bottom: 10px; }
.pop-row { display: flex; justify-content: space-between; font-weight: 500; }
.pop-row b { color: var(--accent); font-variant-numeric: tabular-nums; }
.vol-marks { display: flex; justify-content: space-between; font-size: 10px; color: var(--faint); }

/* ---------- custom tooltip ---------- */
.tooltip {
  position: fixed; z-index: 100; max-width: 260px; pointer-events: none;
  background: #f3f7fd; color: #0a1020; font-size: 12px; font-weight: 500; line-height: 1.4;
  padding: 7px 10px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  animation: tipIn 0.12s ease-out;
}
.tooltip::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px;
  background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 2px;
}
.tooltip.below::after { bottom: auto; top: -5px; }
@keyframes tipIn { from { opacity: 0; transform: translateY(3px); } }

/* ---------- number steppers (replace the browser arrows) ---------- */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper { display: flex; align-items: stretch; margin-top: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); overflow: hidden; transition: border-color 0.15s, box-shadow 0.15s; }
.stepper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stepper input { margin: 0; border: 0; border-radius: 0; text-align: center; min-width: 0; background: none; box-shadow: none !important; }
.step-btn {
  flex: 0 0 30px; background: var(--surface-2); color: var(--muted); border: 0; font: inherit; font-size: 16px;
  cursor: pointer; user-select: none; touch-action: manipulation;
}
.step-btn:hover { color: var(--text); background: var(--surface-3); }
.step-btn:active { color: var(--accent); }

/* ---------- hot alerts ---------- */
.hot-banner {
  border: 1px solid rgba(255, 107, 107, 0.5); background: linear-gradient(90deg, rgba(255, 107, 107, 0.16), rgba(255, 181, 71, 0.1));
  border-radius: var(--radius); padding: 8px; margin-bottom: 12px; animation: hotGlow 1.2s ease-in-out infinite alternate;
}
@keyframes hotGlow { to { box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.15); } }
.hot-item { display: flex; align-items: center; gap: 10px; padding: 6px; }
.hot-item + .hot-item { border-top: 1px solid rgba(255, 107, 107, 0.2); }
.hot-flame { font-size: 20px; }
.hot-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hot-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hot-all { margin: 4px 6px; }
.pill.hot b, .tagpill.hot { color: var(--red); }
.tagpill.hot { background: var(--red-soft); }
.project.is-hot { border-color: rgba(255, 107, 107, 0.55); }

/* ---------- alert settings ---------- */
#alerts-panel { margin-top: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.card h3 { font-size: 13px; margin: 0 0 10px; }
.card .switch { margin-bottom: 10px; }
.card .row { flex-wrap: nowrap; }
