:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --border:#e6e8ef;
  --text:#0f172a;
  --muted:#64748b;
  --primary:#2563eb;
  --success:#16a34a;
  --danger:#dc2626;
  --warning:#d97706;
  --radius:14px;
}

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

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

img{max-width:100%; height:auto; display:block;}
a{color:var(--primary); text-decoration:none}
a:hover{text-decoration:underline}

/* Focus ring (accessibility + consistency) */
:focus-visible{
  outline:3px solid rgba(37, 99, 235, .25);
  outline-offset:2px;
  border-radius:12px;
}

/* =========================================================
   Layout
========================================================= */
.admin{
  display:grid;
  grid-template-columns:260px 1fr;
  min-height:100vh;
}

/* =========================================================
   Sidebar (desktop)
========================================================= */
.sidebar{
  background:var(--card);
  border-right:1px solid var(--border);
  padding:18px;
  position:sticky;
  top:0;
  height:100vh;
  overflow:auto;
}

.brand{
  display:flex;
  gap:10px;
  align-items:center;
  margin-bottom:18px;
}
.brand img{height:34px; width:auto; max-width:180px;}
.brand .title{font-weight:800; letter-spacing:.2px}

.nav{display:flex; flex-direction:column; gap:4px;}
.nav a{
  display:flex;
  gap:10px;
  align-items:center;
  padding:10px 12px;
  border-radius:12px;
  color:var(--text);
  opacity:.92;
  border:1px solid transparent;
}
.nav a:hover{background:#f2f5ff; border-color:#e9eeff}
.nav a.active{background:#eef2ff; border-color:#dbe3ff; color:#1d4ed8;}

/* =========================================================
   Main + Sticky Footer base
========================================================= */
.main{
  padding:18px 20px 26px;
  min-width:0;

  /* sticky footer */
  display:flex;
  flex-direction:column;
  min-height:100vh;
}

.main-content{ flex:1 1 auto; min-height:0; }

/* =========================================================
   Topbar
========================================================= */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:16px;
}

.topbar-left{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:160px;
}
.topbar h2{margin:0; font-size:22px}

.right-actions{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:flex-end;
  flex:1;
  min-width:0;
}

/* Search */
.search{flex:1; min-width:140px; max-width:520px;}
.search input{
  width:100%;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px 12px;
  color:var(--text);
  outline:none;
}
.search input:disabled{
  opacity:.7;
  cursor:not-allowed;
}

/* User chip */
.user-chip{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:12px;
  white-space:nowrap;
  min-width:0;
}
.user-dot{
  width:28px; height:28px;
  border-radius:10px;
  background:#eef2ff;
  border:1px solid #dbe3ff;
  flex:0 0 auto;
}
.welcome-text{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:180px;
  color:var(--muted);
  font-size:13px;
}

/* =========================================================
   Buttons / Inputs
========================================================= */
button,input,select,textarea{font:inherit}

/* ✅ Base button style (fix native buttons everywhere) */
button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--card);
  color:var(--text);
  cursor:pointer;
  line-height:1.1;
}
button:hover{background:#fafbff}
button:disabled,
button[disabled]{
  opacity:.6;
  cursor:not-allowed;
  transform:none;
}

/* Links that look like buttons (optional helper) */
.btn-like{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--card);
  color:var(--text);
  text-decoration:none;
}
.btn-like:hover{background:#fafbff; text-decoration:none;}

/* Ghost */
.btn-ghost{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:9px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--card);
  color:var(--text);
  cursor:pointer;
}
.btn-ghost:hover{background:#fafbff}

/* Primary button (optional) */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid transparent;
  background:var(--primary);
  color:#fff;
  font-weight:800;
  cursor:pointer;
}
.btn:hover{filter:brightness(1.05)}
.btn:disabled{opacity:.6; cursor:not-allowed; filter:none;}

/* Mobile toggle button (hamburger) */
.menu-toggle{
  display:none;
  width:40px;
  height:40px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--card);
  cursor:pointer;
  align-items:center;
  justify-content:center;
  padding:0;
}
.menu-toggle span{
  display:block;
  width:18px;
  height:2px;
  background:var(--text);
  position:relative;
}
.menu-toggle span:before,
.menu-toggle span:after{
  content:"";
  position:absolute;
  left:0;
  width:18px;
  height:2px;
  background:var(--text);
}
.menu-toggle span:before{top:-6px;}
.menu-toggle span:after{top:6px;}

/* =========================================================
   Cards
========================================================= */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:14px;
  box-shadow:0 10px 24px rgba(15, 23, 42, .06);
}

.card-title{margin:0 0 10px;}

@media (hover:hover){
  .card{transition:0.2s ease;}
  .card:hover{
    transform:translateY(-3px);
    box-shadow:0 14px 30px rgba(0,0,0,.08);
  }
}

/* KPI grid */
.grid-3,
.kpi-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:12px;
}

.kpi{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
}
.kpi .label{color:var(--muted); font-size:13px}
.kpi .value{font-size:28px; font-weight:900; margin-top:6px}
.kpi .sub{color:var(--muted); font-size:12px; margin-top:4px}

/* Clickable card wrapper */
.card-link{
  display:block;
  color:inherit;
  text-decoration:none;
}
.card-link:hover{text-decoration:none}

/* =========================================================
   Badges
========================================================= */
.badge{
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  color:var(--muted);
  background:#fff;
  white-space:nowrap;
}
.badge.success{color:var(--success); border-color:rgba(22,163,74,.25); background:rgba(22,163,74,.06)}
.badge.danger{color:var(--danger); border-color:rgba(220,38,38,.25); background:rgba(220,38,38,.06)}
.badge.warn{color:var(--warning); border-color:rgba(217,119,6,.25); background:rgba(217,119,6,.06)}

/* =========================================================
   Tables
========================================================= */
.table-wrap{overflow:auto; -webkit-overflow-scrolling:touch;}
.table{width:100%; border-collapse:separate; border-spacing:0;}
.table th, .table td{
  padding:10px 10px;
  border-bottom:1px solid var(--border);
  text-align:left;
  font-size:14px;
  vertical-align:top;
}
.table th{
  color:var(--muted);
  font-weight:700;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.06em;
}
.table tr:hover td{background:#fafbff}

/* =========================================================
   Forms (generic)
========================================================= */
.field-label{
  color:var(--muted);
  font-size:13px;
  margin-bottom:6px;
}

input,select,textarea{
  background:var(--card);
  border:1px solid var(--border);
  color:var(--text);
  border-radius:12px;
  padding:10px 12px;
  outline:none;
}
textarea{resize:vertical; min-height:92px; width:100%;}

hr{border:0; border-top:1px solid var(--border); margin:16px 0}

/* =========================================================
   Overlay for mobile sidebar
========================================================= */
.sidebar-overlay{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.25);
  z-index:900;
}
.sidebar-overlay.show{display:block;}

/* =========================================================
   Footer
========================================================= */
.footer-bar{
  margin-top:auto;
  padding:14px 0;
  text-align:center;
  font-size:13px;
  color:var(--muted);
  border-top:1px solid var(--border);
}

/* =========================================================
   Auth (Login)
========================================================= */
.auth-page{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px;
}

.auth-card{
  width:100%;
  max-width:420px;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:0 14px 30px rgba(0,0,0,.08);
  padding:18px;
}

.auth-brand{
  display:flex;
  gap:12px;
  align-items:center;
  margin-bottom:14px;
}

.auth-brand img{
  height:44px;
  width:auto;
  max-width:160px;
  object-fit:contain;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
  padding:6px;
}

.auth-title{ font-weight:900; font-size:18px; }
.auth-sub{ color:var(--muted); font-size:13px; margin-top:2px; }

.auth-alert{
  border:1px solid rgba(220,38,38,.25);
  background:rgba(220,38,38,.06);
  color:var(--text);
  border-radius:12px;
  padding:10px 12px;
  margin:10px 0 12px;
}

.auth-form{
  display:grid;
  gap:10px;
}

.auth-label{ color:var(--muted); font-size:13px; }

.auth-input{
  width:100%;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px 12px;
  color:var(--text);
  outline:none;
}

.auth-btn{
  margin-top:8px;
  width:100%;
  border:1px solid #dbe3ff;
  background:#eef2ff;
  color:#1d4ed8;
  border-radius:12px;
  padding:10px 12px;
  font-weight:800;
  cursor:pointer;
}
.auth-btn:hover{filter:brightness(1.02)}

.auth-footer{
  margin-top:14px;
  text-align:center;
  font-size:13px;
  color:var(--muted);
}

/* =========================================================
   Responsive (ONE media block)
========================================================= */
@media (max-width: 980px){
  .admin{grid-template-columns:1fr;}
  .main{padding:14px;}

  /* sidebar off-canvas */
  .menu-toggle{display:inline-flex;}
  .sidebar{
    position:fixed;
    left:-270px;
    top:0;
    width:260px;
    height:100vh;
    z-index:1000;
    transition:0.25s ease;
    box-shadow:0 0 20px rgba(0,0,0,0.1);
    border-right:1px solid var(--border);
  }
  .sidebar.open{left:0;}

  /* topbar becomes 2 rows */
  .topbar{
    flex-direction:column;
    align-items:stretch;
    gap:10px;
  }
  .topbar-left{
    width:100%;
    justify-content:flex-start;
  }
  .right-actions{
    width:100%;
    flex-wrap:wrap;
    justify-content:space-between;
    gap:8px;
  }
  .search{
    order:3;
    width:100%;
    max-width:100%;
    flex: 1 1 100%;
  }
  .user-chip{
    order:2;
    flex: 1 1 auto;
    min-width:0;
  }
  .btn-ghost{
    order:1;
    flex: 0 0 auto;
  }

  .welcome-text{display:none;}
}