:root {
  --bg: #f5f5f7;
  --sidebar-bg: rgba(255, 255, 255, 0.72);
  --sidebar-w: 240px;
  --card-bg: #ffffff;
  --line: rgba(0, 0, 0, 0.06);
  --text: #1d1d1f;
  --secondary: #48484a;
  --muted: #86868b;
  --subtle: #aeaeb2;

  /* Muted accent — slate blue, never vivid */
  --primary: #5d8bb3;
  --primary-light: rgba(93, 139, 179, 0.08);
  --primary-deep: #4a7396;

  /* Status — desaturated, soft tones */
  --green: #5d9b7a;
  --green-light: rgba(93, 155, 122, 0.08);
  --warn: #c4a050;
  --warn-light: rgba(196, 160, 80, 0.08);
  --danger: #b5605c;
  --danger-light: rgba(181, 96, 92, 0.08);
  --accent: #8685ad;
  --accent-light: rgba(134, 133, 173, 0.08);

  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.05), 0 1px 4px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.07), 0 2px 8px rgba(0, 0, 0, 0.03);
}

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

body {
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Login Page ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  width: 360px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 40px 36px 32px;
}

.login-error {
  color: var(--danger);
  font-size: 12px;
  padding: 8px 12px;
  background: rgba(181, 96, 92, 0.08);
  border-radius: var(--radius-sm);
  text-align: center;
}

.login-hint {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 16px;
}

.email-suffix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid rgba(0,0,0,0.10);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  height: 38px;
}

.form-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--secondary);
  cursor: pointer;
}

.form-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.sidebar-user {
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
}

.sidebar-user:hover {
  color: var(--text);
}

/* ── Layout ── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar (Frosted Glass) ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #5d8bb3, #8685ad);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 4px 12px;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 16px 8px 6px;
  letter-spacing: 0.01em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--muted);
  transition: color 0.15s ease;
}

.nav-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-deep);
  font-weight: 600;
}

.nav-item.active svg {
  color: var(--primary);
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.up {
  background: var(--green);
}

.sidebar-link {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
}

.sidebar-link:hover { text-decoration: underline; }

/* ── Main Content ── */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px 36px 48px;
  min-width: 0;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.topbar-logout {
  height: 28px !important;
  padding: 0 12px !important;
  font-size: 11px !important;
}

/* ── Tab Pages ── */
.tab-page { display: none; }
.tab-page.active { display: block; }

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.page-header h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

/* ── Cards ── */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  padding: 22px;
}

.card h3 {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}

/* ── Summary Grid (Impact via Typography) ── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.09), 0 4px 12px rgba(0, 0, 0, 0.04);
}

.summary-card:nth-child(1) { background: linear-gradient(135deg, #f6f8fc, #e8eef6); }
.summary-card:nth-child(2) { background: linear-gradient(135deg, #f3f9f5, #e4f0e8); }
.summary-card:nth-child(3) { background: linear-gradient(135deg, #fdf7f0, #f8ead6); }
.summary-card:nth-child(4) { background: linear-gradient(135deg, #f6f3fb, #ece5f6); }

.summary-card .label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  order: 1;
}

.summary-card .value {
  display: block;
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1.1;
  order: 0;
}

/* ── Dashboard Rows ── */
.dash-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.dash-row-bottom {
  grid-template-columns: 2fr 1fr;
}

.dash-chart-card {
  min-height: 240px;
}

.dash-wide {
  min-height: 200px;
}

.dash-narrow {
  min-height: 200px;
}

.chart-area {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

/* ── Donut Chart ── */
.donut-chart-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.donut-chart-wrap svg {
  flex-shrink: 0;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--secondary);
  white-space: nowrap;
}

.donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.donut-legend-value {
  font-weight: 600;
  color: var(--text);
  margin-left: auto;
  padding-left: 12px;
}

/* ── Bar Chart ── */
.bar-chart {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 0;
}

.bar-chart-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar-chart-label {
  font-size: 12px;
  color: var(--secondary);
  width: 80px;
  text-align: right;
  flex-shrink: 0;
}

.bar-chart-track {
  flex: 1;
  height: 22px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.bar-chart-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  min-width: 28px;
}

/* ── Progress Bars (Dashboard) ── */
.progress-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.progress-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.progress-item-meta {
  font-size: 12px;
  color: var(--muted);
}

.progress-bar-wrap {
  height: 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-bar.status-active { background: linear-gradient(90deg, #7cabd3, #5d8bb3); }
.progress-bar.status-planning { background: linear-gradient(90deg, #dbc370, #c4a050); }
.progress-bar.status-paused { background: linear-gradient(90deg, #c5c5ca, #aeaeb2); }
.progress-bar.status-done { background: linear-gradient(90deg, #78b68e, #5d9b7a); }
.progress-bar.status-idle { background: linear-gradient(90deg, #d1d1d6, #c5c5ca); }

/* Due date urgency */
.due-warn { color: #b8960f; font-weight: 600; }
.due-alert { color: #b87a0f; font-weight: 600; }
.due-danger { color: #c06060; font-weight: 600; }

/* ── Stack List (recent results) ── */
.stack-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stack-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--line);
  transition: box-shadow 0.15s ease;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.stack-item:hover {
  box-shadow: var(--shadow);
}

.stack-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.stack-item-dot.up { background: var(--green); }
.stack-item-dot.down { background: var(--danger); }
.stack-item-dot.unknown { background: var(--subtle); }

.stack-item-content {
  flex: 1;
  min-width: 0;
}

.stack-item-content strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stack-item-content span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Split Layout ── */
.split-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  align-items: start;
}

.keys-split {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 16px;
}

.keys-table-card {
  margin-top: 0;
}

.api-ref-card {
  margin-top: 16px;
}

.form-panel { min-width: 0; }
.table-panel { min-width: 0; overflow: hidden; }

/* ── Forms ── */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

.form-stack label,
.form-inline-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-inline-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.form-inline-grid .span-full {
  grid-column: 1 / -1;
}

.form-submit-row {
  display: flex;
  justify-content: flex-end;
}

.form-submit-row .primary-btn {
  width: auto;
  min-width: 120px;
}

.project-form-card {
  margin-bottom: 16px;
}

input, select, textarea {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.10);
  background: #ffffff;
  color: var(--text);
  padding: 8px 11px;
  font: inherit;
  font-size: 13px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea { min-height: 52px; resize: vertical; }
select[multiple] { min-height: 72px; }

button {
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.primary-btn {
  width: 100%;
  height: 38px;
  background: #1d1d1f;
  color: #ffffff;
  font-weight: 600;
  padding: 0 18px;
  margin-top: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.primary-btn:hover {
  background: #000000;
}

.ghost-btn {
  height: 38px;
  background: transparent;
  color: var(--secondary);
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 0 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ghost-btn:hover {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.18);
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg);
  position: sticky;
  top: 0;
}

td {
  color: var(--secondary);
}

tr:hover td {
  background: rgba(0, 0, 0, 0.015);
}

/* ── Badges (Soft, Desaturated) ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
}

.badge.up, .badge.active {
  background: var(--green-light);
  color: #3d7d5c;
}

.badge.down {
  background: var(--danger-light);
  color: #943e3b;
}

.badge.unknown {
  background: rgba(0, 0, 0, 0.04);
  color: var(--muted);
}

.badge.planning {
  background: var(--warn-light);
  color: #8a6d2e;
}

.badge.paused {
  background: rgba(0, 0, 0, 0.04);
  color: var(--muted);
}

.badge.degraded {
  background: var(--warn-light);
  color: #8a6d2e;
}

.badge.done {
  background: var(--accent-light);
  color: #6665a0;
}

/* ── Gantt Chart ── */
.gantt-wrapper {
  padding: 0;
  overflow: hidden;
}

.gantt-container {
  display: flex;
  min-height: 300px;
  max-height: calc(100vh - 220px);
  overflow: hidden;
}

.gantt-left {
  width: 340px;
  min-width: 340px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  flex-shrink: 0;
}

.gantt-right {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
}

.gantt-left-header {
  display: grid;
  grid-template-columns: 70px 1fr 80px 70px 56px;
  gap: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

.gantt-left-header span {
  padding: 10px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gantt-left-row {
  display: grid;
  grid-template-columns: 70px 1fr 80px 70px 56px;
  gap: 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
  height: 42px;
}

.gantt-left-row > span {
  padding: 0 8px;
  font-size: 12px;
  color: var(--secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gantt-left-row > span:first-child {
  font-weight: 600;
  color: var(--text);
}

.gantt-timeline-header {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
  min-width: max-content;
}

.gantt-month-group {
  display: flex;
  flex-direction: column;
}

.gantt-month-label {
  padding: 4px 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  border-bottom: 1px solid var(--line);
  letter-spacing: 0.02em;
}

.gantt-week-row {
  display: flex;
}

.gantt-week-cell {
  width: 40px;
  min-width: 40px;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  padding: 3px 0;
  border-right: 1px solid rgba(0, 0, 0, 0.02);
}

.gantt-week-cell.weekend {
  background: rgba(0, 0, 0, 0.015);
}

.gantt-body {
  position: relative;
  min-width: max-content;
}

.gantt-row-bg {
  height: 42px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.gantt-row-bg:hover {
  background: rgba(0, 0, 0, 0.01);
}

.gantt-bar {
  position: absolute;
  top: 10px;
  height: 22px;
  border-radius: 6px;
  overflow: hidden;
  cursor: default;
  display: flex;
  align-items: center;
}

.gantt-bar-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0.14;
  border-radius: 6px;
}

.gantt-bar-fill {
  height: 100%;
  border-radius: 6px;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  opacity: 0.50;
}

.gantt-bar-text {
  position: relative;
  z-index: 1;
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  padding: 0 8px;
  white-space: nowrap;
}

.gantt-bar.status-active .gantt-bar-bg,
.gantt-bar.status-active .gantt-bar-fill { background: linear-gradient(90deg, #7cabd3, #5d8bb3); }

.gantt-bar.status-planning .gantt-bar-bg,
.gantt-bar.status-planning .gantt-bar-fill { background: linear-gradient(90deg, #dbc370, #c4a050); }

.gantt-bar.status-paused .gantt-bar-bg,
.gantt-bar.status-paused .gantt-bar-fill { background: linear-gradient(90deg, #c5c5ca, #aeaeb2); }

.gantt-bar.status-done .gantt-bar-bg,
.gantt-bar.status-done .gantt-bar-fill { background: linear-gradient(90deg, #78b68e, #5d9b7a); }

/* ── Project Progress Cards (Projects Page) ── */
.project-list {
  display: flex;
  flex-direction: column;
}

.project-card-item {
  padding: 18px 4px;
  border-bottom: 1px solid var(--line);
}

.project-card-item:last-child {
  border-bottom: none;
}

.project-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.project-card-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.project-card-code {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.project-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.project-card-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.project-card-meta {
  font-size: 12px;
  color: var(--muted);
}

.project-card-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  min-width: 40px;
  text-align: right;
}

.project-card-bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.project-card-bar .progress-bar {
  height: 100%;
  border-radius: 4px;
}

.gantt-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--danger);
  z-index: 3;
  pointer-events: none;
}

.gantt-today-label {
  position: absolute;
  top: -18px;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 600;
  color: var(--danger);
  white-space: nowrap;
  background: var(--card-bg);
  padding: 1px 4px;
  border-radius: 3px;
}

.gantt-grid-lines {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.gantt-grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(0, 0, 0, 0.03);
}

.gantt-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--muted);
  font-size: 13px;
}

.gantt-left::-webkit-scrollbar-x,
.gantt-right::-webkit-scrollbar-y {
  display: none;
}

/* ── Milestone Timeline ── */
.milestone-project {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.milestone-project:last-child {
  border-bottom: none;
}

.milestone-project-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.milestone-project-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.milestone-project-meta {
  font-size: 12px;
  color: var(--muted);
}

.milestone-track {
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
  padding: 8px 0;
}

.milestone-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  min-width: 80px;
  flex: 1;
}

.milestone-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--subtle);
  transition: all 0.2s ease;
  position: relative;
  z-index: 2;
}

.milestone-dot.completed {
  background: var(--green);
  border-color: var(--green);
}

.milestone-dot.active {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.milestone-dot.pending {
  background: #fff;
  border-color: var(--subtle);
}

.milestone-label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
  line-height: 1.3;
  max-width: 72px;
  word-break: keep-all;
}

.milestone-label.completed {
  color: var(--green);
  font-weight: 500;
}

.milestone-label.active {
  color: var(--primary);
  font-weight: 600;
}

.milestone-line {
  flex: 1;
  height: 2px;
  background: var(--subtle);
  position: relative;
  top: -12px;
  min-width: 20px;
}

.milestone-line.completed {
  background: var(--green);
}

/* ── Token ── */
.token-result {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--green-light);
  border: 1px solid rgba(93, 155, 122, 0.15);
}

.token-warn {
  font-size: 12px;
  font-weight: 500;
  color: #8a6d2e;
  margin-bottom: 8px;
}

.token-code {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
  word-break: break-all;
  user-select: all;
}

/* ── API Grid (legacy) ── */
.api-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.api-grid code {
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--secondary);
  font-size: 12px;
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
}

/* ── API Explorer ── */
.api-explorer {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.api-group-card {
  padding: 18px 22px;
}

.api-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: box-shadow 0.2s ease;
}

.api-item:last-child {
  margin-bottom: 0;
}

.api-item.expanded {
  box-shadow: var(--shadow-md);
}

.api-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  gap: 12px;
  transition: background 0.15s ease;
}

.api-item-header:hover {
  background: rgba(0, 0, 0, 0.015);
}

.api-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.api-method {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 24px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.03em;
  text-align: center;
}

.api-path {
  font-size: 13px;
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
  color: var(--text);
  font-weight: 500;
}

.api-desc {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.api-item-body {
  padding: 14px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.01);
}

.api-param-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 10px;
}

.api-param-label code {
  font-size: 11px;
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
}

.api-param-input {
  flex: 1;
  max-width: 180px;
  height: 30px;
  font-size: 12px;
  padding: 4px 8px;
}

.api-body-section {
  margin-bottom: 10px;
}

.api-body-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.api-body-editor {
  width: 100%;
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  resize: vertical;
  min-height: 80px;
}

.api-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.api-run-btn {
  width: auto;
  min-width: 100px;
  height: 32px;
  font-size: 12px;
  padding: 0 16px;
}

.api-response {
  margin-top: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

.api-response-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.api-response-status {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.api-response-status.ok {
  color: var(--green);
}

.api-response-status.err {
  color: var(--danger);
}

.api-response-time {
  font-size: 11px;
  color: var(--muted);
}

.api-response-body {
  padding: 12px;
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--secondary);
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

/* ── API Sub-tabs ── */
.api-sub-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.api-sub-tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.api-sub-tab:hover {
  color: var(--text);
}

.api-sub-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.api-tab-pane {
  display: none;
}

.api-tab-pane.active {
  display: block;
}

.card-hint {
  font-size: 12px;
  color: var(--muted);
  margin: -4px 0 14px;
  line-height: 1.5;
}

.card-hint code {
  font-size: 11px;
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
}

/* ── SDK Docs ── */
.sdk-doc {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sdk-section {
  padding: 20px 24px;
}

.sdk-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.sdk-section h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--secondary);
}

.sdk-section p {
  font-size: 13px;
  line-height: 1.7;
  color: var(--secondary);
  margin-bottom: 10px;
}

.sdk-section ul, .sdk-section ol {
  font-size: 13px;
  line-height: 1.7;
  color: var(--secondary);
  padding-left: 20px;
  margin-bottom: 10px;
}

.sdk-section li {
  margin-bottom: 4px;
}

.sdk-code-block {
  position: relative;
  margin: 10px 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  overflow: hidden;
}

.sdk-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(0,0,0,0.03);
  border-bottom: 1px solid var(--line);
}

.sdk-code-lang {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sdk-copy-btn {
  font-size: 11px;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.sdk-copy-btn:hover {
  background: rgba(0,0,0,0.04);
}

.sdk-code-body {
  padding: 14px 16px;
  background: #fafafa;
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}

.sdk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 10px 0 14px;
}

.sdk-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-weight: 600;
  color: var(--secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sdk-table td {
  padding: 8px 12px;
  border: 1px solid var(--line);
  color: var(--secondary);
  vertical-align: top;
}

.sdk-table code {
  font-size: 11px;
  background: rgba(0,0,0,0.04);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
}

.sdk-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  color: #fff;
  letter-spacing: 0.02em;
}

.sdk-badge.get { background: #5d9b7a; }
.sdk-badge.post { background: #5d8bb3; }
.sdk-badge.put { background: #c4a050; }
.sdk-badge.delete { background: #b5605c; }

/* ── Toolbar Row (search + pills + actions, below title) ── */
.toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tb-search {
  width: 140px;
  height: 30px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--bg);
  padding: 0 12px;
  font-size: 12px;
  color: var(--text);
  flex-shrink: 0;
  transition: width 0.2s ease, border-color 0.2s ease;
}

.tb-search:focus {
  width: 180px;
  border-color: var(--primary);
  outline: none;
  background: #fff;
}

.fg {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 16px;
  padding: 2px;
  flex-shrink: 0;
}

.fp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

.fp:hover {
  color: var(--secondary);
}

.fp.on {
  background: #fff;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.tb-acts {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

.tb-btn {
  height: 30px !important;
  font-size: 11px !important;
  padding: 0 10px !important;
  border-radius: 16px !important;
}

/* ── Combo Select ── */
.combo-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.combo-select select {
  width: 100%;
}

.combo-select input {
  width: 100%;
}

/* ── Batch Bar ── */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--primary);
  border-radius: 20px;
  margin-left: 8px;
}

.batch-bar .batch-count {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.batch-bar .tb-btn,
.batch-bar .ghost-btn {
  color: #fff !important;
  border-color: rgba(255,255,255,0.3) !important;
  background: rgba(255,255,255,0.12) !important;
}

.batch-bar .tb-btn:hover,
.batch-bar .ghost-btn:hover {
  background: rgba(255,255,255,0.22) !important;
}

/* ── Empty State ── */
.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 24px 0;
  text-align: center;
}

/* ── Multi-Select ── */
.multi-select {
  position: relative;
}

.multi-select-display {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 38px;
  padding: 5px 8px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  align-items: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.multi-select-display:hover {
  border-color: rgba(0, 0, 0, 0.18);
}

.multi-select.open .multi-select-display {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.multi-select-placeholder {
  color: var(--muted);
  font-size: 13px;
}

.multi-select-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
}

.multi-select-tag-x {
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  margin-left: 2px;
}

.multi-select-tag-x:hover {
  color: var(--danger);
}

.multi-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 280px;
  overflow-y: auto;
  display: none;
  z-index: 10;
}

.multi-select.open .multi-select-dropdown {
  display: block;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.1s ease;
}

.multi-select-option:hover {
  background: rgba(0, 0, 0, 0.03);
}

.multi-select-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: auto;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Drawer (Slide-in Panel) ── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 440px;
  max-width: 92vw;
  height: 100vh;
  background: var(--card-bg);
  box-shadow: -6px 0 28px rgba(0, 0, 0, 0.10);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-overlay.open .drawer {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.drawer-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.drawer-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border: none;
  padding: 0;
  transition: background 0.15s ease;
}

.drawer-close:hover {
  background: rgba(0, 0, 0, 0.10);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.10);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.18);
}

/* ── Responsive ── */
@media (max-width: 1400px) {
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 1100px) {
  .dash-row { grid-template-columns: 1fr; }
  .dash-row-bottom { grid-template-columns: 1fr; }
  .split-layout { grid-template-columns: 1fr; }
  .keys-split { grid-template-columns: 1fr; }
  .form-inline-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: #ffffff;
  }
  .sidebar-brand { display: none; }
  .sidebar-footer { display: none; }
  .sidebar-nav {
    display: flex;
    gap: 2px;
    padding: 8px;
  }
  .nav-group-label { display: none; }
  .nav-item { white-space: nowrap; padding: 8px 14px; }
  .nav-item svg { display: none; }
  .layout { flex-direction: column; }
  .content { margin-left: 0; padding: 16px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-card .value { font-size: 32px; }
  .form-inline-grid { grid-template-columns: 1fr; }
}

/* ── Nav Permission Grid ── */
.nav-perm-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 12px;
  padding: 8px;
  background: var(--bg-main);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.nav-perm-grid .form-checkbox-label {
  font-size: 12px;
  padding: 4px 0;
}

/* ── Audit table tweaks ── */
#audit-logs-table table td {
  font-size: 12px;
}
#audit-logs-table table th {
  font-size: 11px;
}
