/* =======================
   NEXT LEVEL WHITE UI (ERP)
   ======================= */

:root{
  --bg:#f6f7fb;
  --panel:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e8edf5;

  --primary:#2563eb;
  --primary2:#7c3aed;
  --success:#16a34a;
  --danger:#ef4444;
  --warning:#f59e0b;
  --info:#06b6d4;

  --radius:16px;
  --shadow: 0 10px 30px rgba(15,23,42,.08);
  --shadow2: 0 6px 18px rgba(15,23,42,.08);
}

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

/* ===== Topbar ===== */
.topbar{
  position: sticky;
  top:0;
  z-index:50;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom:1px solid var(--border);
  box-shadow: 0 2px 14px rgba(15,23,42,.05);
}

.topbar-inner{
  max-width: 1250px;
  margin: 0 auto;
  padding: 14px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
}

.logo{
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.75), transparent 45%),
    linear-gradient(135deg, var(--primary), var(--primary2));
  box-shadow: 0 12px 22px rgba(37,99,235,.25);
}

.brand-title{
  font-weight: 900;
  letter-spacing: .2px;
  line-height: 1.1;
}
.brand-sub{
  font-size: 12px;
  color: var(--muted);
}

/* ===== Nav ===== */
.nav{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.nav a{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 10px 12px;
  border-radius: 12px;
  color: #111827;
  text-decoration:none;
  border: 1px solid transparent;
  transition: background .15s, transform .12s, border .15s;
  font-weight: 700;
  font-size: 13px;
}

.nav a:hover{
  background: #f1f5ff;
  border-color: #dbe7ff;
  transform: translateY(-1px);
}

.nav a.active{
  background: linear-gradient(135deg, rgba(37,99,235,.12), rgba(124,58,237,.10));
  border-color: rgba(37,99,235,.20);
  color: #1d4ed8;
}

.pill{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #f8fafc;
  border:1px solid var(--border);
}
.avatar{
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.7), transparent 45%),
    linear-gradient(135deg, #22c55e, #06b6d4);
}
.pill .name{
  font-weight: 800;
  font-size: 13px;
}
.pill .links a{
  padding: 6px 10px;
  font-weight: 700;
  font-size: 12px;
  border-radius: 999px;
  background: #ffffff;
  border:1px solid var(--border);
  color:#111827;
}
.pill .links a:hover{
  background:#f1f5ff;
  border-color:#dbe7ff;
}

/* ===== Mobile menu button ===== */
.burger{
  display:none;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background:#fff;
  cursor:pointer;
  font-size: 18px;
}
.burger:active{ transform: translateY(1px); }

/* ===== Container ===== */
.container{
  max-width: 1250px;
  margin: 20px auto;
  padding: 0 18px 30px;
}

/* ===== Page Header ===== */
.page-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  margin: 18px 0 14px;
}
.page-title{
  font-size: 20px;
  font-weight: 900;
}
.page-sub{
  margin-top: 3px;
  font-size: 13px;
  color: var(--muted);
}

/* ===== Cards ===== */
.card{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow2);
  margin-bottom: 16px;
}

.card-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom: 12px;
}
.card-title{
  font-weight: 900;
}
.card-actions{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

/* ===== KPI tiles ===== */
.kpis{
  display:grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.kpi{
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow2);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.kpi:before{
  content:"";
  position:absolute;
  inset:-40px -80px auto auto;
  width: 200px;
  height: 200px;
  border-radius: 999px;
  filter: blur(0px);
  opacity:.15;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
}

.kpi .label{
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.kpi .value{
  font-size: 28px;
  font-weight: 1000;
  margin-top: 8px;
}
.kpi .hint{
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.kpi.blue:before{ background: linear-gradient(135deg,#2563eb,#60a5fa); }
.kpi.green:before{ background: linear-gradient(135deg,#16a34a,#86efac); }
.kpi.orange:before{ background: linear-gradient(135deg,#f59e0b,#fde68a); }
.kpi.purple:before{ background: linear-gradient(135deg,#7c3aed,#c4b5fd); }

/* ===== Grid helpers ===== */
.row{ display:flex; gap:14px; flex-wrap:wrap; }
.col{ flex:1; min-width: 240px; }

/* ===== Forms ===== */
label{
  display:block;
  margin: 10px 0 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: .02em;
}

input, select, textarea{
  width: 100%;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fbfcff;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border .15s, box-shadow .15s, background .15s;
}

input:focus, select:focus, textarea:focus{
  border-color: rgba(37,99,235,.45);
  box-shadow: 0 0 0 4px rgba(37,99,235,.14);
  background: #fff;
}

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

/* ===== Buttons ===== */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: #111827;
  font-weight: 900;
  font-size: 13px;
  cursor:pointer;
  transition: transform .08s, box-shadow .15s, background .15s, border .15s;
  user-select:none;
}
.btn:hover{
  background:#f7faff;
  border-color:#dbe7ff;
  box-shadow: 0 10px 22px rgba(37,99,235,.08);
}
.btn:active{ transform: translateY(1px); }

.btn-primary{
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  border-color: rgba(37,99,235,.25);
  color:#fff;
  box-shadow: 0 14px 28px rgba(37,99,235,.18);
}
.btn-primary:hover{
  box-shadow: 0 18px 34px rgba(37,99,235,.25);
}

.btn-success{
  background: linear-gradient(135deg, #16a34a, #22c55e);
  border-color: rgba(22,163,74,.25);
  color:#fff;
}
.btn-danger{
  background: linear-gradient(135deg, #ef4444, #fb7185);
  border-color: rgba(239,68,68,.25);
  color:#fff;
}
.btn-ghost{
  background: #fff;
}

/* ===== Table ===== */
.tablewrap{
  background:#fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow2);
  overflow:auto;
}

table{
  width:100%;
  border-collapse: collapse;
  min-width: 900px;
}

th, td{
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  text-align:left;
  white-space: nowrap;
}

th{
  background:#f7f9ff;
  color:#334155;
  font-weight: 1000;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr:hover td{
  background:#fbfdff;
}

.actions a{
  color:#1d4ed8;
  font-weight: 900;
  margin-right: 10px;
}
.actions a:hover{ text-decoration: underline; }

/* ===== Badges ===== */
.badge{
  display:inline-flex;
  align-items:center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 1000;
  border: 1px solid var(--border);
  background:#fff;
}
.badge.ok{ background:#ecfdf5; border-color:#bbf7d0; color:#166534; }
.badge.no{ background:#fff1f2; border-color:#fecdd3; color:#9f1239; }
.badge.warn{ background:#fffbeb; border-color:#fde68a; color:#92400e; }
.badge.info{ background:#ecfeff; border-color:#a5f3fc; color:#0e7490; }

/* ===== Flash ===== */
.flash{
  background:#ecfeff;
  border: 1px solid #a5f3fc;
  border-left: 6px solid #06b6d4;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  color:#0e7490;
  font-weight: 800;
}

/* ===== Login ===== */
.auth{
  min-height: calc(100vh - 1px);
  display:grid;
  place-items:center;
  padding: 26px;
}
.auth-card{
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.auth-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 14px;
}
.auth-title{
  font-weight: 1000;
  font-size: 18px;
}
.auth-sub{
  font-size: 12px;
  color: var(--muted);
}
.auth-badge{
  padding: 8px 10px;
  border-radius: 999px;
  font-weight: 1000;
  font-size: 12px;
  background: linear-gradient(135deg, rgba(37,99,235,.12), rgba(124,58,237,.10));
  border:1px solid rgba(37,99,235,.18);
  color:#1d4ed8;
}

/* ===== Responsive ===== */
@media (max-width: 980px){
  .kpis{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 820px){
  .burger{ display:inline-flex; align-items:center; justify-content:center; }
  .nav{
    display:none;
    width:100%;
    padding-top: 10px;
  }
  .nav.open{ display:flex; }
  .topbar-inner{ flex-wrap:wrap; }
  table{ min-width: 780px; }
}

@media (max-width: 520px){
  .kpis{ grid-template-columns: 1fr; }
  table{ min-width: 680px; }
}
