:root {
  --th-primary: #0284c7;
  --th-primary-hover: #0369a1;
  --th-bg-card: #ffffff;
  --th-border: #e2e8f0;
  --th-text-main: #0f172a;
  --th-text-muted: #64748b;
  --th-pill-bg: #f1f5f9;
  --th-pill-hover: #e2e8f0;
  --th-result-bg: #f8fafc;
  --th-hl-bg: #e0f2fe;
  --th-hl-border: #bae6fd;
  --th-hl-text: #0369a1;
  --th-col-net: #10b981;
  --th-col-tax: #ef4444;
  --th-col-ni: #f59e0b;
  --th-col-pen: #6366f1;
}

.th-tool-container {
  max-width: 900px;
  margin: 0 auto 3rem auto;
  font-family: inherit;
  color: var(--th-text-main);
}

.th-editor-card {
  background: var(--th-bg-card);
  border: 1px solid var(--th-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.th-presets-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--th-border);
}

.th-presets-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--th-text-muted);
}

.th-pill-btn {
  background: var(--th-pill-bg);
  border: 1px solid var(--th-border);
  color: var(--th-text-main);
  border-radius: 9999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.th-pill-btn:hover {
  background: var(--th-pill-hover);
  border-color: var(--th-primary);
}

.th-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 680px) {
  .th-grid-3 {
    grid-template-columns: 1fr;
  }
}

.th-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--th-text-main);
}

.th-req {
  color: #dc2626;
}

.th-field input,
.th-field select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--th-border);
  border-radius: 8px;
  background: var(--th-bg-card);
  color: var(--th-text-main);
  font-size: 0.95rem;
  box-sizing: border-box;
}

.th-field input:focus,
.th-field select:focus {
  outline: none;
  border-color: var(--th-primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.th-action-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.th-primary-btn {
  flex: 2;
  background: var(--th-primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.th-primary-btn:hover {
  background: var(--th-primary-hover);
}

.th-secondary-btn {
  background: var(--th-pill-bg);
  color: var(--th-text-main);
  border: 1px solid var(--th-border);
  border-radius: 8px;
  padding: 0.85rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.th-results-card {
  background: var(--th-result-bg);
  border: 1px solid var(--th-border);
  border-radius: 12px;
  padding: 1.75rem;
}

.th-highlight-box {
  background: var(--th-hl-bg);
  border: 1px solid var(--th-hl-border);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.th-hl-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--th-hl-text);
  margin-bottom: 0.25rem;
  display: block;
}

.th-hl-val {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--th-hl-text);
  margin-bottom: 0.25rem;
}

.th-hl-sub {
  font-size: 0.95rem;
  color: var(--th-hl-text);
}

/* 4 Period Cards */
.th-periods-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .th-periods-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.th-period-card {
  background: var(--th-bg-card);
  border: 1px solid var(--th-border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.th-pc-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--th-text-muted);
}

.th-pc-val {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--th-text-main);
}

.th-pc-sub {
  font-size: 0.75rem;
  color: var(--th-text-muted);
}

/* Progress bar */
.th-bar-wrap {
  background: var(--th-bg-card);
  border: 1px solid var(--th-border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.th-bar-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  color: var(--th-text-main);
}

.th-progress-bar {
  display: flex;
  height: 18px;
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 0.75rem;
  background: #e2e8f0;
}

.th-bar-seg {
  height: 100%;
  transition: width 0.3s ease;
}

.th-seg-net { background: var(--th-col-net); }
.th-seg-tax { background: var(--th-col-tax); }
.th-seg-ni { background: var(--th-col-ni); }
.th-seg-pen { background: var(--th-col-pen); }

.th-legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--th-text-muted);
}

.th-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.th-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.th-dot-net { background: var(--th-col-net); }
.th-dot-tax { background: var(--th-col-tax); }
.th-dot-ni { background: var(--th-col-ni); }
.th-dot-pen { background: var(--th-col-pen); }

/* Table */
.th-table-card {
  background: var(--th-bg-card);
  border: 1px solid var(--th-border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.th-sub-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.75rem 0;
  color: var(--th-text-main);
}

.th-table-wrap {
  overflow-x: auto;
}

.th-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.th-table th,
.th-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--th-border);
}

.th-table th {
  background: var(--th-pill-bg);
  font-weight: 700;
  color: var(--th-text-muted);
}

.th-tip-box {
  background: var(--th-bg-card);
  border: 1px solid var(--th-border);
  border-radius: 8px;
  padding: 1.25rem;
}

.th-tip-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  color: var(--th-primary);
}

.th-tip-box p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--th-text-muted);
  line-height: 1.5;
}

.th-ad {
  overflow: hidden;
  min-height: 280px;
  margin: 32px 0;
  text-align: center;
}
/* tf:dark-palette — generated by migrate_chrome.py */
/* Neutrals inherit the shared chrome tokens so all tools share one
   ground; brand hues are kept and lightened, never inverted. */
[data-theme="dark"] {
  --th-primary: #81bcda;
  --th-primary-hover: #69aed4;
  --th-bg-card: var(--tf-surface);
  --th-border: var(--tf-surface);
  --th-text-main: var(--tf-ink);
  --th-text-muted: var(--tf-ink-faint);
  --th-pill-bg: var(--tf-surface);
  --th-pill-hover: var(--tf-surface);
  --th-result-bg: var(--tf-surface);
  --th-hl-bg: var(--tf-surface);
  --th-hl-border: #81bbda;
  --th-hl-text: #69aed4;
  --th-col-net: #81dabd;
  --th-col-tax: #da8181;
  --th-col-ni: #dab981;
  --th-col-pen: #8182da;
}
