/* ==========================================================================
   Drubix app — shared design system
   Used by every page under src/dashboard/public. Brand navy/teal from the
   logo, extended with a colorful accent + severity palette.
   ========================================================================== */

:root {
  /* brand */
  --ink: #0a2c40;
  --ink-deep: #071f2e;
  --ink-soft: #123a52;
  --teal: #1c93b0;
  --teal-600: #167e97;
  --cyan: #3fd1e0;
  --violet: #7c5cff;
  --pink: #ec4899;
  --grad-brand: linear-gradient(135deg, #1c93b0 0%, #3fd1e0 100%);
  --grad-hero: linear-gradient(120deg, #0a2c40 0%, #0f4c6b 45%, #1c93b0 100%);
  --grad-violet: linear-gradient(135deg, #7c5cff 0%, #3fd1e0 100%);

  /* surfaces */
  --bg: #f3f7fa;
  --surface: #ffffff;
  --surface-alt: #f6f9fb;
  --border: #e2eaef;
  --border-strong: #cfdbe2;

  /* text */
  --text: #122330;
  --text-muted: #5f707c;
  --text-faint: #8a99a4;

  /* status */
  --crit: #e5484d;   --crit-bg: #fdecec;  --crit-bd: #f8c9ca;
  --high: #f76b15;   --high-bg: #fff1e7;  --high-bd: #fdd2b3;
  --mod:  #d99a00;   --mod-bg:  #fff8e1;  --mod-bd:  #f5e0a0;
  --low:  #3b82f6;   --low-bg:  #eaf2ff;  --low-bd:  #c4d9fb;
  --info: #7b8a96;   --info-bg: #eff3f6;  --info-bd: #d8e0e6;
  --ok:   #12a150;   --ok-bg:   #e6f7ed;  --ok-bd:   #b6e6c9;
  --warn: #b7791f;   --warn-bg: #fff6e0;  --warn-bd: #f3dc9f;
  --ai:   #7c5cff;   --ai-bg:   #f0ecff;  --ai-bd:   #d6ccff;

  --danger: var(--crit); --danger-bg: var(--crit-bg); --danger-border: var(--crit-bd);
  --success: var(--ok);  --success-bg: var(--ok-bg);  --success-border: var(--ok-bd);

  /* type */
  --display: "Poppins", "Inter", sans-serif;
  --sans: "Inter", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;

  /* shape */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(10, 44, 64, .06);
  --shadow: 0 1px 2px rgba(10, 44, 64, .05), 0 4px 16px rgba(10, 44, 64, .06);
  --shadow-lg: 0 12px 40px rgba(10, 44, 64, .16);
  --ring: 0 0 0 3px rgba(28, 147, 176, .22);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-600); text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--display); color: var(--ink); margin: 0; letter-spacing: -0.01em; font-weight: 600; }
code, .mono { font-family: var(--mono); }
code {
  background: var(--surface-alt); color: var(--ink); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 5px; font-size: 12.5px; word-break: break-all;
}
.muted { color: var(--text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- buttons ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--sans); font-size: 13.5px; font-weight: 600; line-height: 1;
  padding: 10px 16px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
  text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--teal); color: var(--teal); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .6; cursor: default; transform: none; }
button svg, .btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary { background: var(--grad-brand); color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(28,147,176,.3); }
.btn-primary:hover { color: #fff; border-color: transparent; filter: brightness(1.05); box-shadow: 0 4px 14px rgba(28,147,176,.38); }
.btn-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-dark:hover { background: var(--ink-soft); color: #fff; border-color: var(--ink-soft); }
.btn-violet { background: var(--grad-violet); color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(124,92,255,.28); }
.btn-violet:hover { color: #fff; border-color: transparent; filter: brightness(1.05); }
.btn-danger { background: var(--crit); color: #fff; border-color: var(--crit); }
.btn-danger:hover { background: #cf3a3f; color: #fff; border-color: #cf3a3f; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-alt); border-color: var(--border); color: var(--text); }
.btn-ghost.danger:hover { background: var(--crit-bg); border-color: var(--crit-bd); color: var(--crit); }
.btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn { padding: 8px; width: 34px; height: 34px; }

.btn-spinner {
  display: inline-block; width: 12px; height: 12px; margin-right: 2px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: btn-spin .6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin: 16px 0 6px; }
input, select, textarea {
  width: 100%; font-family: var(--sans); font-size: 14px; color: var(--text);
  padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
/* Checkboxes and radios keep their natural size (the rule above is for text fields). */
input[type=checkbox], input[type=radio] { width: auto; padding: 0; flex-shrink: 0; accent-color: var(--teal); }
input::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: var(--ring); }
.input-icon { position: relative; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }
.input-icon > svg, .input-icon > [data-icon] { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; }
.input-icon > [data-icon] svg { width: 16px; height: 16px; }
.input-icon > input { padding-left: 38px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-title { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 15px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.card-desc { font-size: 13.5px; color: var(--text-muted); margin: 0 0 14px; }
.icon-tile {
  width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--low-bg); color: var(--teal);
}
.icon-tile svg { width: 17px; height: 17px; }
.icon-tile.teal { background: #e3f5f9; color: var(--teal); }
.icon-tile.violet { background: var(--ai-bg); color: var(--ai); }
.icon-tile.orange { background: var(--high-bg); color: var(--high); }
.icon-tile.red { background: var(--crit-bg); color: var(--crit); }
.icon-tile.green { background: var(--ok-bg); color: var(--ok); }
.icon-tile.blue { background: var(--low-bg); color: var(--low); }
.icon-tile.amber { background: var(--mod-bg); color: var(--mod); }

/* ---------- badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1.4;
  border: 1px solid var(--info-bd); background: var(--info-bg); color: var(--info);
  text-transform: capitalize; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.critical { background: var(--crit-bg); border-color: var(--crit-bd); color: var(--crit); }
.badge.high     { background: var(--high-bg); border-color: var(--high-bd); color: var(--high); }
.badge.moderate { background: var(--mod-bg);  border-color: var(--mod-bd);  color: #a87400; }
.badge.low      { background: var(--low-bg);  border-color: var(--low-bd);  color: var(--low); }
.badge.info     { background: var(--info-bg); border-color: var(--info-bd); color: var(--info); }
.badge.ok       { background: var(--ok-bg);   border-color: var(--ok-bd);   color: var(--ok); }
.badge.warn     { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn); }
.badge.danger   { background: var(--crit-bg); border-color: var(--crit-bd); color: var(--crit); }
.badge.ai       { background: var(--ai-bg);   border-color: var(--ai-bd);   color: var(--ai); }
.badge.kev      { background: var(--crit); border-color: var(--crit); color: #fff; }
.badge.kev::before { background: #fff; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- inline messages ---------- */
.inline-msg { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 9px; font-size: 13px; margin-top: 10px; border: 1px solid; }
.inline-msg.error   { background: var(--crit-bg); border-color: var(--crit-bd); color: #b4282d; }
.inline-msg.success { background: var(--ok-bg);   border-color: var(--ok-bd);   color: #0c7a3c; }
.inline-msg.info    { background: var(--low-bg);  border-color: var(--low-bd);  color: #2563c9; }
.inline-msg.warn    { background: var(--warn-bg); border-color: var(--warn-bd); color: #8a5a10; }

/* ---------- toasts ---------- */
#toast-container {
  position: fixed; top: 18px; right: 18px; z-index: 2000;
  display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 36px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px 12px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.45;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); border-left: 4px solid var(--teal);
  animation: toast-in .22s ease-out;
}
.toast::before {
  content: ""; flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%; margin-top: 1px;
  background: var(--teal) center/12px no-repeat;
}
.toast.error { border-left-color: var(--crit); }
.toast.error::before { background-color: var(--crit); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M8 4v5M8 12h0'/%3E%3C/svg%3E"); }
.toast.success { border-left-color: var(--ok); }
.toast.success::before { background-color: var(--ok); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E"); }
.toast.info::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M8 7v5M8 4h0'/%3E%3C/svg%3E"); }
.toast .toast-msg { flex: 1; }
.toast .toast-close { padding: 0; border: 0; background: none; color: var(--text-faint); font-size: 18px; line-height: 1; cursor: pointer; }
.toast .toast-close:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ---------- modal (confirm dialog) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1500; background: rgba(7, 31, 46, .45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade-in .15s ease-out;
}
.modal {
  width: 100%; max-width: 440px; background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 24px; animation: pop-in .18s ease-out;
}
.modal h3 { font-size: 17px; margin: 12px 0 6px; }
.modal p { color: var(--text-muted); font-size: 13.5px; margin: 0 0 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(6px); } }

/* ---------- skeleton ---------- */
.skeleton { background: linear-gradient(90deg, #eaf0f3 0%, #f5f8fa 50%, #eaf0f3 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ==========================================================================
   App shell (dashboard + settings)
   ========================================================================== */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--ink-deep);
  background-image: radial-gradient(120% 60% at 0% 0%, rgba(63,209,224,.16) 0%, transparent 60%),
                    radial-gradient(100% 50% at 100% 100%, rgba(124,92,255,.18) 0%, transparent 60%);
  color: #c4d3dc; padding: 22px 16px; display: flex; flex-direction: column; gap: 6px;
}
.sidebar .brand { display: flex; align-items: center; padding: 4px 10px 22px; }
.sidebar .brand img { height: 28px; filter: brightness(0) invert(1); }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #6f8b9b; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
  color: #c4d3dc; font-weight: 500; font-size: 13.5px; text-decoration: none; transition: background .15s, color .15s;
}
.nav a svg { width: 17px; height: 17px; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(63,209,224,.20), rgba(63,209,224,.04)); color: #fff; box-shadow: inset 3px 0 0 var(--cyan); }
.nav a.active svg { color: var(--cyan); opacity: 1; }
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.plan-card {
  border-radius: 14px; padding: 16px; color: #fff;
  background: linear-gradient(145deg, rgba(124,92,255,.55), rgba(28,147,176,.55));
  border: 1px solid rgba(255,255,255,.12);
}
.plan-card .plan-kicker { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.plan-card .plan-name { font-family: var(--display); font-weight: 600; font-size: 16px; margin: 2px 0 6px; }
.plan-card p { font-size: 12.5px; opacity: .85; margin: 0 0 12px; }
.plan-card button { width: 100%; white-space: normal; line-height: 1.3; text-align: center; background: #fff; color: var(--ink); border-color: #fff; }
.plan-card button:hover { background: #eef9fb; color: var(--ink); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; margin-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: var(--grad-violet); color: #fff; font-weight: 700; font-size: 13px; text-transform: uppercase;
}
.user-chip .who { min-width: 0; flex: 1; }
.user-chip .who strong { display: block; color: #fff; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who span { display: block; font-size: 11.5px; color: #8aa3b1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip a { color: #8aa3b1; display: flex; padding: 6px; border-radius: 8px; }
.user-chip a:hover { color: #fff; background: rgba(255,255,255,.08); }
.user-chip a svg { width: 17px; height: 17px; }

.main { min-width: 0; padding: 28px 36px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--text-muted); margin: 4px 0 0; font-size: 14px; }
.mobile-bar { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 1200; box-shadow: var(--shadow-lg); }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: sticky; top: 0; z-index: 1100; padding: 12px 16px;
    background: var(--ink-deep); color: #fff;
  }
  .mobile-bar img { height: 24px; filter: brightness(0) invert(1); }
  .mobile-bar button { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); color: #fff; }
  .main { padding: 20px 16px 48px; }
}

/* ==========================================================================
   Auth pages (login, signup, reset, verify, invite)
   ========================================================================== */
.auth { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.auth-art {
  position: relative; overflow: hidden; color: #fff; padding: 44px 52px;
  background: var(--grad-hero); display: flex; flex-direction: column; justify-content: space-between;
}
.auth-art::before, .auth-art::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(10px); opacity: .55; pointer-events: none;
}
.auth-art::before { width: 420px; height: 420px; right: -120px; top: -120px; background: radial-gradient(circle, rgba(63,209,224,.7), transparent 65%); }
.auth-art::after { width: 380px; height: 380px; left: -120px; bottom: -140px; background: radial-gradient(circle, rgba(124,92,255,.7), transparent 65%); }
.auth-art > * { position: relative; z-index: 1; }
.auth-art .logo { height: 30px; width: auto; align-self: flex-start; filter: brightness(0) invert(1); }
.auth-art h2 { color: #fff; font-size: 32px; line-height: 1.2; max-width: 16ch; margin-bottom: 14px; }
.auth-art h2 span { background: linear-gradient(90deg, #7ff0f7, #c3b5ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-art p { color: #cfe3ec; font-size: 15px; max-width: 42ch; margin: 0 0 26px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.auth-points li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #e8f4f8; }
.auth-points li i {
  width: 30px; height: 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); font-style: normal;
}
.auth-points li i svg { width: 15px; height: 15px; }
.auth-art .fine { font-size: 12.5px; color: #9fc0cf; }

.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .logo-mobile { display: none; height: 28px; margin-bottom: 28px; }
.auth-card h1 { font-size: 26px; margin: 0 0 8px; }
.auth-card p.sub { color: var(--text-muted); font-size: 14.5px; margin: 0 0 20px; }
.auth-card button[type=submit], .auth-card .btn-primary { width: 100%; margin-top: 24px; padding: 13px; font-size: 15px; }
.auth-card .foot { margin: 20px 0 0; font-size: 13.5px; color: var(--text-muted); text-align: center; }
.auth-card #error { display: none; }
.auth-card #error, .auth-card #msg { margin-top: 14px; padding: 10px 12px; border-radius: 9px; font-size: 13.5px; border: 1px solid; }
.auth-card #error, .auth-card .error { background: var(--crit-bg); border-color: var(--crit-bd); color: #b4282d; }
.auth-card .success { background: var(--ok-bg); border-color: var(--ok-bd); color: #0c7a3c; }
.auth-card p.sub.error, .auth-card p.sub.success { padding: 10px 12px; border-radius: 9px; }
.auth-card p.sub.error { background: var(--crit-bg); border: 1px solid var(--crit-bd); color: #b4282d; }
.auth-card p.sub.success { background: var(--ok-bg); border: 1px solid var(--ok-bd); color: #0c7a3c; }
.auth-card #msg:not(.error):not(.success) { display: none; }
.auth-card p#msg.sub:not(.error):not(.success) { display: block; border: 0; padding: 0; }
.auth-card .status-icon {
  width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
  background: var(--grad-brand); color: #fff; margin-bottom: 20px; box-shadow: 0 8px 24px rgba(28,147,176,.3);
}
.auth-card .status-icon svg { width: 26px; height: 26px; }
.pw-meter { height: 5px; border-radius: 5px; background: var(--border); margin-top: 8px; overflow: hidden; }
.pw-meter span { display: block; height: 100%; width: 0; border-radius: 5px; transition: width .2s, background .2s; }
.pw-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-card .logo-mobile { display: block; }
}
