/* Clockspring design system — dark enterprise console */
:root {
  --bg: #0b1019;
  --bg-raised: #111827;
  --bg-panel: #151e2e;
  --bg-hover: #1c2840;
  --border: #243049;
  --border-light: #2e3d5c;
  --text: #e6ecf5;
  --text-dim: #93a1b8;
  --text-faint: #5b6982;
  --accent: #16c2d5;
  --accent-soft: rgba(22, 194, 213, 0.12);
  --accent-2: #7c5cff;
  --green: #2dd482;
  --green-soft: rgba(45, 212, 130, 0.13);
  --amber: #f5b942;
  --amber-soft: rgba(245, 185, 66, 0.13);
  --red: #f4596b;
  --red-soft: rgba(244, 89, 107, 0.13);
  --blue: #5a9cf8;
  --blue-soft: rgba(90, 156, 248, 0.13);
  --purple-soft: rgba(124, 92, 255, 0.14);
  --radius: 10px;
  --sidebar-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Default icon size — context rules (.btn svg, .nav a svg, .stat-icon svg, …)
   override this; it just keeps any unconstrained inline icon from blowing up. */
svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1100px 500px at 80% -10%, rgba(124, 92, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(22, 194, 213, 0.14), transparent 60%),
    var(--bg);
}
.login-card {
  width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 38px 36px 32px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-logo .mark {
  width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: 17px; color: #fff;
}
.login-logo h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.login-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 28px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.login-error { background: var(--red-soft); color: var(--red); border: 1px solid rgba(244,89,107,.3); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-top: 16px; }
.login-hint { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 12px; line-height: 1.7; }
.login-hint code { color: var(--text-dim); }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; border-bottom: 1px solid var(--border); }
.brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: 14px; color: #fff;
  flex-shrink: 0;
}
.brand .name { font-weight: 700; font-size: 15.5px; letter-spacing: -0.2px; }
.brand .org { font-size: 11px; color: var(--text-faint); margin-top: 1px; }

.nav { padding: 14px 10px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 1px 0;
  border-radius: 8px;
  color: var(--text-dim); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--bg-hover); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }

.sidebar-user { border-top: 1px solid var(--border); padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-user .u-name { font-size: 13px; font-weight: 600; line-height: 1.25; }
.sidebar-user .u-role { font-size: 11px; color: var(--text-faint); text-transform: capitalize; }
.sidebar-user button { margin-left: auto; }

.main { flex: 1; margin-left: var(--sidebar-w); padding: 26px 32px 60px; max-width: calc(100vw - var(--sidebar-w)); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h2 { font-size: 21px; font-weight: 700; letter-spacing: -0.3px; }
.page-head .crumbs { font-size: 12.5px; color: var(--text-faint); margin-bottom: 5px; }
.page-head .crumbs a { color: var(--text-dim); text-decoration: none; }
.page-head .crumbs a:hover { color: var(--accent); }
.page-head .sub { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border-light);
  background: var(--bg-panel); color: var(--text);
  cursor: pointer; transition: all .12s;
  text-decoration: none;
}
.btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04222a; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.danger { color: var(--red); border-color: rgba(244,89,107,.4); }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }

input, select, textarea {
  font-family: var(--font); font-size: 13.5px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-light); border-radius: 8px;
  padding: 9px 12px; width: 100%;
  outline: none; transition: border-color .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-faint); }
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 120px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2393a1b8' fill='none' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 30px; }

.search-box { position: relative; width: 260px; }
.search-box input { padding-left: 34px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-faint); pointer-events: none; }

/* ---------- Cards / stats ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1200px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card h3 { font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h3 svg { width: 15px; height: 15px; }

.stat-card { position: relative; overflow: hidden; }
.stat-card .stat-label { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.stat-card .stat-value { font-size: 30px; font-weight: 700; letter-spacing: -1px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.stat-card .stat-icon {
  position: absolute; right: 16px; top: 16px;
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}
.stat-card .stat-icon svg { width: 18px; height: 18px; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint);
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.015);
  white-space: nowrap;
}
tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr.clickable { cursor: pointer; }
td.mono, .mono { font-family: var(--mono); font-size: 12.5px; }
td .dim { color: var(--text-faint); }
.table-empty { padding: 48px; text-align: center; color: var(--text-faint); }
.table-empty .big { font-size: 15px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
tr:hover .row-actions { opacity: 1; }
.icon-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-dim); padding: 5px; border-radius: 6px;
  display: inline-flex; transition: all .12s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--accent); }
.icon-btn.danger:hover { color: var(--red); background: var(--red-soft); }
.icon-btn svg { width: 15px; height: 15px; }

/* ---------- Pills & badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 99px;
  text-transform: capitalize;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.cyan { background: var(--accent-soft); color: var(--accent); }
.pill.purple { background: var(--purple-soft); color: var(--accent-2); }
.pill.gray { background: rgba(147,161,184,.12); color: var(--text-dim); }

.tag { font-family: var(--mono); font-size: 11.5px; background: var(--bg); border: 1px solid var(--border); padding: 2px 8px; border-radius: 6px; color: var(--text-dim); }

/* ---------- Utilization bars ---------- */
.util { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.util .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden; }
.util .fill { height: 100%; border-radius: 3px; background: var(--green); transition: width .3s; }
.util .fill.warn { background: var(--amber); }
.util .fill.crit { background: var(--red); }
.util .pct { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-dim); width: 36px; text-align: right; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 8, 16, 0.72);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 20px 20px;
  backdrop-filter: blur(3px);
  animation: fadeIn .15s;
}
.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  width: 520px; max-width: 100%;
  max-height: 84vh; overflow-y: auto;
  box-shadow: 0 30px 90px rgba(0,0,0,.6);
  animation: slideUp .18s;
}
.modal.wide { width: 680px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 0; }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 18px 22px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.form-row .help { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } }

/* ---------- Toasts ---------- */
#toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg-panel); border: 1px solid var(--border-light);
  border-radius: 10px; padding: 12px 18px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  display: flex; align-items: center; gap: 10px;
  animation: slideUp .2s; max-width: 420px;
}
.toast.ok { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--red); }

/* ---------- Misc ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.section-title { font-size: 15px; font-weight: 700; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title svg { width: 16px; height: 16px; flex-shrink: 0; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }
.readonly-note {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--amber-soft); color: var(--amber);
  font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 99px;
}
.readonly-note svg { width: 13px; height: 13px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs button {
  background: none; border: none; cursor: pointer;
  font-family: var(--font); font-size: 13.5px; font-weight: 600;
  color: var(--text-dim); padding: 10px 16px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .12s;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

.danger-zone { border: 1px solid rgba(244,89,107,.35); border-radius: var(--radius); }
.danger-zone .dz-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid rgba(244,89,107,.18); }
.danger-zone .dz-row:last-child { border-bottom: none; }
.danger-zone .dz-title { font-weight: 600; font-size: 13.5px; }
.danger-zone .dz-desc { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--text-faint); }
.kv dd { color: var(--text); }

code.inline { font-family: var(--mono); font-size: 12px; background: var(--bg); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; }

.edition-tag {
  display: inline-block; font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 1px 6px; border-radius: 5px; vertical-align: middle;
  margin-left: 2px;
}
.edition-tag.enterprise { background: var(--purple-soft); color: var(--accent-2); }
.edition-tag.professional { background: var(--accent-soft); color: var(--accent); }
.edition-tag.community { background: rgba(147,161,184,.15); color: var(--text-dim); }

.lic-banner {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; font-weight: 600;
  padding: 10px 16px; border-radius: 10px; margin-bottom: 18px;
}
.lic-banner svg { width: 16px; height: 16px; flex-shrink: 0; }
.lic-banner.amber { background: var(--amber-soft); color: var(--amber); border: 1px solid rgba(245,185,66,.3); }
.lic-banner.red { background: var(--red-soft); color: var(--red); border: 1px solid rgba(244,89,107,.3); }

.loading { padding: 60px; text-align: center; color: var(--text-faint); }
.spinner {
  width: 22px; height: 22px; margin: 0 auto 12px;
  border: 2px solid var(--border-light); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
