:root{
  --bg:#f4f7fb;
  --panel:#ffffff;
  --panel-2:#eef3f9;
  --text:#0f172a;
  --muted:#64748b;
  --line:rgba(15,23,42,.08);
  --primary:#0f766e;
  --primary-2:#14b8a6;
  --accent:#22c55e;
  --danger:#dc2626;
  --warn:#f59e0b;
  --shadow:0 12px 30px rgba(15,23,42,.10);
  --sidebar:#ffffff;
  --hero:linear-gradient(135deg, rgba(15,118,110,.18), rgba(20,184,166,.18));
}

html[data-theme="dark"]{
  --bg:#08111f;
  --panel:#0f172a;
  --panel-2:#111c31;
  --text:#eaf2ff;
  --muted:#93a4c7;
  --line:rgba(255,255,255,.08);
  --primary:#2dd4bf;
  --primary-2:#14b8a6;
  --accent:#4ade80;
  --danger:#f87171;
  --warn:#fbbf24;
  --shadow:0 12px 30px rgba(0,0,0,.30);
  --sidebar:#0b1323;
  --hero:linear-gradient(135deg, rgba(45,212,191,.18), rgba(20,184,166,.18));
}

*{box-sizing:border-box}

html,body{
  min-height:100%;
}

body{
  margin:0;
  font-family:Arial, Helvetica, sans-serif;
  background:var(--bg);
  color:var(--text);
  transition:background .25s ease,color .25s ease;
}

a{color:inherit}

.layout{
  display:grid;
  grid-template-columns:280px 1fr;
  min-height:100vh;
}

.sidebar{
  background:var(--sidebar);
  border-right:1px solid var(--line);
  padding:22px 18px;
  display:flex;
  flex-direction:column;
  gap:18px;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
}

.brand img{
  width:78px;
  height:78px;
  object-fit:contain;
  border-radius:16px;
  padding:6px;
  background:rgba(255,255,255,.06);
}

.brand h1{
  margin:0;
  font-size:22px;
}

.brand p{
  margin:4px 0 0;
  color:var(--muted);
  font-size:13px;
}

.sidebar-user{
  display:flex;
  flex-direction:column;
  gap:6px;
  padding:14px;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:16px;
  box-shadow:var(--shadow);
}

.sidebar-user strong{
  font-size:15px;
}

.sidebar-user span{
  color:var(--muted);
  font-size:13px;
  line-height:1.4;
}

.menu{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.menu a,
.menu span{
  text-decoration:none;
  color:var(--text);
  padding:12px 14px;
  border-radius:14px;
  border:1px solid transparent;
  background:transparent;
  transition:.2s ease;
  display:block;
}

.menu a:hover{
  background:var(--panel-2);
  border-color:var(--line);
}

.menu .active{
  background:var(--panel-2);
  border-color:var(--line);
  box-shadow:var(--shadow);
}

.menu .disabled{
  color:var(--muted);
  opacity:.72;
  cursor:not-allowed;
}

.sidebar-footer{
  margin-top:auto;
}

.main{
  display:flex;
  flex-direction:column;
  min-width:0;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:18px 24px;
  border-bottom:1px solid var(--line);
  background:var(--panel);
  position:sticky;
  top:0;
  z-index:5;
}

.topbar-left h2{
  margin:0;
  font-size:24px;
}

.topbar-left p{
  margin:4px 0 0;
  color:var(--muted);
  font-size:14px;
  line-height:1.45;
}

.topbar-actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.content{
  padding:24px;
  display:grid;
  gap:24px;
}

.hero{
  background:var(--hero);
  border:1px solid var(--line);
  border-radius:22px;
  padding:24px;
  box-shadow:var(--shadow);
}

.hero h3{
  margin:0 0 8px;
  font-size:28px;
}

.hero p{
  margin:0;
  color:var(--muted);
  max-width:880px;
  line-height:1.6;
}

.panel{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:var(--shadow);
}

.dashboard-kpis{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
  gap:16px;
  padding:18px;
}

.tile{
  background:var(--panel-2);
  border:1px solid var(--line);
  border-radius:16px;
  padding:18px;
}

.tile-title{
  color:var(--muted);
  font-size:13px;
  margin-bottom:8px;
}

.tile-value{
  font-size:30px;
  font-weight:700;
}

.section-card,
.card,
.data-card{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:18px;
  padding:20px;
  box-shadow:var(--shadow);
}

.section-title{
  margin:0 0 8px;
  font-size:22px;
}

.section-subtitle{
  margin:0;
  color:var(--muted);
  line-height:1.5;
}

.module-grid,
.data-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(240px,1fr));
  gap:16px;
}

.module-card{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:18px;
  padding:18px;
  box-shadow:var(--shadow);
}

.module-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}

.module-title{
  display:flex;
  gap:10px;
  align-items:center;
}

.module-title h3{
  margin:0;
  font-size:18px;
}

.module-icon{
  font-size:22px;
  line-height:1;
}

.module-card p{
  margin:0 0 14px;
  color:var(--muted);
  font-size:14px;
  line-height:1.5;
}

.timeline-lite{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(220px,1fr));
  gap:16px;
  margin-top:18px;
}

.timeline-item{
  padding:16px;
  border-radius:16px;
  border:1px solid var(--line);
  background:var(--panel-2);
  display:flex;
  flex-direction:column;
  gap:8px;
}

.timeline-item strong{
  font-size:15px;
}

.timeline-item span{
  color:var(--muted);
  line-height:1.5;
  font-size:14px;
}

.btn{
  border:none;
  border-radius:12px;
  padding:10px 14px;
  cursor:pointer;
  font-weight:600;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
}

.btn-theme,
.btn-secondary,
.ghost,
.module-btn,
.small-btn{
  background:var(--panel-2);
  color:var(--text);
  border:1px solid var(--line);
}

.btn-primary{
  background:linear-gradient(135deg,var(--primary),var(--primary-2));
  color:#fff;
}

.btn:disabled,
.ghost:disabled{
  opacity:.65;
  cursor:not-allowed;
}

.alert{
  padding:14px 16px;
  border-radius:14px;
  border:1px solid var(--line);
  box-shadow:var(--shadow);
}

.alert.ok{
  background:rgba(34,197,94,.12);
  border-color:rgba(34,197,94,.24);
}

.alert.err{
  background:rgba(220,38,38,.12);
  border-color:rgba(220,38,38,.24);
}

.alert.warn{
  background:rgba(245,158,11,.12);
  border-color:rgba(245,158,11,.24);
}

.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:6px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
  border:1px solid var(--line);
  background:var(--panel-2);
}

.badge.ok{
  color:var(--accent);
}

.badge.err{
  color:var(--danger);
}

.badge.warn{
  color:var(--warn);
}

.badge.muted{
  color:var(--muted);
}

.status-list{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.login-layout{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
}

.login-shell{
  width:min(1080px,100%);
  display:grid;
  gap:24px;
}

.login-grid{
  display:grid;
  grid-template-columns:1.1fr .9fr;
  gap:18px;
}

.login-card{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:18px;
  padding:24px;
  box-shadow:var(--shadow);
}

.login-brand{
  text-align:center;
  padding:28px 24px;
}

.login-brand img{
  width:104px;
  height:104px;
  object-fit:contain;
  margin-bottom:14px;
  border-radius:20px;
  padding:10px;
  background:rgba(255,255,255,.06);
}

.title-main{
  margin:0;
  font-size:30px;
}

.subtitle{
  margin:8px 0 0;
  color:var(--muted);
  line-height:1.55;
}

.form{
  display:grid;
  gap:12px;
  margin-top:18px;
}

.form.grid{
  grid-template-columns:repeat(2,minmax(0,1fr));
}

.form label{
  font-size:14px;
  font-weight:600;
  display:block;
  margin-bottom:6px;
}

.form input,
.form select,
.form textarea{
  width:100%;
  padding:12px 14px;
  border-radius:12px;
  border:1px solid var(--line);
  background:var(--panel-2);
  color:var(--text);
  outline:none;
  font:inherit;
}

.form textarea{
  resize:vertical;
  min-height:100px;
}

.form .full{
  grid-column:1 / -1;
}

.empty-state{
  display:grid;
  gap:10px;
  margin-top:18px;
  padding:16px;
  border-radius:16px;
  background:var(--panel-2);
  border:1px solid var(--line);
}

.empty-state.compact{
  margin-top:12px;
}

.empty-state span{
  color:var(--muted);
  line-height:1.5;
}

.table-wrap{
  margin-top:18px;
  overflow:auto;
}

.table{
  width:100%;
  border-collapse:collapse;
}

.table th,
.table td{
  padding:12px 10px;
  border-bottom:1px solid var(--line);
  text-align:left;
  vertical-align:top;
}

.table th{
  color:var(--muted);
  font-size:13px;
  font-weight:700;
}

.table-muted{
  color:var(--muted);
  font-size:12px;
}

.inline-form{
  margin:0;
}

.small-btn{
  padding:8px 10px;
  font-size:13px;
}

.stack{
  display:grid;
  gap:24px;
}

.checkbox-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
  gap:10px;
  margin-top:8px;
}

.checkbox-item{
  display:flex;
  align-items:flex-start;
  gap:10px;
  padding:12px 14px;
  border:1px solid var(--line);
  border-radius:14px;
  background:var(--panel-2);
}

.checkbox-item input{
  width:auto;
  margin-top:2px;
}

.checkbox-item span{
  display:block;
  color:var(--muted);
  font-size:13px;
  line-height:1.4;
}

.inline-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.pill-list{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.pill{
  display:inline-flex;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  background:var(--panel-2);
  border:1px solid var(--line);
  font-size:12px;
  font-weight:700;
}

code{
  font-family:Consolas, monospace;
  background:rgba(127,127,127,.14);
  padding:2px 6px;
  border-radius:8px;
}

@media (max-width: 960px){
  .layout,
  .login-grid,
  .form.grid,
  .module-grid,
  .data-grid{
    grid-template-columns:1fr;
  }

  .sidebar{
    border-right:none;
    border-bottom:1px solid var(--line);
  }

  .topbar{
    align-items:flex-start;
    flex-direction:column;
  }
}
