:root {
  --background: 220 20% 7%;
  --foreground: 30 10% 83%;

  --card: 220 18% 10%;
  --card-foreground: 30 10% 83%;

  --popover: 220 18% 10%;
  --popover-foreground: 30 10% 83%;

  --primary: 165 100% 38%;
  --primary-foreground: 220 20% 7%;

  --secondary: 220 14% 15%;
  --secondary-foreground: 220 10% 65%;

  --muted: 220 12% 13%;
  --muted-foreground: 220 10% 50%;

  --accent: 220 14% 17%;
  --accent-foreground: 30 10% 83%;

  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 100%;

  --border: 220 14% 16%;
  --input: 220 14% 18%;
  --ring: 165 100% 38%;

  --radius: 0.5rem;

  --sidebar-background: 220 20% 8%;
  --sidebar-foreground: 220 10% 55%;
  --sidebar-primary: 165 100% 38%;
  --sidebar-primary-foreground: 220 20% 7%;
  --sidebar-accent: 220 14% 13%;
  --sidebar-accent-foreground: 30 10% 83%;
  --sidebar-border: 220 14% 14%;
  --sidebar-ring: 165 100% 38%;

  --nerve-steel: 220 8% 58%;
  --nerve-dim: 220 12% 25%;
  --nerve-bone: 30 10% 83%;
  --nerve-accent: 165 100% 38%;
  --nerve-accent-dim: 165 50% 20%;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-color: hsl(var(--border));
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  display: flex;
}

/* ─── Typography ─────────────────────────────────────────
   3 sizes only:
     label  = 0.6875rem (11px)  — badges, timestamps, sidebar labels, codes
     body   = 0.8125rem (13px)  — nav, cards, table rows, buttons [default]
     heading= 1.375rem  (22px)  — page h1 only
   1 font family: monospace (set on body)
─────────────────────────────────────────────────────── */

/* font-mono is kept for tabular-nums only — no separate font family */
.font-mono { font-variant-numeric: tabular-nums; }

/* All existing size classes map to one of the 3 allowed sizes */
.text-xs,
.text-\[10px\],
.text-\[9px\],
.text-\[11px\] { font-size: 0.6875rem; }

.text-sm,
.text-lg,
.text-xl { font-size: 0.8125rem; }

.text-2xl { font-size: 1.375rem; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.uppercase { text-transform: uppercase; }
.tracking-tight { letter-spacing: -0.025em; }
.tracking-wider { letter-spacing: 0.05em; }
.tracking-widest { letter-spacing: 0.1em; }
.tracking-\[0\.2em\]  { letter-spacing: 0.2em; }
.tracking-\[0\.15em\] { letter-spacing: 0.15em; }

.text-primary { color: hsl(var(--primary)); }
.text-muted-foreground { color: hsl(var(--muted-foreground)); }
.text-destructive { color: hsl(var(--destructive)); }
.text-nerve-steel { color: hsl(var(--nerve-steel)); }
.text-nerve-dim { color: hsl(var(--nerve-dim)); }
.text-nerve-bone { color: hsl(var(--nerve-bone)); }

/* Layout Components */
.sidebar {
  width: 260px;
  background-color: hsl(var(--sidebar-background));
  border-right: 1px solid hsl(var(--sidebar-border));
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease;
  overflow: hidden;
}

.sidebar.no-transition,
.sidebar.no-transition * {
  transition: none !important;
}

.sidebar-icon-expand {
  display: none;
}

.sidebar.collapsed ~ .main-content .sidebar-icon-collapse {
  display: none;
}

.sidebar.collapsed ~ .main-content .sidebar-icon-expand {
  display: block;
}

.sidebar.collapsed {
  width: 64px;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-info {
  display: none;
}

.sidebar.collapsed .sidebar-label {
  font-size: 0;
  height: 0;
  margin: 0.5rem 0;
  padding: 0;
  border-top: 1px solid hsl(var(--sidebar-border));
  overflow: hidden;
}

.sidebar.collapsed .sidebar-label:first-child {
  margin: 0;
  border-top: none;
}

.project-avatar-collapsed {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar.collapsed .project-avatar-collapsed {
  display: flex;
}

.sidebar.collapsed .project-info-expanded {
  display: none;
}

.sidebar.collapsed .sidebar-project-info {
  padding: 0.25rem;
  margin-bottom: 0;
  display: flex;
  justify-content: center;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.625rem;
}

.sidebar.collapsed .sidebar-header {
  padding: 1rem 0.5rem;
  justify-content: center;
}

.sidebar.collapsed .sidebar-header .flex {
  justify-content: center;
}

.sidebar.collapsed .sidebar-footer {
  padding: 0.5rem;
}

.sidebar.collapsed .sidebar-footer .nav-text,
.sidebar.collapsed .sidebar-footer .footer-status-text {
  display: none;
}

.sidebar.collapsed .sidebar-footer-status {
  justify-content: center;
}

.sidebar.collapsed .sidebar-footer-actions {
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar.collapsed .lang-picker {
  width: 100%;
  position: static;
}

.sidebar.collapsed .lang-picker-toggle {
  justify-content: center;
  width: 100%;
  padding: 0.375rem;
}

.sidebar.collapsed .lang-picker-menu {
  position: fixed;
  bottom: auto;
  left: auto;
  min-width: 140px;
}

.sidebar.collapsed .footer-logout-btn {
  justify-content: center;
  padding: 0.5rem;
}

.sidebar-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.sidebar-header {
  padding: 1rem 1rem;
  border-bottom: 1px solid hsl(var(--sidebar-border));
  min-height: 56px;
  display: flex;
  align-items: center;
}

.sidebar-content {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.sidebar-footer {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid hsl(var(--sidebar-border));
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.sidebar-footer-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.25rem 0.25rem;
}

.sidebar-footer-status .footer-status-text {
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-footer-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
}

/* --- Language picker dropdown --- */
.lang-picker {
  position: relative;
}

.lang-picker-toggle {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: 1px solid hsl(var(--sidebar-border));
  border-radius: 6px;
  color: hsl(var(--sidebar-foreground));
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.lang-picker-toggle .icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.lang-picker-toggle:hover {
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
}

.lang-picker-toggle:hover .icon {
  opacity: 1;
}

.lang-picker-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 140px;
  background: hsl(var(--sidebar-background));
  border: 1px solid hsl(var(--sidebar-border));
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 8px 24px hsl(0 0% 0% / 0.25), 0 2px 8px hsl(0 0% 0% / 0.15);
  z-index: 100;
  animation: lang-picker-in 0.12s ease-out;
}

@keyframes lang-picker-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lang-picker.open .lang-picker-menu {
  display: block;
}

.lang-picker-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.375rem 0.5rem;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: hsl(var(--sidebar-foreground));
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  transition: background 0.1s, color 0.1s;
  text-align: left;
}

.lang-picker-item:hover {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
}

.lang-picker-item.active {
  color: hsl(var(--primary));
}

.lang-picker-item.active .lang-flag {
  font-weight: 700;
}

.lang-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  font-weight: 600;
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

.lang-picker-item:hover .lang-flag,
.lang-picker-item.active .lang-flag {
  opacity: 1;
}

.footer-logout-form {
  flex: 1;
}

.footer-logout-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.25rem 0.375rem;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  transition: color 0.15s, border-color 0.15s;
}

.footer-logout-btn:hover {
  color: hsl(var(--destructive));
  border-color: hsl(var(--destructive) / 0.3);
}

.footer-logout-btn .icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  border-bottom: 1px solid hsl(var(--border));
}

.page-body {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

/* UI Components */
.card {
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.card-header {
  padding: 1rem 1rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-content {
  padding: 1rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  border: 1px solid transparent;
  background: transparent;
  color: hsl(var(--foreground));
}
.button:focus:not(:focus-visible) { outline: none; }

.button-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.button-outline {
  border-color: hsl(var(--border));
}

.button-ghost {
  color: hsl(var(--muted-foreground));
}

.button-ghost:hover {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.button-icon {
  padding: 0.25rem;
  width: 2rem;
  height: 2rem;
}

.badge {
  display: inline-flex;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-family: inherit;
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  color: hsl(var(--sidebar-foreground));
  text-decoration: none;
  font-size: 0.8125rem;
  gap: 0.75rem;
  transition: background-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-item .icon {
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
}

.nav-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover {
  background-color: hsl(var(--sidebar-accent));
  color: hsl(var(--sidebar-accent-foreground));
}

.nav-item.active {
  background-color: hsl(var(--sidebar-accent));
  color: hsl(var(--sidebar-primary));
  font-weight: 500;
}

.sidebar-label {
  padding: 0.5rem 1rem 0.375rem;
  font-size: 0.6875rem;
  color: hsl(var(--nerve-steel));
  text-transform: uppercase;
  letter-spacing: 0.15em;
  white-space: nowrap;
}

.sidebar-label:first-child {
  padding-top: 0.375rem;
}

/* Animations */
@keyframes nerve-reveal {
  from {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

.animate-reveal {
  animation: nerve-reveal 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes nerve-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.animate-pulse {
  animation: nerve-pulse 2s ease-in-out infinite;
}

/* Status Dot */
.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
}

.status-dot.active { background-color: hsl(var(--primary)); }
.status-dot.inactive { background-color: hsl(var(--muted-foreground)); }
.status-dot.error { background-color: hsl(var(--destructive)); }

/* Grid / Spacing */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
@media (min-width: 768px) {
  .grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.gap-1 { gap: 0.25rem; }
.gap-1\.5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.mt-0\.5 { margin-top: 0.125rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-3 { margin-top: 0.75rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-8 { margin-bottom: 2rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.p-3 { padding: 0.75rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.rounded-md { border-radius: calc(var(--radius) - 2px); }
.border { border: 1px solid hsl(var(--border)); }
.w-full { width: 100%; }


/* Icon utility */
.icon { width: 1rem; height: 1rem; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* ─── Tables ─────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  text-align: left;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  font-size: 0.8125rem;
}

.table th {
  font-weight: 600;
  font-size: 0.6875rem;
  color: hsl(var(--nerve-steel));
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.table td a {
  color: hsl(var(--primary));
  text-decoration: none;
}

.table td a:hover {
  text-decoration: underline;
}

.table td code {
  font-size: 0.6875rem;
  background: hsl(var(--secondary));
  padding: 0.1rem 0.4rem;
  border-radius: calc(var(--radius) - 2px);
}

/* ─── Forms ──────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: hsl(var(--nerve-steel));
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.375rem;
}

.form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: hsl(var(--input));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 0.8125rem;
}

.form-input:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 1px hsl(var(--ring));
}

.form-input.input-error,
.form-select.input-error {
  border-color: hsl(var(--destructive));
}

.form-select {
  width: 100%;
  padding: 0.5rem 2.25rem 0.5rem 0.75rem;
  background: hsl(var(--input));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.form-select:focus {
  outline: none;
  border-color: hsl(var(--ring));
}

.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.form-row > .button {
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-end;
  /* match .form-input visual height */
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  line-height: 1.5;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: hsl(var(--primary));
}

.checkbox-row label {
  margin: 0;
  font-size: 0.8125rem;
  color: hsl(var(--foreground));
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
}

/* ─── Alerts ─────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.8125rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: hsl(var(--destructive) / 0.15);
  color: hsl(var(--destructive));
  border: 1px solid hsl(var(--destructive) / 0.3);
}

.alert-success {
  background: hsl(var(--primary) / 0.15);
  color: hsl(var(--primary));
  border: 1px solid hsl(var(--primary) / 0.3);
}

.field-error {
  color: hsl(var(--destructive));
  font-size: 0.6875rem;
  margin-top: 0.25rem;
}

/* ─── Badge variants ─────────────────────────────────── */
.badge-active {
  background: hsl(var(--primary) / 0.15);
  color: hsl(var(--primary));
}

.badge-done {
  background: hsl(142 70% 45% / 0.15);
  color: hsl(142 70% 50%);
}

.badge-error {
  background: hsl(var(--destructive) / 0.15);
  color: hsl(var(--destructive));
}

.badge-loading {
  background: hsl(210 80% 50% / 0.15);
  color: hsl(210 80% 65%);
}

.badge-unloading {
  background: hsl(40 80% 50% / 0.15);
  color: hsl(40 80% 65%);
}

.badge-admin {
  background: hsl(210 80% 50% / 0.15);
  color: hsl(210 80% 65%);
}

.badge-warning {
  background: hsl(40 80% 50% / 0.15);
  color: hsl(40 80% 65%);
}

/* ─── Audit event badge variants ─────────────────────── */
.badge-auth {
  background: hsl(0 70% 50% / 0.15);
  color: hsl(0 70% 65%);
}
.badge-token {
  background: hsl(280 70% 50% / 0.15);
  color: hsl(280 70% 65%);
}
.badge-user {
  background: hsl(180 70% 45% / 0.15);
  color: hsl(180 70% 60%);
}
.badge-plugin {
  background: hsl(210 80% 50% / 0.15);
  color: hsl(210 80% 65%);
}
.badge-mcp {
  background: hsl(260 70% 50% / 0.15);
  color: hsl(260 70% 65%);
}
.badge-task {
  background: hsl(140 60% 45% / 0.15);
  color: hsl(140 60% 60%);
}
.badge-notes {
  background: hsl(50 70% 50% / 0.15);
  color: hsl(50 70% 65%);
}
.badge-project {
  background: hsl(30 80% 50% / 0.15);
  color: hsl(30 80% 65%);
}

/* ─── Audit stat cards ───────────────────────────────── */
.audit-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  min-width: 5rem;
}
.audit-stat-count {
  font-size: 1.25rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  line-height: 1;
}
.audit-stat-label {
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  margin-top: 0.125rem;
}
.badge-pomodoro {
  background: hsl(350 70% 50% / 0.15);
  color: hsl(350 70% 65%);
}
.badge-dashboard {
  background: hsl(200 60% 50% / 0.15);
  color: hsl(200 60% 65%);
}

/* ─── Button danger ──────────────────────────────────── */
.button-danger {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.button-danger:hover {
  background-color: hsl(var(--destructive) / 0.85);
}

.button-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.button-secondary:hover {
  background-color: hsl(var(--accent));
}

/* ─── Description list ───────────────────────────────── */
.dl-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.4rem 0.75rem;
}

.dl-grid dt {
  font-weight: 600;
  color: hsl(var(--nerve-steel));
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.dl-grid dd {
  margin: 0;
  font-size: 0.8125rem;
}

/* ─── Dashboard header ──────────────────────────────── */
.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.dashboard-settings-btn {
  background: none;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  color: hsl(var(--muted-foreground));
  padding: 0.375rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  margin-top: 0.25rem;
}
.dashboard-settings-btn:hover {
  color: hsl(var(--foreground));
  border-color: hsl(var(--foreground));
}

/* ─── Widget grid ────────────────────────────────────── */
.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

/* Card chrome — refined dark monospace, faint top accent rail */
.widget-card {
  position: relative;
  background:
    linear-gradient(180deg, hsl(var(--card) / 0.92) 0%, hsl(var(--card)) 100%);
  border: 1px solid hsl(var(--border));
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 160ms ease, transform 160ms ease;
}
.widget-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    hsl(var(--primary) / 0.55) 18%,
    hsl(var(--primary) / 0.55) 42%,
    transparent 100%
  );
  pointer-events: none;
}
.widget-card:hover {
  border-color: hsl(var(--primary) / 0.35);
}
.widget-card .card-header {
  padding: 0.875rem 1rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 0;
}
.widget-card .card-header .text-sm,
.widget-card .card-header > span {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: hsl(var(--muted-foreground));
}

/* Drag & drop feedback */
.widget-card[draggable] { cursor: grab; }
.widget-card[draggable]:active { cursor: grabbing; }
.widget-dragging { opacity: 0.4; }
.widget-drop-before { box-shadow: -3px 0 0 0 hsl(var(--primary)); }
.widget-drop-after { box-shadow: 3px 0 0 0 hsl(var(--primary)); }

/* Dashboard settings modal */
.dash-settings-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.dash-settings-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; cursor: pointer; }
.dash-settings-item input[type="checkbox"] { accent-color: hsl(var(--primary)); }

.widget-grid .full {
  grid-column: 1 / -1;
}

.widget-error {
  color: hsl(var(--destructive));
  font-size: 0.8125rem;
}

/* ─── Widget body: stats + list ──────────────────────── */
.widget-card .card-content { padding-top: 0.25rem; }

.widget-stats {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0 0 0.625rem 0;
  margin-bottom: 0.625rem;
  border-bottom: 1px solid hsl(var(--border));
}
.widget-stat {
  display: flex;
  align-items: baseline;
  gap: 0.4375rem;
}
.widget-stat + .widget-stat {
  padding-left: 0.75rem;
  margin-left: 0.75rem;
  border-left: 1px solid hsl(var(--border));
}
.widget-stat-value {
  font-size: 1.375rem;       /* 22px — large size from palette */
  font-weight: 600;
  letter-spacing: -0.02em;
  color: hsl(var(--nerve-bone));
  font-feature-settings: "tnum" 1;
}
.widget-stat-label {
  font-size: 0.6875rem;      /* 11px — minor size */
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.widget-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.widget-list-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.4375rem 0.5rem;
  font-size: 0.8125rem;      /* 13px — body size */
  border-radius: 4px;
  position: relative;
  transition: background-color 120ms ease, transform 120ms ease;
}
.widget-list-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6875rem;
  bottom: 0.6875rem;
  width: 2px;
  background: transparent;
  border-radius: 1px;
  transition: background-color 120ms ease;
}
.widget-list-item:hover {
  background: hsl(var(--muted) / 0.55);
}
.widget-list-item:hover::before {
  background: hsl(var(--primary));
}
.widget-list-item:has(a.link:focus-visible) {
  background: hsl(var(--muted) / 0.55);
  outline: 1px solid hsl(var(--primary) / 0.45);
  outline-offset: 0;
}

/* Title — clickable or plain. Override the global .link rule that paints
   text in primary; inside widgets we want the title to read as content,
   the hover bg + accent rail signals interactivity. */
.widget-list-item .link,
.widget-list-item .font-medium {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.8125rem;
  line-height: 1.35;
  font-weight: 500;
  color: hsl(var(--nerve-bone));
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.widget-list-item a.link:hover {
  color: hsl(var(--primary));
  text-decoration: none;
}
.widget-list-item a.link:focus-visible { outline: none; }

/* Trailing meta cluster (badges) sits opposite the title. */
.widget-list-item > .badge,
.widget-list-item > .badge + .badge {
  flex: 0 0 auto;
  align-self: center;
  font-size: 0.6875rem;       /* 11px */
  padding: 0.125rem 0.4375rem;
  border-radius: 3px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  font-weight: 500;
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 500;
}
.badge-default {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

/* ─── Auth layout (login/register) ───────────────────── */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 2rem;
}

.auth-card h1 {
  font-size: 1.375rem;
  font-weight: 700;
  color: hsl(var(--nerve-bone));
  margin-bottom: 0.5rem;
}

.auth-card .auth-subtitle {
  font-size: 0.6875rem;
  color: hsl(var(--nerve-steel));
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 1.5rem;
}

.auth-card a {
  color: hsl(var(--primary));
  text-decoration: none;
  font-size: 0.8125rem;
}

.auth-card a:hover {
  text-decoration: underline;
}

/* ─── Misc utilities ─────────────────────────────────── */
.inline { display: inline; }
.inline-flex { display: inline-flex; }
.block { display: block; }
.ml-1 { margin-left: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-6 { margin-bottom: 1.5rem; }
.text-right { text-align: right; }
.max-w-lg { max-width: 32rem; }
.overflow-hidden { overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-link { color: hsl(var(--primary)); text-decoration: none; font-size: 0.8125rem; display: inline-block; margin-bottom: 1rem; }
.back-link:hover { text-decoration: underline; }

/* --- Plugin page table --- */
.page-table-wrap { overflow-x: auto; }
.page-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.page-table th { text-align: left; padding: 0.625rem 0.75rem; font-weight: 600; text-transform: capitalize; color: hsl(var(--muted-foreground)); border-bottom: 1px solid hsl(var(--border)); }
.page-table td { padding: 0.625rem 0.75rem; border-bottom: 1px solid hsl(var(--border)); color: hsl(var(--foreground)); }
.page-table tr:hover td { background: hsl(var(--secondary) / 0.5); }

/* Plugin page toolbar */
.page-toolbar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }

/* Create form */
.create-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.create-form-label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8125rem; color: hsl(var(--muted-foreground)); text-transform: capitalize; }
.hidden { display: none !important; }


textarea.form-input {
  resize: vertical;
  min-height: 150px;
}

input[type="date"].form-input {
  color-scheme: dark;
}
input[type="color"] {
  color-scheme: dark;
}
input[type="color"].form-input {
  padding: 0.125rem 0.25rem;
  height: 2rem;
  width: 3rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* Button sizes */
.button-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.button-xs { padding: 0.125rem 0.375rem; font-size: 0.6875rem; min-width: 1.5rem; }

/* Status badge colors */
.badge-pending { background: hsl(45 90% 50% / 0.15); color: hsl(45 90% 60%); }
.badge-in_progress, .badge-in-progress { background: hsl(200 90% 50% / 0.15); color: hsl(200 90% 60%); }
.badge-done, .badge-completed { background: hsl(var(--primary) / 0.15); color: hsl(var(--primary)); }
.badge-cancelled, .badge-interrupted { background: hsl(var(--destructive) / 0.15); color: hsl(var(--destructive)); }

/* Color swatch in table */
.color-swatch { display: inline-block; width: 1rem; height: 1rem; border-radius: 3px; vertical-align: middle; border: 1px solid hsl(var(--border)); }


/* Create dialog */
dialog.mc-dialog { display: none; }
dialog.mc-dialog[open] { display: block; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 1.25rem; max-width: 960px; width: 90vw; max-height: 85vh; overflow-y: auto; color: hsl(var(--foreground)); }
dialog.mc-dialog::backdrop { background: rgba(0,0,0,0.6); }

.mc-toast { position: fixed; bottom: 1.5rem; right: 1.5rem; padding: 0.75rem 1.25rem; border-radius: var(--radius); background: hsl(var(--card)); border: 1px solid hsl(var(--border)); color: hsl(var(--foreground)); font-size: 0.875rem; z-index: 9999; animation: mc-toast-in 0.2s ease; }
.mc-toast-error { border-color: hsl(var(--destructive)); color: hsl(var(--destructive)); }
@keyframes mc-toast-in { from { opacity: 0; transform: translateY(0.5rem); } to { opacity: 1; transform: none; } }

.filter-active { background: hsl(var(--secondary)) !important; color: hsl(var(--foreground)) !important; }

/* ─── Image upload ──────────────────────────────────── */
.image-upload-area { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.25rem; }
.image-upload-preview { width: 64px; height: 64px; flex-shrink: 0; border-radius: var(--radius); background: hsl(var(--secondary)); display: flex; align-items: center; justify-content: center; }
.image-upload-preview:empty::after { content: '📷'; font-size: 1.5rem; opacity: 0.3; }
.image-upload-controls { display: flex; flex-direction: column; gap: 0.25rem; }

/* ─── Confirmation dialog ───────────────────────────── */
dialog.mc-confirm-dialog[open] { max-width: 440px; }
.mc-confirm-title { font-size: 0.8125rem; font-weight: 600; color: hsl(var(--foreground)); margin-bottom: 0.5rem; }
.mc-confirm-message { font-size: 0.8125rem; color: hsl(var(--muted-foreground)); margin-bottom: 1rem; line-height: 1.5; }
.mc-confirm-input-label { display: block; font-size: 0.6875rem; color: hsl(var(--nerve-steel)); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.375rem; }
.mc-confirm-input { margin-bottom: 1rem; }
.mc-confirm-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* ─── Global scrollbar theming ──────────────────────── */
* { scrollbar-width: thin; scrollbar-color: hsl(var(--border)) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background-color: hsl(var(--border)); border-radius: 4px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background-color: hsl(var(--nerve-steel, var(--muted-foreground))); }
*::-webkit-scrollbar-corner { background: transparent; }


/* ---- Plugin settings sections (admin/settings page) ---- */
/* Header for the plugin integrations group, separates them from
   core "Global settings" above. JetBrains Mono only, sizes 11/13/22. */
.plugin-settings-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid hsl(var(--border));
}
.plugin-settings-header-title {
  font-size: 13px;
  font-weight: 600;
  color: hsl(var(--nerve-bone));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.plugin-settings-header-count {
  font-size: 11px;
  color: var(--muted-foreground);
}

/* Responsive grid: 1 column on narrow, 2 on wide.
   Each card is self-contained — clear border, hover lift, source plugin
   badge in top-right corner. */
.plugin-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  align-items: start;
}

.plugin-settings-card {
  margin-bottom: 0;
  transition: border-color 120ms ease, transform 120ms ease;
}
.plugin-settings-card:hover {
  border-color: hsl(var(--primary));
}

.plugin-settings-card-header {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card));
}
.plugin-settings-card-title {
  font-size: 13px;
  font-weight: 600;
  color: hsl(var(--nerve-bone));
}
.plugin-settings-card-source {
  font-size: 11px;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  padding: 0.125rem 0.5rem;
  border: 1px solid hsl(var(--border));
  border-radius: 4px;
  background: hsl(var(--muted) / 0.3);
}

.plugin-settings-card-content {
  padding: 1rem;
}
.plugin-settings-card-desc {
  font-size: 11px;
  color: var(--muted-foreground);
  margin: 0 0 0.875rem;
  line-height: 1.5;
}

/* Tighter form groups inside plugin section cards so they don't dominate the page. */
.plugin-settings-card-content .form-group {
  margin-bottom: 0.75rem;
}
.plugin-settings-card-content .form-group:last-of-type {
  margin-bottom: 0.875rem;
}
.plugin-settings-card-content label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
  font-weight: 600;
}
.plugin-settings-card-content .form-input {
  font-size: 13px;
  margin-top: 0.25rem;
}
.plugin-settings-card-content .form-group p {
  font-size: 11px;
  color: var(--muted-foreground);
  margin: 0.25rem 0 0;
  line-height: 1.4;
}

.plugin-section-status {
  font-size: 11px;
  margin-top: 0.5rem;
  font-family: var(--font-mono);
}

/* Plugin tabs */
.plugin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid hsl(var(--border));
  margin-bottom: 1.5rem;
}
.plugin-tab {
  padding: 0.5rem 1rem;
  font-size: 13px;
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
}
.plugin-tab.active {
  color: hsl(var(--foreground));
  border-bottom-color: hsl(var(--primary));
}
.plugin-tab:hover {
  color: hsl(var(--foreground));
}

/* Catalog grid */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.catalog-card {
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.catalog-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.catalog-card-name {
  font-size: 13px;
  font-weight: 600;
}
.catalog-card-version {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--muted-foreground));
}
.catalog-card-author {
  font-size: 11px;
  color: hsl(var(--muted-foreground));
}
.catalog-card-desc {
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  flex: 1;
}
.catalog-card-incompatible {
  opacity: 0.6;
}
.catalog-card-versions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.25rem;
}
.catalog-version-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 11px;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  background: hsl(var(--muted) / 0.3);
}
.catalog-version-incompatible {
  opacity: 0.5;
  text-decoration: line-through;
}
.catalog-version-num {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 3.5rem;
}
.catalog-version-core {
  color: hsl(var(--muted-foreground));
}
.catalog-version-size {
  color: hsl(var(--muted-foreground));
  margin-left: auto;
}
.catalog-card-deps {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid hsl(var(--border));
}
.catalog-dep-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 11px;
}
.catalog-dep-status {
  font-weight: 700;
  width: 1rem;
  text-align: center;
}
.catalog-dep-ok {
  color: hsl(var(--primary));
}
.catalog-dep-missing {
  color: hsl(var(--destructive));
}
.catalog-dep-name {
  font-weight: 600;
}
.catalog-dep-constraint {
  color: hsl(var(--muted-foreground));
}
.catalog-dep-type {
  color: hsl(var(--muted-foreground));
  margin-left: auto;
  font-style: italic;
}
.catalog-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
}
/* Catalog install progress bar */
.catalog-install-progress {
  font-size: 11px;
  color: hsl(var(--primary));
  margin-top: 0.25rem;
  display: none;
}
.catalog-install-progress.active {
  display: block;
}
.catalog-progress-bar {
  height: 3px;
  margin-top: 0.25rem;
  border-radius: 2px;
  background: hsl(var(--muted));
  overflow: hidden;
}
.catalog-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: hsl(var(--primary));
  width: 0%;
  transition: width 0.3s ease;
}

/* Core update banner */
.core-update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: hsl(45 100% 51% / 0.12);
  border-bottom: 1px solid hsl(45 100% 51% / 0.25);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}
