:root{
  --bg: #070708;
  --panel: #0c0c0e;
  --text: #f3f4f6;
  --muted: #a1a1aa;
  --gold: #b68d2c;
  --line: rgba(182,141,44,0.35);
  --shadow: 0 10px 30px rgba(0,0,0,0.35);

  --input-bg: #f3f4f6;
  --input-text: #111827;
  --input-border: #d1d5db;
  --input-placeholder: #6b7280;

  --sidebar-bg: #050506;
  --sidebar-text: #f3f4f6;
  --sidebar-muted: rgba(243,244,246,0.70);
  --sidebar-hover: rgba(182,141,44,0.12);
  --sidebar-active: rgba(182,141,44,0.18);

  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --info: #b68d2c;
}

*{ box-sizing: border-box; }

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

a{ color: var(--info); text-decoration: none; }
a:hover{ text-decoration: underline; }

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

.sidebar{
  width: 270px;
  padding: 18px 16px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--line);
}

.brand{
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--sidebar-text);
  text-decoration: none;
}
.brand:hover{ text-decoration: none; }
.brand-logo{
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
}
.brand-text{ min-width: 0; }
.brand-title{
  font-weight: 900;
  letter-spacing: 1px;
  font-size: 18px;
}
.brand-sub{
  margin-top: 2px;
  font-size: 12px;
  color: var(--sidebar-muted);
}

.nav{ display: flex; flex-direction: column; gap: 6px; }
.nav-section{
  margin-top: 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--sidebar-muted);
}
.nav-item{
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  display: block;
  border: 1px solid transparent;
}
.nav-item:hover{ background: var(--sidebar-hover); }
.nav-item.active{
  background: var(--sidebar-active);
  border-color: rgba(182,141,44,0.35);
}

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

.topbar{
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar-left{ font-weight: 800; }
.topbar-right{ color: var(--muted); font-size: 13px; }

.main-inner{
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
}

.card{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.card.focus{
  border-color: rgba(248,113,113,0.55);
  box-shadow: 0 0 0 2px rgba(248,113,113,0.15), var(--shadow);
}

.card-title{
  font-weight: 900;
  margin: 0 0 10px 0;
  font-size: 14px;
  letter-spacing: 0.3px;
}

.card-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-head .card-title{ margin-bottom: 0; }

.grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.kpi{
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.kpi.focus{
  border-color: rgba(248,113,113,0.55);
  box-shadow: 0 0 0 2px rgba(248,113,113,0.15), var(--shadow);
}
.kpi .label{ color: var(--muted); font-size: 12px; }
.kpi .value{ font-weight: 900; font-size: 18px; }

.table{
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td{
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
.table th{
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.pill{
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text);
  background: rgba(255,255,255,0.03);
}
.pill.ok{ border-color: rgba(52,211,153,0.35); background: rgba(52,211,153,0.10); color: var(--ok); }
.pill.warn{ border-color: rgba(251,191,36,0.35); background: rgba(251,191,36,0.10); color: var(--warn); }
.pill.err{ border-color: rgba(248,113,113,0.35); background: rgba(248,113,113,0.10); color: var(--err); }

.flash-stack{ display: grid; gap: 8px; }
.flash{
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--info);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.flash.ok{ border-left-color: var(--ok); }
.flash.success{ border-left-color: var(--ok); }
.flash.error{ border-left-color: var(--err); }
.flash.warning{ border-left-color: var(--warn); }

.form-row{
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.field{
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
  flex: 1 1 260px;
}
.field label{
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.field input, .field select, .field textarea{
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--input-text);
  font-size: 14px;
}
.field input::placeholder, .field textarea::placeholder{ color: var(--input-placeholder); }
.field input:focus, .field select:focus, .field textarea:focus{
  outline: 2px solid rgba(182,141,44,0.35);
  outline-offset: 1px;
}
.field textarea{ min-height: 92px; }

.actions{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
  box-shadow: var(--shadow);
}
.btn:hover{ filter: brightness(1.05); }
.btn.icon{
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1;
}
.btn.primary{
  background: rgba(182,141,44,0.95);
  color: #0b0b0c;
  border-color: rgba(182,141,44,0.85);
}
.btn.danger{
  background: rgba(153,27,27,0.08);
  color: var(--err);
  border-color: rgba(153,27,27,0.25);
}

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

@keyframes alarmPulse{
  0%, 100%{
    box-shadow: 0 0 0 2px rgba(248,113,113,0.18), var(--shadow);
    border-color: rgba(248,113,113,0.55);
    background: linear-gradient(180deg, rgba(248,113,113,0.10), var(--panel) 60%);
  }
  50%{
    box-shadow: 0 0 0 2px rgba(251,191,36,0.20), var(--shadow);
    border-color: rgba(251,191,36,0.55);
    background: linear-gradient(180deg, rgba(251,191,36,0.12), var(--panel) 60%);
  }
}
.card.alarm{
  animation: alarmPulse 1.15s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce){
  .card.alarm{ animation: none; }
}

.page-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 1100px){
  .page-grid.two{
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
  }
}

.stack{
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Auth pages */
.no-sidebar .sidebar{ display:none; }
.no-sidebar .topbar{ display:none; }
.no-sidebar .main{ width: 100%; }
.no-sidebar .main-inner{ max-width: 520px; padding-top: 48px; }
