:root {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --green-fg: #15803d;
  --green-bg: #f0fdf4;
  --green-bd: #bbf7d0;
  --amber-fg: #b45309;
  --amber-bg: #fffbeb;
  --amber-bd: #fde68a;
  --red-fg: #b91c1c;
  --red-bg: #fef2f2;
  --red-bd: #fecaca;
  --radius: 8px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 20px;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.num {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--text-muted);
  font-size: 12.5px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  height: 54px;
  display: flex;
  align-items: center;
}
.topbar-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-main);
  flex-shrink: 0;
}
.brand h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}
.brand-divider {
  color: var(--border-strong);
}
.brand-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  text-decoration: none !important;
}
.btn-xs {
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
}
.btn-primary {
  background: var(--text-main);
  color: #ffffff;
  border-color: var(--text-main);
}
.btn-primary:hover {
  background: #1e293b;
}
.btn-secondary {
  background: #eff6ff;
  color: var(--accent);
  border-color: #bfdbfe;
}
.btn-secondary:hover {
  background: #dbeafe;
}
.btn-ghost {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text-main);
}
.btn-danger-text {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-danger-text:hover {
  background: var(--red-bg);
  color: var(--red-fg);
}
.btn-unlocked {
  background: var(--green-bg);
  color: var(--green-fg);
  border-color: var(--green-bd);
}

/* Main Content */
.main-content {
  padding-top: 20px;
  padding-bottom: 48px;
}

/* Single-Row Summary Strip */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.summary-cell {
  padding: 14px 18px;
  border-right: 1px solid var(--border);
  min-width: 0;
}
.summary-cell:last-child {
  border-right: none;
}
.summary-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.summary-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}
.summary-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Clean Underline Tabs */
.tabs-bar {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 2px;
  margin-bottom: -1px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
}
.tab-btn:hover {
  color: var(--text-main);
}
.tab-btn.active {
  color: var(--text-main);
  font-weight: 600;
  border-bottom-color: var(--text-main);
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-group {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 2px;
  flex-wrap: wrap;
}
.pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.pill:hover {
  color: var(--text-main);
}
.pill.active {
  background: var(--bg-surface);
  color: var(--text-main);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.search-input {
  height: 32px;
  width: 240px;
  max-width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--text-main);
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Section Blocks */
.section-block {
  margin-bottom: 22px;
}
.section-head {
  margin-bottom: 8px;
}
.section-head h3 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
}
.section-head-flex {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

/* Row-by-Row Data Tables */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-secondary);
}
.data-table tbody tr:last-child td {
  border-bottom: none;
}
.data-table tbody tr:hover td {
  background: var(--bg-hover);
}

/* Row Typography Helpers */
.row-title {
  font-weight: 600;
  color: var(--text-main);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.row-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
}
.row-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.row-private {
  font-size: 12px;
  color: var(--amber-fg);
  background: var(--amber-bg);
  border: 1px solid var(--amber-bd);
  border-radius: 4px;
  padding: 2px 7px;
  margin-top: 4px;
  display: inline-block;
}
.row-atts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 5px;
}
.att-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 4px;
}
.att-item button {
  border: none;
  background: none;
  color: var(--red-fg);
  cursor: pointer;
  font-size: 11px;
  margin-left: 2px;
}

/* Calm Minimal Status Badges & Dots */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.st-green {
  color: var(--green-fg);
  background: var(--green-bg);
  border-color: var(--green-bd);
}
.st-green .dot { background: #16a34a; }

.st-amber {
  color: var(--amber-fg);
  background: var(--amber-bg);
  border-color: var(--amber-bd);
}
.st-amber .dot { background: #d97706; }

.st-red {
  color: var(--red-fg);
  background: var(--red-bg);
  border-color: var(--red-bd);
}
.st-red .dot { background: #dc2626; }

.st-neutral {
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border-color: var(--border);
}
.st-neutral .dot { background: #94a3b8; }

.tag-clean {
  display: inline-block;
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Inline Quota Cell */
.quota-inline {
  min-width: 165px;
}
.quota-inline-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
  gap: 8px;
}
.progress-slim {
  width: 100%;
  height: 5px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
}
.progress-slim-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}
.progress-slim-fill.warn {
  background: #d97706;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  white-space: nowrap;
}

/* GPU Tab Notice & Calculator Strip */
.notice-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-main);
  border-radius: var(--radius);
  padding: 11px 15px;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.calc-strip {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.calc-inputs {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
}
.calc-inputs label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
}
.calc-inputs label span {
  font-size: 12px;
  color: var(--text-muted);
}
.calc-inputs select, .calc-inputs input {
  height: 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 9px;
  font-size: 12.5px;
  color: var(--text-main);
}
.calc-output {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 16px 0;
  color: var(--text-muted);
  font-size: 12px;
  background: var(--bg-surface);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* Modals */
.hidden {
  display: none !important;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px 22px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
}
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 720px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 14px;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.form-grid .form-field {
  margin-bottom: 0;
}
.form-field.full-span {
  grid-column: 1 / -1;
}
.form-field span {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.form-field input, .form-field select, .form-field textarea {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 16px;
  padding-top: 18px;
}
.check-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  cursor: pointer;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--text-main);
  color: #ffffff;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.18);
}
.toast.error {
  background: var(--red-fg);
}

@media (max-width: 960px) {
  .summary-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .summary-cell:nth-child(2) {
    border-right: none;
  }
  .summary-cell:nth-child(1), .summary-cell:nth-child(2) {
    border-bottom: 1px solid var(--border);
  }
  .brand-divider, .brand-sub {
    display: none;
  }
}

@media (max-width: 640px) {
  .summary-strip {
    grid-template-columns: 1fr;
  }
  .summary-cell {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .summary-cell:last-child {
    border-bottom: none;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .search-input {
    width: 100%;
  }
}
