:root{
  --bg:#f7f9fc; --sidebar:#0f172a; --sidebar-hover:#1e293b; --text:#111827;
  --muted:#6b7280; --card:#fff; --border:#e5e7eb; --primary:#2563eb; --primary-600:#1d4ed8;
}

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

/* ================== Layout ================== */
.layout{
  display:grid;
  grid-template-columns:240px 1fr;
  min-height:100dvh;
}
.sidebar{
  background:var(--sidebar); color:#fff; padding:16px;
  display:flex; flex-direction:column; gap:14px;
}
.sidebar .brand{display:flex;align-items:center;gap:10px;font-weight:700}
.sidebar .brand img{height:28px;filter:brightness(1.3)}
.sidebar nav{display:grid;gap:6px}
.sidebar nav a{color:#e5e7eb;text-decoration:none;padding:10px 12px;border-radius:10px}
.sidebar nav a:hover{background:var(--sidebar-hover)}
.sidebar nav a.active{background:#172554;color:#fff}

.content{
  padding:22px 20px;
  max-width:1200px; width:100%; margin:0 auto;
}

/* ===== Responsive layout: Sidebar collapses to top bar ===== */
@media (max-width: 900px){
  .layout{ grid-template-columns:1fr; }
  .sidebar{
    position:sticky; top:0; z-index:50;
    padding:10px 12px;
    flex-direction:row; align-items:center; gap:12px;
  }
  .sidebar .brand{margin-right:auto}
  .sidebar nav{
    display:flex; gap:6px; overflow:auto; padding-bottom:2px;
  }
  .sidebar nav a{white-space:nowrap}
}

/* ================== Common UI ================== */
.page-header{
  display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px;
}
.page-header h1{margin:0;font-size:24px}
.page-header .actions{display:flex;gap:10px;flex-wrap:wrap}

.btn{
  display:inline-block; padding:10px 14px; border-radius:10px;
  text-decoration:none; border:1px solid var(--border);
  color:var(--text); background:#fff; font-weight:600;
}
.btn:hover{background:#f8fafc}
.btn-primary{background:var(--primary);border-color:var(--primary);color:#fff}
.btn-primary:hover{background:var(--primary-600)}
.btn-small{ padding:6px 10px; font-size:12px; border-radius:8px; }

.card{
  background:var(--card); border:1px solid var(--border); border-radius:16px;
  box-shadow:0 10px 30px rgba(0,0,0,.05); padding:18px;
}

/* Tables */
.data-table{width:100%;border-collapse:collapse}
.data-table th,.data-table td{padding:12px 10px;border-bottom:1px solid var(--border);text-align:left}
.data-table th{background:#f1f5f9;font-weight:700}

/* Make tables scrollable on small screens */
@media (max-width: 720px){
  .card{ overflow-x:auto; }
  .data-table{ min-width:640px; }
}

/* ================== Forms & Details ================== */
.form-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap:16px 20px;
}
@media (max-width: 900px){
  .form-grid{ grid-template-columns:1fr; }
}

.field{ display:flex; flex-direction:column; }
.field label{ font-size:13px; color:var(--muted); margin-bottom:6px; }
.field input[type=text],
.field input[type=email],
.field input[type=date],
.field input[type=password],
.field select,
.field textarea{
  border:1px solid var(--border); border-radius:12px;
  padding:12px 14px; font-size:15px; background:#fff;
}
.field input:focus,.field select:focus,.field textarea:focus{
  outline:none; border-color:#93c5fd; box-shadow:0 0 0 3px rgba(59,130,246,.18);
}

.file-row{ grid-column:1 / -1; }
.row-span{ grid-column:1 / -1; }
.help{ font-size:12px; color:var(--muted); margin-top:6px; }

.actions-bar{
  grid-column:1 / -1; display:flex; gap:10px; justify-content:flex-end; margin-top:-10px;
}

/* Key–value viewer */
.kv{
  display:grid; grid-template-columns:220px 1fr; gap:12px 20px;
}
.kv .k{ color:var(--muted); }
.kv .v{ font-weight:600; }
@media (max-width: 900px){ .kv{ grid-template-columns:1fr; } }

/* ================== Password eye (inside input) ================== */
.pw-wrap{ position:relative; display:block; width:100% }
.pw-wrap input{ width:100%; padding-right:2.5rem; box-sizing:border-box }
.pw-eye{
  position:absolute; top:50%; right:.75rem; transform:translateY(-50%);
  background:transparent; border:none; cursor:pointer; color:#6b7280;
  display:flex; align-items:center; justify-content:center; padding:0;
}
.pw-eye:hover{ color:#374151 }
.pw-eye svg{ width:20px; height:20px }
.icon-eye-off{ display:none }
.pw-wrap.is-show .icon-eye{ display:none }
.pw-wrap.is-show .icon-eye-off{ display:block }

/* ================== Search bar ================== */
.searchbar{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.search-input{ position:relative; flex:1; min-width:260px; }
.search-input input{
  width:100%; height:44px; padding:10px 14px 10px 40px;
  border:1px solid var(--border); border-radius:999px; background:#fff; font-size:15px;
  box-shadow:0 1px 2px rgba(0,0,0,.03) inset;
}
.search-input input::placeholder{ color:var(--muted); }
.search-icon{
  position:absolute; left:12px; top:50%; transform:translateY(-50%);
  width:18px; height:18px; color:#94a3b8;
}
.search-actions{ display:flex; gap:10px; }
.btn-secondary{ background:#fff; color:var(--text); border:1px solid var(--border); }
.btn-secondary:hover{ background:#f8fafc; }

/* ================== Dashboard ================== */
.kpi-grid{
  display:grid; gap:12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.kpi{
  background:#fff; border:1px solid var(--border); border-radius:16px;
  padding:16px; box-shadow:0 6px 20px rgba(0,0,0,.05);
}
.kpi-label{ color:var(--muted); font-size:13px; margin-bottom:6px; }
.kpi-value{ font-size:28px; font-weight:800; letter-spacing:.2px; }

.metric-row{ display:flex; align-items:center; justify-content:space-between; }
.metric-title{ font-weight:700; }
.metric-sub{ color:var(--muted); font-size:13px; margin-top:4px; }

.progress{ width:100%; height:10px; border-radius:999px; background:#e5e7eb; overflow:hidden; }
.progress-bar{ height:100%; background:#2563eb; }

.panel-grid{
  display:grid; gap:16px; margin-top:16px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.card-title{ font-weight:800; margin-bottom:10px; }
.list{ list-style:none; padding:0; margin:0; }
.list-row{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 0; border-top:1px solid #f0f2f5;
}
.list-row:first-child{ border-top:0; }
.list .title{ font-weight:600; }
.list .meta{ color:var(--muted); font-size:12px; margin-top:2px; }
.empty{ color:var(--muted); padding:6px 0; }

/* Mini bar chart */
.mini-bars{ margin-top:6px; }
.mini-bars-svg{ width:100%; height:110px; }
.mini-bar{ fill:#3b82f6; opacity:.85; }
.mini-bars-label{ font-size:10px; fill:#64748b; }
.mini-bars-legend{ display:flex; gap:12px; flex-wrap:wrap; color:#64748b; font-size:12px; margin-top:6px; }

/* ================== Action chips ================== */
.actions-cell{ display:flex; gap:8px; align-items:center; }
.chip{
  display:inline-flex; align-items:center; gap:8px;
  height:32px; padding:0 12px; border-radius:999px;
  border:1px solid var(--border); background:#fff; color:var(--text);
  font-size:13px; font-weight:600; text-decoration:none;
  box-shadow:0 1px 0 rgba(0,0,0,.02);
}
.chip svg{ width:16px; height:16px; }
.chip:hover{ background:#f8fafc; }
.chip:active{ transform:translateY(0.5px); }
.chip-view{ border-color:#c7d2fe; color:#1e40af; background:#eef2ff; }
.chip-view:hover{ background:#e0e7ff; }
.chip-edit{ border-color:#bfdbfe; color:#1d4ed8; background:#eff6ff; }
.chip-edit:hover{ background:#dbeafe; }

/* Compact chips on very small screens */
@media (max-width: 520px){
  .chip span{ display:none; }
  .chip{ padding:0 10px; }
}

/* ================== Utilities ================== */
.maxw{ max-width:none; width:100% } /* allow full-width cards when used */

/* Modern mini bar chart */
.mini-bars{
  margin-top:12px;
  border:1px solid var(--border);
  border-radius:14px;
  background: linear-gradient(180deg,#fff, #fafbff);
  box-shadow: 0 6px 24px rgba(0,0,0,.05);
  padding: 10px 12px 6px;
  position: relative;
}

/* gridlines (background stripes) */
.mini-bars::before{
  content:"";
  position:absolute; inset:10px 12px 32px 12px; /* leave bottom for labels */
  background:
    linear-gradient(to top, rgba(99,102,241,.08) 1px, transparent 1px) 0 0 / 100% 24px;
  pointer-events:none; border-radius:10px;
}

.mini-bars-svg{
  width:100%; height:140px; display:block;
}

.mini-bar{
  fill:#3b82f6;
  opacity:.85;
  rx:6; /* rounded */
  transition: transform .15s ease, opacity .15s ease, fill .15s ease;
}
.mini-bar:hover{
  transform: translateY(-2px);
  opacity:1;
  fill:#2563eb;
}

.mini-bars-label{
  font-size:11px; fill:#64748b;
}

/* legend chips */
.mini-bars-legend{
  display:flex; gap:10px; flex-wrap:wrap;
  color:#64748b; font-size:12px; margin-top:8px;
}
.mini-bars-legend span{
  background:#f1f5f9; border:1px solid var(--border);
  padding:4px 8px; border-radius:999px;
}

/* tooltip */
.chart-tip{
  position:absolute; z-index:10;
  background:#111827; color:#fff; font-size:12px; font-weight:600;
  padding:6px 8px; border-radius:8px; transform:translate(-50%,-120%);
  pointer-events:none; opacity:0; transition:opacity .12s ease, transform .12s ease;
  box-shadow:0 8px 20px rgba(0,0,0,.2);
  white-space:nowrap;
}
.chart-tip.show{ opacity:1; transform:translate(-50%,-130%); }

/* mobile tweaks */
@media (max-width: 560px){
  .mini-bars-svg{ height:120px; }
  .mini-bars-label{ font-size:10px; }
}
.modal{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;
  background:rgba(0,0,0,.5);}
.modal.hidden{display:none;}
.modal-content{max-width:400px;width:100%;}

