@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --accent: #0033E7;
  --accent-light: #3D5CFF;
  --accent-soft: #E8ECFC;
  --bg: #F5F6FA;
  --surface: #FFFFFF;
  --border: #E2E4EC;
  --fg: #12141C;
  --fg-muted: #5B5F70;
  --fg-faint: #9A9EAF;
  --good: #157A4A;
  --good-soft: #E4F5EC;
  --warn: #9A6300;
  --warn-soft: #FBF0DC;
  --danger: #B32323;
  --danger-soft: #FBE7E7;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(18,20,28,.05);
  --shadow-md: 0 8px 24px rgba(18,20,28,.08);
  --font-display: 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
* { margin: 0; padding: 0; }
body {
  font-family: var(--font-body); background: var(--bg); color: var(--fg);
  line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; color: var(--fg); }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ===== Animated background canvas (behind all content) ===== */
.portal-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; opacity: .85; pointer-events: none; }

/* ===== Login screen — Aurora background (distinct from the dashboard's dot canvas) ===== */
.auth-screen {
  position: relative; overflow: hidden; min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem; background: var(--bg);
}
.auth-aurora { position: absolute; inset: -15%; z-index: 0; filter: blur(50px); pointer-events: none; }
.auth-aurora span { position: absolute; border-radius: 50%; opacity: .64; }
.auth-aurora span:nth-child(1) { width: 40vw; height: 40vw; min-width: 320px; min-height: 320px; left: -8%; top: -12%; background: radial-gradient(circle, #0033E7, transparent 70%); animation: aurora-drift-a 13s ease-in-out infinite; }
.auth-aurora span:nth-child(2) { width: 36vw; height: 36vw; min-width: 300px; min-height: 300px; right: -10%; top: 6%; background: radial-gradient(circle, #3D5CFF, transparent 70%); animation: aurora-drift-b 16s ease-in-out infinite; }
.auth-aurora span:nth-child(3) { width: 44vw; height: 44vw; min-width: 340px; min-height: 340px; left: 22%; bottom: -22%; background: radial-gradient(circle, #001A8C, transparent 70%); animation: aurora-drift-a 19s ease-in-out infinite reverse; }
@keyframes aurora-drift-a { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(6%, 7%) scale(1.15); } }
@keyframes aurora-drift-b { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-7%, 5%) scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .auth-aurora span { animation: none; } }
.auth-card {
  position: relative; width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 2.25rem 2rem;
}
.auth-logo { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.75rem; }
.auth-logo img { height: 36px; width: auto; }
.auth-card h1 { font-size: 1.35rem; margin-bottom: .35rem; }
.auth-card .sub { color: var(--fg-muted); font-size: .92rem; margin-bottom: 1.75rem; }
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-family: var(--font-display); font-weight: 600; font-size: .84rem; margin-bottom: .4rem; }
.field input {
  width: 100%; padding: .8rem .9rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.btn-submit {
  width: 100%; padding: .85rem; border: none; border-radius: var(--radius-sm); background: var(--accent); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: .96rem; transition: background .15s, transform .1s;
  margin-top: .4rem;
}
.btn-submit:hover { background: var(--accent-light); }
.btn-submit:disabled { opacity: .6; cursor: default; }
.auth-error {
  display: none; background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm);
  padding: .7rem .9rem; font-size: .86rem; margin-bottom: 1.1rem;
}
.auth-error.is-visible { display: block; }
.auth-foot { margin-top: 1.5rem; text-align: center; font-size: .82rem; color: var(--fg-faint); }

/* ===== Dashboard shell ===== */
.shell { position: relative; display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.shell-sidebar {
  background: var(--surface); border-right: 1px solid var(--border); padding: 1.5rem 1.1rem;
  display: flex; flex-direction: column; gap: 1.5rem;
}
.shell-brand { display: flex; align-items: center; gap: .6rem; padding: 0 .3rem; }
.shell-brand img { height: 30px; }
.shell-role-badge {
  font-family: var(--font-display); font-weight: 600; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); padding: .3rem .7rem; border-radius: 999px; display: inline-flex; width: fit-content;
}
.shell-nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.shell-nav a {
  padding: .65rem .8rem; border-radius: var(--radius-sm); font-size: .92rem; font-weight: 600; color: var(--fg-muted);
  display: flex; align-items: center; gap: .6rem; transition: background .15s, color .15s;
}
.shell-nav a:hover, .shell-nav a.is-active { background: var(--accent-soft); color: var(--accent); }
.shell-user { border-top: 1px solid var(--border); padding-top: 1rem; display: flex; flex-direction: column; gap: .3rem; }
.shell-user .name { font-weight: 600; font-size: .88rem; }
.shell-user .email { font-size: .78rem; color: var(--fg-faint); word-break: break-all; }
.shell-signout {
  margin-top: .5rem; padding: .55rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; font-size: .84rem; font-weight: 600; color: var(--fg-muted); text-align: left;
}
.shell-signout:hover { border-color: var(--danger); color: var(--danger); }
.shell-main { padding: 2rem 2.5rem; }
.shell-header { margin-bottom: 2rem; }
.shell-header h1 { font-size: 1.6rem; margin-bottom: .3rem; }
.shell-header p { color: var(--fg-muted); }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.25rem 1.4rem; box-shadow: var(--shadow-sm); }
.stat-card .num { font-family: var(--font-display); font-weight: 800; font-size: 1.9rem; color: var(--accent); }
.stat-card .label { font-size: .85rem; color: var(--fg-muted); margin-top: .2rem; }

.empty-panel {
  background: var(--surface); border: 1.5px dashed var(--border); border-radius: var(--radius-lg);
  padding: 3rem 2rem; text-align: center; color: var(--fg-muted);
}
.empty-panel h2 { font-size: 1.05rem; color: var(--fg); margin-bottom: .5rem; }
.empty-panel p { font-size: .92rem; max-width: 44ch; margin: 0 auto; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .shell-sidebar { flex-direction: row; align-items: center; overflow-x: auto; padding: 1rem; }
  .shell-nav { flex-direction: row; }
  .shell-user { display: none; }
}

/* ===== Toolbar / panel actions ===== */
.panel-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.panel-toolbar h2 { font-size: 1.15rem; }
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .65rem 1.15rem; border-radius: var(--radius-sm); border: none; font-family: var(--font-display); font-weight: 700; font-size: .9rem; transition: background .15s, transform .1s; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-light); }
.btn-ghost { background: transparent; border: 1.5px solid var(--border); color: var(--fg-muted); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-text { background: transparent; color: var(--accent); font-family: var(--font-display); font-weight: 600; font-size: .86rem; padding: .3rem .5rem; }
.btn-text:hover { text-decoration: underline; }

/* ===== Data table ===== */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data-table th { text-align: left; font-family: var(--font-display); font-weight: 600; font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; color: var(--fg-faint); padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); background: var(--bg); }
.data-table td { padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table td.muted { color: var(--fg-faint); }
.table-empty-row td { text-align: center; color: var(--fg-faint); padding: 2.5rem 1rem; }

/* ===== Status badges ===== */
.badge { display: inline-flex; align-items: center; gap: .4rem; font-family: var(--font-display); font-weight: 600; font-size: .78rem; padding: .3rem .7rem; border-radius: 999px; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--bg); color: var(--fg-faint); border: 1px solid var(--border); }

/* ===== Modal (native <dialog>) ===== */
dialog.modal { border: none; border-radius: var(--radius-lg); padding: 0; box-shadow: var(--shadow-md); width: min(480px, 92vw); }
dialog.modal::backdrop { background: rgba(18,20,28,.45); backdrop-filter: blur(2px); }
.modal-inner { padding: 1.75rem; }
.modal-inner h2 { font-size: 1.2rem; margin-bottom: .3rem; }
.modal-inner .modal-sub { color: var(--fg-muted); font-size: .88rem; margin-bottom: 1.3rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .7rem; margin-top: 1.5rem; }
.field-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 480px) { .field-row-2 { grid-template-columns: 1fr; } }
.field select { width: 100%; padding: .8rem .9rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.field small { display: block; color: var(--fg-faint); font-size: .78rem; margin-top: .35rem; }
.tc-reveal { font-family: var(--font-display); font-weight: 600; }
.tc-reveal button { background: none; border: none; color: var(--accent); font-family: var(--font-display); font-weight: 600; font-size: .84rem; padding: 0; }
.tc-reveal button:hover { text-decoration: underline; }

.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--fg); color: #fff; padding: .85rem 1.2rem; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 600; box-shadow: var(--shadow-md); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--danger); }
