:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --surface-muted: #f2efe8;
  --border: #e4e0d5;
  --border-strong: #cfc9ba;
  --text: #1c2421;
  --text-muted: #5c6662;
  --primary: #1f5e4b;
  --primary-hover: #17493a;
  --primary-soft: #eaf3ef;
  --amber: #b97318;
  --amber-soft: #fdf4e6;
  --blue: #235789;
  --blue-soft: #ecf3fa;
  --danger: #b42318;
  --danger-soft: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(28, 36, 33, 0.05), 0 1px 2px rgba(28, 36, 33, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
  background: var(--surface-muted);
  padding: 2px 6px;
  border-radius: 5px;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 242px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.nav-item:hover {
  background: var(--surface-muted);
  color: var(--text);
}

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

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.45;
}

.nav-item.active .nav-dot {
  opacity: 1;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.proto-note {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.proto-note strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

.proto-note p {
  margin: 0;
}

/* Main container */
.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}

.page-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.role-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.role-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.select-input,
.text-input,
.textarea-input {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}

.select-input:focus,
.text-input:focus,
.textarea-input:focus {
  outline: 2px solid rgba(31, 94, 75, 0.2);
  border-color: var(--primary);
}

.textarea-input {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  resize: vertical;
}

.role-banner {
  padding: 9px 26px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.role-banner.core {
  background: var(--primary-soft);
  color: var(--primary);
}

.role-banner.restricted {
  background: var(--amber-soft);
  color: #8b530d;
}

.content-area {
  padding: 22px 26px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1340px;
  width: 100%;
}

/* Cards & Grids */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.kpi-value {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.grid-split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

/* Badges & Buttons */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-muted);
  color: var(--text-muted);
}

.badge-green {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(31, 94, 75, 0.22);
}

.btn-secondary:hover:not(:disabled) {
  background: #dcebe4;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-muted);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon {
  border: 0;
  background: transparent;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.btn-icon:hover {
  background: var(--surface-muted);
}

.full-width {
  width: 100%;
}

/* Pills / Tabs */
.pill-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.pill:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* Progress & Distribution Bars */
.progress-track {
  width: 100%;
  height: 9px;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.dim-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dim-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dim-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.dim-bar-track {
  height: 7px;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: hidden;
}

.dim-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}

.dim-bar-fill.alt {
  background: var(--amber);
}

/* Skills & Lists */
.skill-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: #fcfcfa;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skill-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.skill-title {
  font-weight: 700;
  font-size: 14px;
}

.skill-summary {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  flex: 1;
}

.project-mini {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.project-mini:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

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

/* SVG Chart */
.chart-box {
  position: relative;
  width: 100%;
  overflow-x: auto;
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 5px;
}

.chart-tooltip {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--primary);
  min-height: 20px;
  font-weight: 500;
}

/* Data Table */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  background: #faf9f6;
}

.data-table td.num,
.data-table th.num {
  text-align: right;
}

/* Highlight Live Box */
.live-highlight {
  background: linear-gradient(135deg, #f3f8f5 0%, #fcfaf4 100%);
  border: 1px solid #d5e5dd;
  border-radius: var(--radius);
  padding: 16px 18px;
}

.live-metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.live-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.live-stat .num {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

/* Meetings Scheduler */
.room-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.room-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.room-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
}

.slot-btn {
  border: 1px solid #b9dacb;
  background: #eff7f3;
  color: #164e3d;
  border-radius: 6px;
  padding: 6px 4px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.slot-btn:hover:not(:disabled) {
  background: #d7ede3;
}

.slot-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.slot-btn.booked {
  background: #eceae3;
  border-color: var(--border);
  color: #8b8f8c;
  cursor: not-allowed;
  text-decoration: line-through;
}

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

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

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

.booking-success-box {
  background: var(--primary-soft);
  border: 1px solid rgba(31, 94, 75, 0.25);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.booking-success-box pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--surface);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
}

/* KB Docs */
.kb-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kb-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kb-title {
  font-weight: 700;
  font-size: 14px;
}

/* Info / Error Banners */
.info-strip {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-feedback {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.inline-feedback.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f5c2c0;
}

.inline-feedback.success {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #b8d8cb;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 24, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 40;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: min(680px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.16);
}

.modal-card-sm {
  width: min(480px, 100%);
}

.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.modal-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #1c2421;
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 60;
}

.loading-box {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

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

.live-auth-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.conn-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: #fcfcfa;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.conn-details {
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

.agenda-raw {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  background: var(--surface-muted);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: pre-wrap;
}

@media (max-width: 960px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    gap: 12px;
  }
  .nav-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav-item {
    width: auto;
  }
  .sidebar-footer {
    display: none;
  }
  .grid-2,
  .grid-split,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .content-area,
  .topbar,
  .role-banner {
    padding-left: 16px;
    padding-right: 16px;
  }
}

.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top left, #edf5f0 0%, var(--bg) 55%, #f4efe6 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
