:root{
  --bg:#f5f7fb;
  --panel:#ffffff;
  --muted:#6b7280;
  --text:#0f172a;
  --border: rgba(15,23,42,.08);
  --shadow: 0 12px 30px rgba(15,23,42,.08);
  --soft: rgba(15,23,42,.05);
  --primary: #3b82f6;

  --radius: 14px;
  --radius2: 18px;

  --sidebarW: 260px;
  --topbarH: 72px;
}

.theme-dark{
  --bg:#0b1220;
  --panel:#121c2e;
  --muted:#9aa7bd;
  --text:#e6edf8;
  --border: rgba(255,255,255,.07);
  --shadow: 0 18px 45px rgba(0,0,0,.35);
  --soft: rgba(255,255,255,.06);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family:Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:var(--bg);
  color:var(--text);
}

a{ color:inherit; text-decoration:none; }
small{ color:var(--muted); }

/* ===== APP LAYOUT ===== */

.app-shell{
  display:flex;
  min-height:100vh;
}

.sidebar{
  width:var(--sidebarW);
  background:var(--panel);
  border-right:1px solid var(--border);
  position:sticky;
  top:0;
  height:100vh;
  padding:16px;
  overflow:auto;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding:6px 8px 14px 8px;
}

.brand-logo{
  width:34px;
  height:34px;
  border-radius:10px;
  object-fit:cover;
}

.brand-name{
  font-weight:800;
  letter-spacing:.3px;
}

.nav{
  display:flex;
  flex-direction:column;
  gap:6px;
  padding-top:6px;
}

.nav-sep{
  margin:10px 8px 4px;
  font-size:12px;
  letter-spacing:.1em;
  color:var(--muted);
  font-weight:700;
}

.nav-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid transparent;
  color:var(--text);
  background:transparent;
}

.nav-item:hover{
  background:var(--soft);
}

.nav-item.active{
  background: rgba(59,130,246,.14);
  border-color: rgba(59,130,246,.18);
}

.nav-item.danger{
  color:#ef4444;
}

.ni-ic{
  width:22px;
  text-align:center;
}

.ni-t{
  font-weight:600;
}

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

/* ===== TOPBAR ===== */

.topbar{
  height:var(--topbarH);
  display:flex;
  align-items:center;
  gap:12px;
  padding:14px 18px;
  border-bottom:1px solid var(--border);
  position:sticky;
  top:0;
  backdrop-filter: blur(10px);
  z-index:10;
}

.theme-dark .topbar{
  background: rgba(11,18,32,.55);
}

.topbar-title{
  display:flex;
  flex-direction:column;
  gap:2px;
  min-width:0;
}

.crumb{
  font-size:12px;
  color:var(--muted);
}

.ttl{
  font-size:18px;
  font-weight:800;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.topbar-actions{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:10px;
}

.icon-btn{
  width:40px;
  height:40px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--panel);
  cursor:pointer;
  color:var(--text);
}

.icon-btn:hover{
  transform:translateY(-1px);
}

.pill{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--panel);
}

.avatar{
  width:28px;
  height:28px;
  border-radius:999px;
  background: rgba(59,130,246,.18);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
}

/* ===== CONTENT ===== */

.content{
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:14px;
}

/* ===== CARDS ===== */

.card{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius2);
  box-shadow: var(--shadow);
}

.card-h{
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  gap:10px;
}

.card-h .title{
  font-weight:800;
}

.card-b{
  padding:14px 16px;
}

/* ===== GRID ===== */

.grid{
  display:grid;
  gap:14px;
}

.grid.cols-2{
  grid-template-columns:repeat(2,minmax(0,1fr));
}

.grid.cols-3{
  grid-template-columns:repeat(3,minmax(0,1fr));
}

.grid.cols-4{
  grid-template-columns:repeat(4,minmax(0,1fr));
}

/* ===== KPI ===== */

.kpi{
  padding:14px 16px;
  display:flex;
  gap:12px;
  align-items:flex-start;
}

.kpi .ic{
  width:44px;
  height:44px;
  border-radius:14px;
  background: rgba(59,130,246,.14);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:20px;
  flex:0 0 44px;
}

.kpi .v{
  font-size:22px;
  font-weight:900;
  line-height:1.05;
}

.kpi .l{
  font-size:12px;
  color:var(--muted);
  font-weight:700;
  margin-bottom:4px;
}

/* ===== BUTTONS ===== */

.btn,
button,
input[type="submit"],
input[type="button"]{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-height:42px;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--panel);
  cursor:pointer;
  font-weight:700;
  color:var(--text);
  text-decoration:none;
  box-shadow:none;
}

.btn.primary,
button.primary,
input[type="submit"],
input[type="button"]{
  background:var(--primary);
  color:#fff;
  border-color:transparent;
}

.btn.danger{
  background:#ef4444;
  color:#fff;
  border-color:#ef4444;
}

/* ===== FORMS ===== */

form{
  margin:0;
}

.form{
  display:grid;
  gap:12px;
}

.form .row{
  display:grid;
  gap:12px;
  grid-template-columns: repeat(2, minmax(0,1fr));
}

label{
  display:block;
  font-size:13px;
  font-weight:700;
  margin-bottom:6px;
  color:var(--text);
}

input:not([type="checkbox"]):not([type="radio"]),
.input,
select,
textarea{
  width:100%;
  min-height:42px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--panel);
  color:var(--text);
  outline:none;
  box-shadow:none;
  font:inherit;
}

textarea{
  min-height:100px;
  resize:vertical;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
.input:focus,
select:focus,
textarea:focus{
  border-color: rgba(59,130,246,.45);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

input[type="checkbox"],
input[type="radio"]{
  appearance:auto;
  -webkit-appearance:auto;
  width:18px !important;
  height:18px !important;
  min-width:18px !important;
  min-height:18px !important;
  padding:0 !important;
  margin:0 !important;
  border:none !important;
  background:transparent !important;
  box-shadow:none !important;
  vertical-align:middle;
  cursor:pointer;
  accent-color:var(--primary);
  flex:0 0 auto;
  transform:none !important;
}

input[type="checkbox"]{
  border-radius:4px;
}

input[type="radio"]{
  border-radius:50%;
}

::placeholder{
  color:var(--muted);
  opacity:1;
}

.help{
  font-size:12px;
  color:var(--muted);
  margin-top:6px;
}

/* ===== TABLE ===== */

.table-wrap{
  overflow:auto;
}

table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
}

th,td{
  padding:12px 10px;
  border-bottom:1px solid var(--border);
  text-align:left;
  vertical-align:middle;
}

th{
  font-size:12px;
  color:var(--muted);
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.04em;
}

tr:hover td{
  background: rgba(59,130,246,.05);
}

/* ===== HERO BASE ===== */

.hero{
  padding:26px;
  border-radius:var(--radius2);
  background:
    radial-gradient(1200px 600px at 30% 20%, rgba(59,130,246,.35), transparent 60%),
    radial-gradient(900px 500px at 70% 30%, rgba(168,85,247,.35), transparent 55%),
    radial-gradient(900px 600px at 60% 80%, rgba(14,165,233,.25), transparent 60%),
    linear-gradient(135deg, rgba(15,23,42,.75), rgba(15,23,42,.35));
  border:1px solid var(--border);
  box-shadow: var(--shadow);
  color:#fff;
}

.hero h2{
  margin:0 0 8px;
  font-size:26px;
}

.hero p{
  margin:0 0 14px;
  opacity:.9;
}

.hero .actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

/* ===== BADGES ===== */

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
  border:1px solid var(--border);
  background: rgba(255,255,255,.06);
}

.badge.ok{
  background: rgba(34,197,94,.14);
  border-color: rgba(34,197,94,.22);
  color:#16a34a;
}

.badge.warn{
  background: rgba(245,158,11,.14);
  border-color: rgba(245,158,11,.22);
  color:#f59e0b;
}

.badge.bad{
  background: rgba(239,68,68,.14);
  border-color: rgba(239,68,68,.22);
  color:#ef4444;
}

/* ===== NOTICE ===== */

.notice{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(59,130,246,.08);
}

.notice.ok{
  background: rgba(34,197,94,.12);
}

.notice.err{
  background: rgba(239,68,68,.12);
}

/* ===== AUTH ===== */

.auth-wrap{
  min-height:100vh;
  display:grid;
  grid-template-columns: 1.1fr 1fr;
}

.auth-left{
  background-size:cover;
  background-position:center;
  position:relative;
}

.auth-left::after{
  content:"";
  position:absolute;
  inset:0;
  background: linear-gradient(120deg, rgba(0,0,0,.55), rgba(0,0,0,.25));
}

.auth-right{
  display:flex;
  align-items:center;
  justify-content:center;
  padding:26px;
}

.auth-card{
  width:min(440px, 100%);
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:18px;
  padding:22px;
  box-shadow: var(--shadow);
}

.auth-card h1{
  margin:0 0 6px;
}

.auth-card .sub{
  color:var(--muted);
  margin-bottom:16px;
}

/* ===== FOOTER ===== */

.footer{
  padding:18px;
  color:var(--muted);
  font-size:12px;
  text-align:center;
}

/* ===== DASHBOARD HERO FINAL ===== */

.dashhero{
  padding:22px;
  border-radius:var(--radius2);
  background:
    radial-gradient(1200px 600px at 30% 20%, rgba(59,130,246,.35), transparent 60%),
    radial-gradient(900px 500px at 70% 30%, rgba(168,85,247,.35), transparent 55%),
    radial-gradient(900px 600px at 60% 80%, rgba(14,165,233,.25), transparent 60%),
    linear-gradient(135deg, rgba(15,23,42,.78), rgba(15,23,42,.38));
  color:#fff;
  display:grid;
  grid-template-columns:minmax(0, 1.2fr) minmax(320px, .8fr);
  gap:18px;
  align-items:center;
}

.dashhero__eyebrow{
  font-size:12px;
  font-weight:900;
  letter-spacing:.12em;
  text-transform:uppercase;
  opacity:.92;
  margin-bottom:8px;
}

.dashhero__title{
  margin:0 0 8px;
  font-size:28px;
  line-height:1.1;
  letter-spacing:-.02em;
}

.dashhero__desc{
  margin:0 0 16px;
  max-width:720px;
  font-size:15px;
  line-height:1.45;
  opacity:.93;
}

.dashhero__actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.dashhero__btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-height:42px;
  padding:10px 14px;
  border-radius:14px;
  color:#fff;
  font-weight:800;
  line-height:1;
  border:1px solid rgba(255,255,255,.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

.dashhero__btn:hover{
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.dashhero__btn--blue{
  background: linear-gradient(180deg, rgba(59,130,246,.95), rgba(37,99,235,.92));
}

.dashhero__btn--purple{
  background: linear-gradient(180deg, rgba(168,85,247,.92), rgba(147,51,234,.88));
}

.dashhero__btn--cyan{
  background: linear-gradient(180deg, rgba(14,165,233,.92), rgba(8,145,178,.88));
}

.dashhero__btn--green{
  background: linear-gradient(180deg, rgba(34,197,94,.92), rgba(22,163,74,.88));
}

.dashhero__metrics{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}

.dashhero__metric{
  min-height:84px;
  padding:12px 14px;
  border-radius:16px;
  background: rgba(255,255,255,.10);
  border:1px solid rgba(255,255,255,.15);
  backdrop-filter: blur(8px);
}

.dashhero__metric-label{
  font-size:12px;
  font-weight:800;
  letter-spacing:.02em;
  opacity:.86;
  color:#fff;
}

.dashhero__metric-value{
  margin-top:6px;
  font-size:20px;
  font-weight:900;
  line-height:1.1;
  letter-spacing:-.01em;
  color:#fff;
}

/* ===== MOBILE ===== */

@media (max-width: 980px){
  .dashhero{
    grid-template-columns:1fr;
  }

  .grid.cols-4{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .grid.cols-3{
    grid-template-columns:1fr;
  }

  .grid.cols-2{
    grid-template-columns:1fr;
  }

  .form .row{
    grid-template-columns:1fr;
  }

  .sidebar{
    position:fixed;
    left:-290px;
    transition:.2s;
    z-index:99;
  }

  .sidebar.open{
    left:0;
  }

  .auth-wrap{
    grid-template-columns:1fr;
  }
}

@media (max-width: 560px){
  .dashhero{
    padding:18px;
  }

  .dashhero__title{
    font-size:24px;
  }

  .dashhero__metrics{
    grid-template-columns:1fr;
  }

  .dashhero__actions{
    flex-direction:column;
  }

  .dashhero__btn{
    width:100%;
  }

  .content{
    padding:14px;
  }
}