/* Amazon Search Terms Workbench — Impeccable Operate Design System
 * Palette: Deep Ink Indigo shell + Warm Alabaster ground + Cobalt-Klein action + Emerald/Terracotta momentum
 */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;

  /* Typography */
  --font-sans: "IBM Plex Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Committed OKLCH Palette */
  --shell-bg: oklch(0.205 0.028 258);          /* #141926 Deep Ink Indigo */
  --shell-bg-hover: oklch(0.265 0.030 258);
  --shell-bg-active: oklch(0.295 0.036 258);
  --shell-border: oklch(0.29 0.025 258);
  --shell-text: oklch(0.95 0.008 258);
  --shell-muted: oklch(0.72 0.022 258);
  --shell-accent: oklch(0.66 0.175 36);        /* Warm Vermilion-Amber rail marker */

  --ground: oklch(0.968 0.006 85);             /* #F5F4EF Warm Alabaster */
  --surface: oklch(0.998 0.002 85);            /* #FEFEFC Crisp Porcelain */
  --surface-subtle: oklch(0.978 0.005 85);     /* #F8F7F3 Soft Tinted Row / Panel */
  --surface-hover: oklch(0.955 0.012 255);     /* Tinted Indigo-Whisper hover */

  --ink: oklch(0.21 0.016 258);                /* #171B24 Primary Ink (>14:1) */
  --ink-secondary: oklch(0.42 0.018 258);      /* #4B5262 Secondary Ink (>7.5:1) */
  --ink-muted: oklch(0.51 0.015 258);          /* #626978 Muted Metadata (>5.2:1) */

  --border: oklch(0.898 0.009 85);             /* #E2DFD6 Hairline Border */
  --border-strong: oklch(0.81 0.012 85);       /* #C8C4B9 Control Border */
  --border-subtle: oklch(0.935 0.006 85);      /* #ECEAE4 Row Hairline */

  --action: oklch(0.49 0.195 260);             /* #1D4ED8 Cobalt-Klein */
  --action-hover: oklch(0.43 0.195 260);
  --action-soft: oklch(0.945 0.028 260);
  --action-border: oklch(0.76 0.095 260);
  --action-ink: oklch(0.39 0.17 260);

  /* Semantic Momentum & Status */
  --up: oklch(0.48 0.125 162);                 /* #0E7654 Deep Emerald-Teal */
  --up-bg: oklch(0.955 0.028 162);
  --down: oklch(0.51 0.175 26);                /* #C2362C Terracotta-Crimson */
  --down-bg: oklch(0.955 0.025 26);
  --new-ink: oklch(0.47 0.145 42);             /* #A84312 Warm Ochre-Vermilion */
  --new-bg: oklch(0.96 0.032 55);
  --new-border: oklch(0.86 0.07 52);

  /* Elevation */
  --shadow-sm: 0 1px 2px oklch(0.20 0.02 258 / 0.05);
  --shadow-md: 0 2px 4px oklch(0.20 0.02 258 / 0.04), 0 10px 28px -12px oklch(0.20 0.02 258 / 0.10);
  --shadow-dialog: 0 16px 48px -12px oklch(0.16 0.03 258 / 0.28), 0 2px 8px oklch(0.16 0.03 258 / 0.10);

  /* Radii & Layout */
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 11px;
  --rail-width: 224px;
  --topbar-height: 54px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base & Browser Surface Theming */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  caret-color: var(--action);
}

::selection {
  background: oklch(0.49 0.195 260 / 0.18);
  color: var(--ink);
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: oklch(0.76 0.012 85);
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: oklch(0.62 0.015 258); border: 2px solid transparent; background-clip: content-box; }

[hidden] { display: none !important; }

a {
  color: var(--action-ink);
  text-decoration: none;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

h1, h2, h3 {
  margin: 0;
  text-wrap: balance;
  color: var(--ink);
}
p { margin: 0; text-wrap: pretty; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.mono, .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.tabular { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.muted { color: var(--ink-muted); }

/* ==================== APP SHELL ==================== */
.wb-shell {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  min-height: 100vh;
}

.wb-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--shell-bg);
  color: var(--shell-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--shell-border);
  z-index: 20;
  overflow-y: auto;
}

.wb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  color: var(--shell-text);
  text-decoration: none;
  border-bottom: 1px solid var(--shell-border);
}
.wb-brand:hover { text-decoration: none; }

.wb-brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--shell-accent);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.wb-brand-copy { min-width: 0; }
.wb-brand-name {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
  color: var(--shell-text);
}
.wb-brand-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--shell-muted);
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.wb-nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.wb-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  color: var(--shell-muted);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}
.wb-nav a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.82;
}
.wb-nav a:hover {
  background: var(--shell-bg-hover);
  color: var(--shell-text);
  text-decoration: none;
}
.wb-nav a[aria-current="page"] {
  background: var(--shell-bg-active);
  color: #fff;
  font-weight: 600;
}
.wb-nav a[aria-current="page"] svg {
  color: var(--shell-accent);
  opacity: 1;
}
.wb-nav a:focus-visible {
  outline-color: var(--shell-accent);
  outline-offset: 1px;
}

.wb-rail-foot {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--shell-border);
  font-size: 11.5px;
  color: var(--shell-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.wb-market-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--shell-text);
  background: var(--shell-bg-hover);
  border: 1px solid var(--shell-border);
  padding: 3px 8px;
  border-radius: 5px;
}
.wb-market-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: oklch(0.68 0.16 155);
}

/* ==================== WORKSPACE STAGE ==================== */
.wb-stage {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.wb-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--topbar-height);
  background: oklch(0.992 0.003 85 / 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
}

.wb-title-group {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.wb-title-group h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.wb-subtitle {
  font-size: 12.5px;
  color: var(--ink-muted);
}

.wb-topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.wb-main {
  padding: 18px 24px 36px;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ==================== SURFACES & PANELS ==================== */
.wb-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.wb-panel-head {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.wb-panel-head h2 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

/* Inline Status Strip (replaces hero-metric cards) */
.wb-stat-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  box-shadow: var(--shadow-sm);
}
.wb-stat-item {
  flex: 1 1 180px;
  padding: 10px 18px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-right: 1px solid var(--border-subtle);
}
.wb-stat-item:last-child { border-right: 0; }
.wb-stat-label {
  font-size: 12px;
  color: var(--ink-muted);
  white-space: nowrap;
}
.wb-stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

/* ==================== CONTROLS & INPUTS ==================== */
.wb-input,
.wb-select,
.wb-btn,
select.wb-control,
input.wb-control,
button.wb-control {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.3;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 120ms var(--ease-out), background-color 120ms var(--ease-out), box-shadow 120ms var(--ease-out);
}

.wb-input:hover:not(:disabled),
.wb-select:hover:not(:disabled),
.wb-btn:hover:not(:disabled) {
  border-color: oklch(0.62 0.03 258);
}

.wb-input:focus,
.wb-select:focus {
  border-color: var(--action);
  box-shadow: 0 0 0 3px oklch(0.49 0.195 260 / 0.12);
  outline: none;
}

.wb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
}
.wb-btn:hover:not(:disabled) { background: var(--surface-subtle); }
.wb-btn:disabled,
.wb-input:disabled,
.wb-select:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.wb-btn-primary {
  background: var(--action);
  border-color: var(--action);
  color: #fff;
  font-weight: 600;
  padding-inline: 15px;
}
.wb-btn-primary:hover:not(:disabled) {
  background: var(--action-hover);
  border-color: var(--action-hover);
}

.wb-btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-secondary);
}
.wb-btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: transparent;
  color: var(--ink);
}

/* Field Labels */
.wb-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.wb-field > label,
.wb-field > legend {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  padding: 0;
}
.wb-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--ink-secondary);
  font-weight: 500;
}

/* Segmented Control */
.wb-segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 7px;
  background: var(--ground);
  border: 1px solid var(--border);
}
.wb-segmented button {
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-secondary);
  padding: 5px 12px;
  min-height: 28px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms var(--ease-out), color 120ms var(--ease-out), box-shadow 120ms var(--ease-out);
}
.wb-segmented button:hover:not(:disabled) { color: var(--ink); }
.wb-segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--action-ink);
  font-weight: 650;
  box-shadow: 0 1px 2px oklch(0.20 0.02 258 / 0.10);
}
.wb-segmented button:disabled { opacity: 0.45; cursor: not-allowed; }

/* Filter Pills */
.wb-pill {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  padding: 4px 11px;
  min-height: 29px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms var(--ease-out), border-color 120ms var(--ease-out), color 120ms var(--ease-out);
}
.wb-pill:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--ink);
}
.wb-pill[aria-pressed="true"] {
  background: var(--action-soft);
  border-color: var(--action-border);
  color: var(--action-ink);
  font-weight: 600;
}
.wb-pill:disabled { opacity: 0.42; cursor: not-allowed; }

/* ==================== SEMANTIC DATA ENCODING ==================== */
.delta {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.delta.up, .up { color: var(--up); }
.delta.down, .down { color: var(--down); }
.delta.muted { color: var(--ink-muted); font-weight: 400; }

.badge-new {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--new-bg);
  border: 1px solid var(--new-border);
  color: var(--new-ink);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.official-path, .day-category {
  color: var(--ink-muted);
  font-size: 11.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-line;
  margin-top: 3px;
}

@keyframes wb-spin { to { transform: rotate(360deg); } }
@keyframes wb-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
.wb-loading-bar {
  position: relative;
  height: 3px;
  width: 100%;
  overflow: hidden;
  background: var(--action-soft);
  border-radius: 2px;
}
.wb-loading-bar[hidden] { display: none; }
.wb-loading-bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 32%;
  background: var(--action);
  border-radius: 2px;
  animation: wb-slide 1.05s ease-in-out infinite;
}
.wb-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid color-mix(in srgb, var(--action) 25%, transparent);
  border-top-color: var(--action);
  border-radius: 50%;
  animation: wb-spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
.wb-loading-inline {
  display: inline-flex;
  align-items: center;
  color: var(--action-ink);
  font-weight: 550;
}
[data-loading="true"], [aria-busy="true"] {
  opacity: 0.52;
  transition: opacity 140ms ease;
  pointer-events: none;
}

/* Proportional Share Bar (Signature Move) */
.share-track {
  position: relative;
  height: 4px;
  margin-top: 7px;
  background: var(--ground);
  border-radius: 2px;
  width: 80px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}
.share-track i {
  display: block;
  height: 100%;
  background: var(--action);
  border-radius: 1px;
}

/* ==================== TABLES ==================== */
.wb-table-wrap {
  overflow: auto;
  min-height: 160px;
}

.wb-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.wb-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.wb-table td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.wb-table tbody tr:hover td {
  background: var(--surface-hover);
}

.wb-table input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--action);
  cursor: pointer;
}

/* ==================== PAGINATION ==================== */
.wb-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 11px 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12.5px;
  color: var(--ink-muted);
}
.wb-pager-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.wb-pager .wb-btn,
.wb-pager .wb-select,
.wb-pager .wb-input {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12.5px;
}
.wb-pager button.page-num[aria-current="page"] {
  background: var(--action);
  border-color: var(--action);
  color: #fff;
  font-weight: 600;
}

/* ==================== DIALOGS ==================== */
dialog.wb-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
  width: min(1020px, calc(100vw - 28px));
  max-height: 90vh;
}
dialog.wb-dialog::backdrop {
  background: oklch(0.16 0.03 258 / 0.52);
  backdrop-filter: blur(2px);
}
.wb-dialog-head {
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  background: var(--surface-subtle);
}
.wb-dialog-head h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.wb-dialog-head p {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--ink-muted);
}
.wb-dialog-body {
  padding: 18px 22px 22px;
  overflow: auto;
  max-height: calc(90vh - 96px);
}

/* ==================== ICON BUTTONS ==================== */
.icon-link, .icon-btn {
  width: 27px;
  height: 27px;
  border-radius: 5px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-secondary);
  cursor: pointer;
  padding: 0;
  transition: border-color 120ms var(--ease-out), background-color 120ms var(--ease-out), color 120ms var(--ease-out);
}
.icon-link:hover, .icon-btn:hover {
  border-color: var(--action-border);
  background: var(--action-soft);
  color: var(--action-ink);
  text-decoration: none;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 960px) {
  .wb-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .wb-rail {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-right: 0;
    border-bottom: 1px solid var(--shell-border);
    padding: 0 12px;
    gap: 12px;
    overflow-x: auto;
  }
  .wb-brand {
    padding: 10px 4px;
    border-bottom: 0;
  }
  .wb-brand-sub { display: none; }
  .wb-nav {
    flex-direction: row;
    padding: 8px 0;
    gap: 4px;
    overflow-x: auto;
    flex: initial;
  }
  .wb-nav a {
    padding: 6px 10px;
    white-space: nowrap;
    font-size: 13px;
  }
  .wb-rail-foot { display: none; }
  .wb-topbar { position: static; padding: 12px 16px; }
  .wb-main { padding: 14px 16px 28px; }
}

@media (max-width: 600px) {
  .wb-main { padding: 12px 12px 24px; }
  .wb-stat-item { border-right: 0; border-bottom: 1px solid var(--border-subtle); }
  .wb-stat-item:last-child { border-bottom: 0; }
  .wb-dialog-head, .wb-dialog-body { padding: 14px; }
}
