/* ============================= TOKENS ============================= */
:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-alt: #eceef5;
  --surface-raised: #ffffff;
  --border: #dee1ec;
  --border-strong: #c5cadc;
  --text: #14182a;
  --text-muted: #5a6178;
  --text-faint: #8a90a6;
  --accent: #4a3fd6;
  --accent-strong: #362ab0;
  --accent-soft: #ebe9fb;
  --accent-text-on: #ffffff;
  --success: #178a5d;
  --success-soft: #e0f4eb;
  --warning: #b4700a;
  --warning-soft: #fcf0dc;
  --danger: #d43a46;
  --danger-soft: #fbe8ea;
  --info: #0c7fae;
  --info-soft: #e3f3f9;
  --ws-1: #8452b0;
  --ws-1-soft: #f1e8f8;
  --ws-2: #0e8c7a;
  --ws-2-soft: #e0f5f1;
  --ws-3: #4a3fd6;
  --ws-3-soft: #ebe9fb;
  --ws-4: #bd7a1b;
  --ws-4-soft: #fbefdd;
  --ws-5: #c1447e;
  --ws-5-soft: #fbe7f0;
  --ws-6: #1d8fa8;
  --ws-6-soft: #e1f2f6;
  --node-approval: #8452b0;
  --shadow-sm: 0 1px 3px rgba(20, 24, 42, 0.08);
  --shadow-md: 0 6px 20px rgba(20, 24, 42, 0.1);
  --shadow-lg: 0 16px 48px rgba(20, 24, 42, 0.18);
  --surface-glass: rgba(255, 255, 255, 0.7);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --font-ui:
    "Segoe UI Variable", "Segoe UI", Inter, -apple-system, BlinkMacSystemFont,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono:
    "Cascadia Code", "Cascadia Mono", ui-monospace, "Consolas",
    "SFMono-Regular", monospace;
  --nav-w: 248px;
  --topbar-h: 60px;
}
:root[data-theme="dark"] {
  --bg: #0b0d16;
  --surface: #141926;
  --surface-alt: #1b2233;
  --surface-raised: #1a2032;
  --border: #262e42;
  --border-strong: #313b54;
  --text: #e8eaf3;
  --text-muted: #9198b0;
  --text-faint: #6c7590;
  --accent: #8c82f5;
  --accent-strong: #a79dff;
  --accent-soft: #241f45;
  --accent-text-on: #0b0d16;
  --success: #3ecb93;
  --success-soft: #12281f;
  --warning: #e6ac49;
  --warning-soft: #2e2513;
  --danger: #f17179;
  --danger-soft: #331b1e;
  --info: #52c2ea;
  --info-soft: #122733;
  --ws-1: #c79ee8;
  --ws-1-soft: #251c30;
  --ws-2: #4cd9be;
  --ws-2-soft: #0f2a25;
  --ws-3: #8c82f5;
  --ws-3-soft: #201c3e;
  --ws-4: #f2b65e;
  --ws-4-soft: #2e2413;
  --ws-5: #e890bc;
  --ws-5-soft: #2e1c27;
  --ws-6: #5fcbe0;
  --ws-6-soft: #122a30;
  --node-approval: #c79ee8;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 52px rgba(0, 0, 0, 0.55);
  --surface-glass: rgba(19, 23, 36, 0.62);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d16;
    --surface: #141926;
    --surface-alt: #1b2233;
    --surface-raised: #1a2032;
    --border: #262e42;
    --border-strong: #313b54;
    --text: #e8eaf3;
    --text-muted: #9198b0;
    --text-faint: #6c7590;
    --accent: #8c82f5;
    --accent-strong: #a79dff;
    --accent-soft: #241f45;
    --accent-text-on: #0b0d16;
    --success: #3ecb93;
    --success-soft: #12281f;
    --warning: #e6ac49;
    --warning-soft: #2e2513;
    --danger: #f17179;
    --danger-soft: #331b1e;
    --info: #52c2ea;
    --info-soft: #122733;
    --ws-1: #c79ee8;
    --ws-1-soft: #251c30;
    --ws-2: #4cd9be;
    --ws-2-soft: #0f2a25;
    --ws-3: #8c82f5;
    --ws-3-soft: #201c3e;
    --ws-4: #f2b65e;
    --ws-4-soft: #2e2413;
    --ws-5: #e890bc;
    --ws-5-soft: #2e1c27;
    --ws-6: #5fcbe0;
    --ws-6-soft: #122a30;
    --node-approval: #c79ee8;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 18px 52px rgba(0, 0, 0, 0.55);
    --surface-glass: rgba(19, 23, 36, 0.62);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}
p {
  margin: 0;
}
a {
  color: var(--accent);
  text-decoration: none;
}
button {
  font-family: inherit;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.tnum {
  font-variant-numeric: tabular-nums;
}
svg.icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.scrollx {
  overflow-x: auto;
}

h1:focus {
  outline: none;
}
.valid.modified:not([type="checkbox"]) {
  outline: 1px solid var(--success);
}
.invalid {
  outline: 1px solid var(--danger);
}
.validation-message {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
  display: block;
}
.blazor-error-boundary {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 1rem 1rem 1rem 1rem;
  color: var(--danger);
}
.blazor-error-boundary::after {
  content: "An error has occurred.";
}

/* ============================= APP SHELL ============================= */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex: none;
  overflow: hidden;
}
.brand-mark svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.topbar-search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text-faint);
  transition:
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}
.topbar-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  font-size: 13px;
  width: 100%;
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-height: 420px;
  overflow-y: auto;
  padding: 6px;
}
.search-results-empty {
  padding: 16px 12px;
  color: var(--text-faint);
  font-size: 12.5px;
  text-align: center;
}
.search-results-group {
  padding: 8px 10px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.search-result-item {
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.search-result-item:hover {
  background: var(--surface-alt);
}
.search-result-item .cell-main {
  font-size: 13px;
}
.search-result-item .cell-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: box-shadow 0.12s ease;
}
.avatar:hover {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.shell {
  display: flex;
  flex: 1;
  min-height: 0;
}
.sidenav {
  width: var(--nav-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  gap: 2px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  text-decoration: none;
  transition:
    background-color 0.12s ease,
    color 0.12s ease;
}
.nav-item:hover {
  background: var(--surface-alt);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav-foot {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-faint);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.pagehead {
  padding: 18px 26px 0;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.breadcrumb b {
  color: var(--text);
  font-weight: 600;
}
.pagehead-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.pagehead h1 {
  font-size: 22px;
}
.pagehead .desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}
.pagehead-actions {
  display: flex;
  gap: 8px;
}
.content {
  padding: 0 26px 40px;
  flex: 1;
}

/* ============================= COMPONENTS ============================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    transform 0.05s ease;
}
.btn:hover {
  background: var(--surface-alt);
  border-color: var(--border-strong);
}
.btn:active {
  transform: translateY(0.5px);
}
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: var(--accent-strong);
  color: var(--accent-text-on);
  box-shadow: 0 1px 2px rgba(20, 24, 42, 0.14);
}
.btn.primary:hover {
  background: linear-gradient(
    135deg,
    var(--accent-strong),
    var(--accent-strong)
  );
  border-color: var(--accent-strong);
  box-shadow: var(--shadow-sm);
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
}
.btn.ghost:hover {
  background: var(--surface-alt);
}
.btn.danger {
  color: var(--danger);
  border-color: var(--danger);
  background: transparent;
}
.btn.danger:hover {
  background: var(--danger-soft);
}
.btn.sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 7px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn svg {
  width: 15px;
  height: 15px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition:
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}
.card-pad {
  padding: 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kpi-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
}
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.kpi-delta {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 700;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.success {
  background: var(--success-soft);
  color: var(--success);
}
.badge.warning {
  background: var(--warning-soft);
  color: var(--warning);
}
.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge.info {
  background: var(--info-soft);
  color: var(--info);
}
.badge.neutral {
  background: var(--surface-alt);
  color: var(--text-muted);
}
.badge.neutral::before {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 700;
}
.chip.ws-1 {
  background: var(--ws-1-soft);
  color: var(--ws-1);
}
.chip.ws-2 {
  background: var(--ws-2-soft);
  color: var(--ws-2);
}
.chip.ws-3 {
  background: var(--ws-3-soft);
  color: var(--ws-3);
}
.chip.ws-4 {
  background: var(--ws-4-soft);
  color: var(--ws-4);
}
.chip.ws-5 {
  background: var(--ws-5-soft);
  color: var(--ws-5);
}
.chip.ws-6 {
  background: var(--ws-6-soft);
  color: var(--ws-6);
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.search-input {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 220px;
  color: var(--text-faint);
}
.search-input input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  font-size: 13px;
  width: 100%;
}
.spacer {
  flex: 1;
}

table.dtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.dtable thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.dtable tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.dtable tbody tr:last-child td {
  border-bottom: none;
}
.dtable tbody tr:hover {
  background: var(--surface-alt);
}
.cell-main {
  font-weight: 600;
  color: var(--text);
}
.cell-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 1px;
}
.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
.avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  flex: none;
}
.name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tabs button,
.tabs .tab-link {
  padding: 10px 4px;
  margin-right: 22px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
}
.tabs button.active,
.tabs .tab-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.two-col {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.section-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.muted {
  color: var(--text-muted);
}
.faint {
  color: var(--text-faint);
}
.small {
  font-size: 12px;
}
.hr {
  height: 1px;
  background: var(--border);
  border: none;
  margin: 16px 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.field .hint {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 400;
}
.input,
.textarea,
select.selectbox {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.input:focus,
.textarea:focus,
select.selectbox:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea {
  resize: vertical;
  min-height: 90px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.range {
  width: 100%;
  accent-color: var(--accent);
}
.switch {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 100px;
  background: var(--border-strong);
  flex: none;
  cursor: pointer;
  border: none;
}
.switch.on {
  background: var(--accent);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}
.switch.on::after {
  left: 18px;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 13, 22, 0.45);
  z-index: 60;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 640px;
  max-width: 94vw;
  background: var(--surface);
  z-index: 61;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
.drawer-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.drawer-head h3 {
  font-size: 15.5px;
}
.drawer-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}
.drawer-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-faint);
  gap: 10px;
  text-align: center;
}
.empty-state svg {
  width: 40px;
  height: 40px;
  opacity: 0.5;
}

/* ============================= HOME LAUNCHER ============================= */
.home-greeting h1 {
  font-size: 26px;
  letter-spacing: -0.02em;
}
.home-greeting .desc {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-top: 5px;
  margin-bottom: 24px;
}

.home-section {
  margin-bottom: 28px;
}
.home-section:last-child {
  margin-bottom: 0;
}
.home-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    border-color 0.12s ease;
}
.tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.tile:active {
  transform: translateY(0);
  box-shadow: none;
}
.tile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.tile-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--surface-alt);
  color: var(--text-muted);
}
.tile-icon svg {
  width: 19px;
  height: 19px;
}
.tile-stat {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  padding-top: 8px;
}
.tile-chevron {
  color: var(--text-faint);
  opacity: 0;
  transform: translateX(-3px);
  transition:
    opacity 0.12s ease,
    transform 0.12s ease;
}
.tile-chevron svg {
  width: 17px;
  height: 17px;
}
.tile:hover .tile-chevron {
  opacity: 1;
  transform: translateX(0);
}
.tile-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tile-title {
  font-size: 14.5px;
  font-weight: 700;
}
.tile-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* One accent per section, not per tile - reinforces the group (Build/Operate/Manage) rather than
   turning the grid into an arbitrary rainbow; Resources deliberately stays neutral (.tile-icon's
   default) since docs/settings are always-there utilities, not something to visually compete for
   attention with the sections above. */
.tile.build .tile-icon {
  background: var(--ws-3-soft);
  color: var(--ws-3);
}
.tile.operate .tile-icon {
  background: var(--ws-2-soft);
  color: var(--ws-2);
}
.tile.manage .tile-icon {
  background: var(--ws-4-soft);
  color: var(--ws-4);
}

/* ============================= MINI CHARTS ============================= */
.mini-chart {
  width: 100%;
}
.mini-chart-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.mini-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ============================= CONVERSATIONS ============================= */
.chat-shell {
  display: flex;
  height: calc(100vh - var(--topbar-h) - 96px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.chat-sidebar {
  width: 300px;
  flex: none;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.chat-sidebar-head {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.chat-list-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.chat-list-item:hover {
  background: var(--surface-alt);
}
.chat-list-item.active {
  background: var(--accent-soft);
}
.chat-list-item .cell-main {
  font-size: 13px;
}
.chat-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chat-thread-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat-bubble-row {
  display: flex;
}
.chat-bubble-row.user {
  justify-content: flex-end;
}
/* max-width lives on this wrapper (a definite-width flex item), not on .chat-bubble itself - a
   percentage max-width on a shrink-to-fit child creates a circular sizing loop (the child's own
   intrinsic size feeds the parent's fit-content width, which the percentage then re-constrains),
   which collapsed bubbles down to a near-1-character column. */
.chat-bubble-wrap {
  max-width: 68%;
  display: flex;
  flex-direction: column;
}
.chat-bubble-row.user .chat-bubble-wrap {
  align-items: flex-end;
}
.chat-bubble-row.agent .chat-bubble-wrap {
  align-items: flex-start;
}
.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.chat-bubble-row.user .chat-bubble {
  background: var(--accent);
  color: var(--accent-text-on);
  border-bottom-right-radius: 4px;
}
.chat-bubble-row.agent .chat-bubble {
  background: var(--surface-alt);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-bubble-row.error .chat-bubble {
  background: var(--danger-soft);
  color: var(--danger);
  border-bottom-left-radius: 4px;
}
.chat-bubble-meta {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 4px;
}
.thinking-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 6px;
  vertical-align: middle;
}
.thinking-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.3;
  animation: thinking-bounce 1.1s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}
.thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes thinking-bounce {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .thinking-dots span {
    animation: none;
    opacity: 0.6;
  }
}
.spinner-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-faint);
}
.spinner-inline.small {
  font-size: 12px;
}
.spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
.spinner-inline.small .spinner {
  width: 12px;
  height: 12px;
  border-width: 1.5px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}
.chat-composer {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-composer textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 140px;
}

/* ============================= DOCS ============================= */
.docs-shell {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.docs-nav {
  width: 200px;
  flex: none;
  position: sticky;
  top: calc(var(--topbar-h) + 18px);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.docs-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
}
.docs-nav a:hover {
  background: var(--surface-alt);
  color: var(--text);
}
.docs-nav a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.docs-content {
  flex: 1;
  min-width: 0;
  max-width: 760px;
  padding-bottom: 60px;
}
.docs-content h2 {
  font-size: 21px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.docs-content h3 {
  font-size: 15px;
  margin: 28px 0 8px;
  letter-spacing: -0.01em;
}
.docs-lead {
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.65;
  margin: 0 0 20px;
}
.docs-content p {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  margin: 0 0 14px;
}
.docs-content ul,
.docs-content ol {
  margin: 0 0 14px;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text);
}
.docs-content li {
  margin-bottom: 5px;
}
.docs-content li > ul,
.docs-content li > ol {
  margin-top: 5px;
}
.docs-content code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-alt);
  padding: 1.5px 5px;
  border-radius: 4px;
  color: var(--accent-strong);
}
.docs-code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 13px 15px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  overflow-x: auto;
  margin: 0 0 16px;
  white-space: pre;
  color: var(--text);
}
.docs-callout {
  background: var(--info-soft);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
  margin: 0 0 16px;
}
.docs-callout.warn {
  background: var(--warning-soft);
}
.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin: 0 0 18px;
}
.docs-table th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 12px 8px 0;
  border-bottom: 1px solid var(--border);
}
.docs-table td {
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text);
}
.docs-table tr:last-child td {
  border-bottom: none;
}
.docs-badge {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1.5px 7px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ============================= TOOL TYPE PICKER ============================= */
.tool-edit-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  max-width: 1320px;
}
.tool-edit-form {
  flex: 1 1 560px;
  min-width: 0;
  max-width: 640px;
}
.tool-doc-panel {
  flex: 1 1 480px;
  min-width: 0;
  max-width: 640px;
  position: sticky;
  top: calc(var(--topbar-h) + 18px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}
.tool-doc-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.tool-doc-panel-title {
  font-size: 14.5px;
  font-weight: 700;
}
.tool-doc-panel-desc {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 4px;
}
.tool-doc-panel .docs-code,
.tool-doc-panel .docs-callout {
  margin-bottom: 0;
}
.tool-doc-panel .docs-code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-x: hidden;
}
@media (max-width: 980px) {
  .tool-edit-layout {
    flex-direction: column;
  }
  .tool-edit-form {
    max-width: none;
    width: 100%;
  }
  .tool-doc-panel {
    max-width: none;
    width: 100%;
    position: static;
  }
}

.type-picker {
  position: relative;
  margin-top: 6px;
}
.type-picker-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 11px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
}
.type-picker-trigger:hover {
  border-color: var(--accent);
}
.type-picker-trigger-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.type-picker-trigger-label {
  font-size: 13px;
  font-weight: 600;
}
.type-picker-trigger-cat {
  font-size: 11px;
  color: var(--text-faint);
}
.type-picker-chevron {
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  flex: none;
  transition: transform 0.15s ease;
}
.type-picker-chevron.open {
  transform: rotate(180deg);
}
.type-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
}
.type-picker-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 56;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
}
.type-picker-group {
  margin-bottom: 4px;
}
.type-picker-group-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 8px 8px 4px;
}
.type-picker-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
}
.type-picker-item:hover {
  background: var(--surface-alt);
}
.type-picker-item.active {
  background: var(--accent-soft);
}
.type-picker-item-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.type-picker-item-label {
  font-size: 12.5px;
  font-weight: 600;
}
.type-picker-item-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ============================= SETUP WIZARD ============================= */
.setup-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 32px 16px;
}
.setup-stage {
  max-width: 640px;
  width: 100%;
}
.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 34px;
  box-shadow: var(--shadow-md);
}
.setup-steps {
  display: flex;
  align-items: center;
  margin-bottom: 26px;
}
.setup-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-faint);
  white-space: nowrap;
}
.setup-step.active {
  color: var(--accent);
}
.setup-step.done {
  color: var(--success);
}
.setup-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-alt);
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex: none;
}
.setup-step.active .setup-dot {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}
.setup-step.done .setup-dot {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}
.setup-line {
  flex: 1;
  height: 1.5px;
  background: var(--border);
  margin: 0 8px;
}
.setup-line.done {
  background: var(--success);
}
.setup-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.alert {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert.error {
  background: var(--danger-soft);
  color: var(--danger);
}
.alert.ok {
  background: var(--success-soft);
  color: var(--success);
}

/* ============================= LOGIN ============================= */
.auth-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg);
  padding: 32px 16px;
}
.auth-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0.55;
}
.auth-veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 0%, var(--bg) 85%);
  pointer-events: none;
}
.auth-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 3;
  background: var(--surface-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
}
.auth-toggle .icon-sun {
  display: none;
}
:root[data-theme="dark"] .auth-toggle .icon-sun {
  display: block;
}
:root[data-theme="dark"] .auth-toggle .icon-moon {
  display: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .auth-toggle .icon-sun {
    display: block;
  }
  :root:not([data-theme="light"]) .auth-toggle .icon-moon {
    display: none;
  }
}
.auth-shell {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 388px;
}
.auth-card {
  position: relative;
  background: var(--surface-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 38px 34px 32px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  overflow: hidden;
}
.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--ws-2), var(--ws-5));
}
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 26px;
  text-align: center;
}
.auth-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-bottom: 16px;
  animation: authGlow 3.4s ease-in-out infinite;
}
.auth-mark svg {
  width: 28px;
  height: 28px;
  stroke: #fff;
}
@keyframes authGlow {
  0%,
  100% {
    box-shadow: 0 0 0 0 var(--accent-soft);
  }
  50% {
    box-shadow: 0 0 26px 8px var(--accent-soft);
  }
}
@media (prefers-reduced-motion: reduce) {
  .auth-mark {
    animation: none;
    box-shadow: 0 0 20px 4px var(--accent-soft);
  }
}
.auth-title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.auth-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
}
.auth-field-icon {
  position: relative;
}
.auth-field-icon svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}
.auth-field-icon .input {
  padding-left: 36px;
}
.auth-submit {
  width: 100%;
  justify-content: center;
  margin-top: 20px;
}
.auth-foot {
  text-align: center;
  margin-top: 20px;
  font-size: 12.5px;
  color: var(--text-faint);
}
.auth-foot a {
  color: var(--accent);
  font-weight: 600;
}
@media (prefers-reduced-motion: reduce) {
  .auth-canvas {
    opacity: 0.3;
  }
}

/* ============================= NOTIFICATIONS ============================= */
.notif-wrap {
  position: relative;
}
.notif-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 100px;
  background: var(--danger);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 56;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  max-height: 440px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.notif-panel-title {
  font-size: 13px;
  font-weight: 700;
}
.notif-list {
  overflow-y: auto;
}
.notif-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
}
.notif-item:hover {
  background: var(--surface-alt);
}
.notif-item.unread {
  background: var(--accent-soft);
}
.notif-item.unread:hover {
  background: var(--accent-soft);
  filter: brightness(0.97);
}
.notif-item-title {
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.notif-item-title .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}
.notif-item-message {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.notif-item-time {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 4px;
}
