/* ConnexThermo — sistema visivo
   Soft / moderno, ispirato a Stripe/Notion. Superfici bianche,
   neutri caldi tendenti al grigio-tortora freddo, accento blu-indaco
   tenue. Tipografia Inter + JetBrains Mono per i dati numerici. */

:root {
  /* Neutrals */
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --border: #ececea;
  --border-strong: #dedcd8;
  --text: #1a1a19;
  --text-2: #5b5b58;
  --text-3: #8a8a86;
  --text-4: #b3b3ae;

  /* Accento — indaco tenue */
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-text: #3730a3;

  /* Stati semantici */
  --ok: #15803d;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fef7e6;
  --crit: #b91c1c;
  --crit-soft: #fef2f2;
  --info: #1d4ed8;
  --info-soft: #eef4ff;

  --shadow-xs: 0 1px 0 rgba(20, 20, 18, 0.04);
  --shadow-sm: 0 1px 2px rgba(20, 20, 18, 0.05), 0 0 0 1px rgba(20, 20, 18, 0.04);
  --shadow-md: 0 4px 12px rgba(20, 20, 18, 0.06), 0 1px 3px rgba(20, 20, 18, 0.04);

  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --sidebar-w: 240px;
}

html, body {
  margin: 0; padding: 0;
  font-family: var(--font-sans);
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 13.5px;
}

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

/* ── App shell ───────────────────────────────────────────── */
.ct-app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--bg);
}
.ct-app.collapsed { --sidebar-w: 64px; }

/* Sidebar */
.ct-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
  position: sticky; top: 0; height: 100vh;
}
.ct-brand {
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; text-decoration: none;
}
.ct-brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px; letter-spacing: -0.5px;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 1px 2px rgba(79,70,229,0.3);
}
.ct-brand-name {
  font-size: 14.5px; font-weight: 600; color: var(--text); letter-spacing: -0.2px;
  white-space: nowrap;
}
.ct-brand-name span { color: var(--text-3); font-weight: 500; }
.ct-app.collapsed .ct-brand-name,
.ct-app.collapsed .ct-nav-label,
.ct-app.collapsed .ct-nav-section-title,
.ct-app.collapsed .ct-sidebar-footer .meta { display: none; }
.ct-app.collapsed .ct-brand { justify-content: center; padding: 0; }

.ct-sidebar-section { padding: 16px 10px 4px; }
.ct-nav-section-title {
  font-size: 11px; font-weight: 500; color: var(--text-3);
  padding: 0 8px 6px; letter-spacing: 0.3px; text-transform: uppercase;
}
.ct-nav { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1px; }
.ct-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13px; font-weight: 500;
  cursor: pointer; text-decoration: none;
  white-space: nowrap;
  position: relative;
}
.ct-nav-item:hover { background: var(--surface-2); color: var(--text); }
.ct-nav-item.active { background: var(--accent-soft); color: var(--accent-text); }
.ct-nav-item .ct-icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-3); }
.ct-nav-item.active .ct-icon, .ct-nav-item:hover .ct-icon { color: currentColor; }
.ct-nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 10px; min-width: 18px; text-align: center;
  background: var(--crit-soft); color: var(--crit);
  font-variant-numeric: tabular-nums;
}
.ct-app.collapsed .ct-nav-item { justify-content: center; padding: 8px; }
.ct-app.collapsed .ct-nav-badge { position: absolute; top: 2px; right: 2px; padding: 0 4px; min-width: 14px; font-size: 10px; }

.ct-sidebar-footer {
  margin-top: auto; padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.ct-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #d8d4cc, #c5c0b6); color: #5b5b58;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.ct-sidebar-footer .meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ct-sidebar-footer .name { font-size: 12.5px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-sidebar-footer .role { font-size: 11px; color: var(--text-3); text-transform: capitalize; }

/* Main */
.ct-main { display: flex; flex-direction: column; min-width: 0; }
.ct-topbar {
  height: 56px; border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; padding: 0 24px; gap: 16px;
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 30;
}
.ct-crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); }
.ct-crumbs .sep { color: var(--text-4); }
.ct-crumbs .here { color: var(--text); font-weight: 500; }
.ct-topbar-spacer { flex: 1; }
.ct-icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent;
  cursor: pointer; color: var(--text-2); position: relative;
  text-decoration: none;
}
.ct-icon-btn:hover { background: var(--surface-2); color: var(--text); }
.ct-icon-btn .dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px; border-radius: 4px; background: var(--crit);
  border: 1.5px solid var(--surface);
}

/* Content */
.ct-content { flex: 1; padding: 24px 32px 48px; }
.ct-page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  margin-bottom: 24px;
}
.ct-page-title {
  font-size: 22px; font-weight: 600; letter-spacing: -0.4px; color: var(--text); margin: 0 0 4px;
}
.ct-page-sub { font-size: 13px; color: var(--text-3); margin: 0; }
.ct-page-actions { display: flex; gap: 8px; }

/* Buttons (override Bootstrap) */
.ct-btn,
.btn:not(.btn-close) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: var(--radius-sm); font-family: inherit;
  font-size: 12.5px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-xs);
  text-decoration: none; line-height: 1;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.ct-btn:hover, .btn:not(.btn-close):hover { background: var(--surface-2); color: var(--text); }
.btn-primary, .ct-btn-primary {
  background: var(--text) !important; color: #fff !important; border-color: var(--text) !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.06) !important;
}
.btn-primary:hover, .ct-btn-primary:hover { background: #2a2a28 !important; border-color: #2a2a28 !important; }
.btn-secondary, .btn-light, .btn-outline-primary, .btn-outline-secondary {
  background: var(--surface) !important; color: var(--text) !important;
  border-color: var(--border-strong) !important;
}
.btn-danger {
  background: var(--crit) !important; color: #fff !important; border-color: var(--crit) !important;
}
.btn-success {
  background: var(--ok) !important; color: #fff !important; border-color: var(--ok) !important;
}
.btn-warning {
  background: var(--warn) !important; color: #fff !important; border-color: var(--warn) !important;
}
.btn-ghost, .ct-btn-ghost { border-color: transparent !important; background: transparent !important; box-shadow: none !important; color: var(--text-2) !important; }
.btn-ghost:hover, .ct-btn-ghost:hover { background: var(--surface-2) !important; color: var(--text) !important; }
.btn-sm { height: 28px !important; padding: 0 10px !important; font-size: 12px !important; }
.btn-lg { height: 42px !important; padding: 0 18px !important; font-size: 13.5px !important; }
.btn-block, .btn.w-100 { width: 100%; }

/* Cards (override Bootstrap) */
.card, .ct-card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-xs) !important;
  overflow: hidden;
}
.card-header, .ct-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px !important;
  border-bottom: 1px solid var(--border) !important;
  background: var(--surface) !important;
}
.card-title, .ct-card-title { font-size: 14px; font-weight: 600; color: var(--text); margin: 0; }
.ct-card-sub { font-size: 12px; color: var(--text-3); margin: 2px 0 0; }
.card-body { padding: 16px !important; }

/* Forms (override Bootstrap) */
.form-control, .form-select, .ct-input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius-sm) !important;
  background: var(--surface) !important;
  font-size: 13.5px !important;
  color: var(--text) !important;
  box-shadow: none !important;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control:focus, .form-select:focus, .ct-input:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12) !important;
  outline: none !important;
}
textarea.form-control { height: auto; padding: 10px 12px; }
.form-control-lg { height: 42px; font-size: 14px !important; }
.form-label, label.form-label {
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
  margin-bottom: 6px;
}

/* KPI cards */
.ct-kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 1100px) { .ct-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.ct-kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-xs);
}
.ct-kpi-label { font-size: 12px; color: var(--text-3); font-weight: 500; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.ct-kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -0.6px; line-height: 1; font-family: var(--font-mono); }
.ct-kpi-value .unit { font-size: 14px; color: var(--text-3); margin-left: 4px; font-weight: 500; }
.ct-kpi-trend {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 500; margin-top: 10px;
  font-variant-numeric: tabular-nums;
}
.ct-kpi-trend.up { color: var(--ok); }
.ct-kpi-trend.down { color: var(--crit); }
.ct-kpi-trend.flat { color: var(--text-3); }

/* Tables */
.table {
  width: 100%; border-collapse: collapse;
  font-size: 12.5px !important;
  color: var(--text) !important;
  margin-bottom: 0 !important;
}
.table th {
  text-align: left !important; font-weight: 500 !important; color: var(--text-3) !important;
  font-size: 11.5px !important;
  padding: 10px 12px !important; border-bottom: 1px solid var(--border) !important;
  background: var(--surface-2) !important; text-transform: uppercase; letter-spacing: 0.3px;
  white-space: nowrap;
}
.table td {
  padding: 11px 12px !important; border-bottom: 1px solid var(--border) !important;
  vertical-align: middle !important;
  background: var(--surface) !important;
}
.table tbody tr:hover td { background: var(--surface-2) !important; }
.table tbody tr:last-child td { border-bottom: none !important; }
.table .num, .ct-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ct-muted, .table .muted { color: var(--text-3) !important; }
.text-muted { color: var(--text-3) !important; }

/* Status pill */
.ct-pill, .badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px !important; border-radius: 100px !important;
  font-size: 11px !important; font-weight: 500 !important; white-space: nowrap;
  line-height: 1.4 !important;
}
.ct-pill .dot { width: 6px; height: 6px; border-radius: 3px; }
.ct-pill.ok, .badge.bg-success { background: var(--ok-soft) !important; color: var(--ok) !important; }
.ct-pill.ok .dot { background: var(--ok); }
.ct-pill.warn, .badge.bg-warning { background: var(--warn-soft) !important; color: var(--warn) !important; }
.ct-pill.warn .dot { background: var(--warn); }
.ct-pill.crit, .badge.bg-danger { background: var(--crit-soft) !important; color: var(--crit) !important; }
.ct-pill.crit .dot { background: var(--crit); }
.ct-pill.info, .badge.bg-info, .badge.bg-primary { background: var(--info-soft) !important; color: var(--info) !important; }
.ct-pill.info .dot { background: var(--info); }
.ct-pill.neutral, .badge.bg-secondary, .badge.bg-light { background: var(--surface-2) !important; color: var(--text-3) !important; border: 1px solid var(--border); }
.ct-pill.neutral .dot { background: var(--text-3); }

/* Alerts (Bootstrap override) */
.alert {
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  padding: 12px 14px !important;
  font-size: 13px !important;
}
.alert-success { background: var(--ok-soft) !important; color: var(--ok) !important; border-color: rgba(21,128,61,0.18) !important; }
.alert-danger  { background: var(--crit-soft) !important; color: var(--crit) !important; border-color: rgba(185,28,28,0.18) !important; }
.alert-warning { background: var(--warn-soft) !important; color: var(--warn) !important; border-color: rgba(180,83,9,0.18) !important; }
.alert-info    { background: var(--info-soft) !important; color: var(--info) !important; border-color: rgba(29,78,216,0.18) !important; }

/* Tabs */
.ct-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.ct-tab {
  padding: 8px 14px; font-size: 13px; font-weight: 500; color: var(--text-3);
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; text-decoration: none;
}
.ct-tab:hover { color: var(--text-2); }
.ct-tab.active { color: var(--text); border-bottom-color: var(--text); }

/* Chips */
.ct-chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 12px; border-radius: 100px;
  background: var(--surface); border: 1px solid var(--border-strong);
  font-size: 12px; color: var(--text-2); cursor: pointer;
  text-decoration: none;
}
.ct-chip:hover { background: var(--surface-2); }
.ct-chip.active { background: var(--text); color: #fff; border-color: var(--text); }

/* Helpers */
.ct-row { display: flex; align-items: center; gap: 8px; }
.ct-row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ct-stack-12 > * + * { margin-top: 12px; }
.ct-stack-16 > * + * { margin-top: 16px; }
.ct-stack-20 > * + * { margin-top: 20px; }
.ct-two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.ct-three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* Topbar dropdowns (Bootstrap override) */
.dropdown-menu {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
  padding: 4px !important;
  font-size: 13px !important;
}
.dropdown-item {
  border-radius: var(--radius-sm) !important;
  padding: 7px 10px !important;
  font-size: 13px !important;
  color: var(--text-2) !important;
}
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2) !important; color: var(--text) !important; }
.dropdown-divider { border-color: var(--border) !important; margin: 4px 2px !important; }

/* ── Auth shell ───────────────────────────────────────────── */
.ct-auth {
  min-height: 100vh;
  background: linear-gradient(180deg, #faf9f6 0%, #f0eee9 100%);
  display: flex; flex-direction: column;
}
.ct-auth-header {
  display: flex; align-items: center; gap: 10px;
  padding: 24px 32px;
}
.ct-auth-header .ct-brand-mark { width: 28px; height: 28px; font-size: 13px; }
.ct-auth-body {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 0 16px 32px;
}
.ct-auth-card {
  width: 100%; max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(20,20,18,0.06), 0 1px 2px rgba(20,20,18,0.04);
  padding: 32px;
}
.ct-auth-title { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; margin: 0 0 6px; }
.ct-auth-sub   { font-size: 13px; color: var(--text-3); margin: 0 0 24px; }
.ct-auth-footer {
  text-align: center; padding: 0 32px 24px;
  font-size: 12px; color: var(--text-3);
}
.ct-auth-divider {
  display: flex; align-items: center; gap: 12px; margin: 20px 0 16px;
  font-size: 11.5px; color: var(--text-3);
}
.ct-auth-divider::before, .ct-auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* utility */
.ct-text-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ct-hide { display: none !important; }

/* Hide legacy theme bits if accidentally present */
#preloader, .nav-header, .deznav, .header { display: none !important; }
.content-body { margin-left: 0 !important; padding: 0 !important; }
