@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ══════════════════════════════════════════
   VARIABLES
══════════════════════════════════════════ */
:root {
  --bg:       #0d1117;
  --bg2:      #161b22;
  --bg3:      #21262d;
  --border:   #30363d;
  --text:     #e6edf3;
  --text2:    #7d8590;
  --accent:   #2f81f7;
  --accent-h: #1f6feb;
  --success:  #3fb950;
  --warning:  #d29922;
  --danger:   #f85149;
  --radius:   10px;
  --sidebar:  260px;
  --topbar:   56px;
  --trans:    .18s ease;
}

/* ══════════════════════════════════════════
   RESET
══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; }
button { font-family: inherit; }

/* ══════════════════════════════════════════
   OVERLAY
══════════════════════════════════════════ */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(3px);
  z-index: 400;
  transition: opacity var(--trans);
}
#overlay.show { display: block; }

/* ══════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════ */
#sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 500;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}

/* Logo */
.s-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.s-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), #58a6ff);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.s-logo-text {
  font-size: 16px; font-weight: 700;
  letter-spacing: .3px;
}
.s-close {
  display: none;
  margin-left: auto;
  background: none; border: none;
  color: var(--text2); cursor: pointer;
  font-size: 20px; padding: 2px 4px;
  line-height: 1; border-radius: 6px;
  transition: background var(--trans);
}
.s-close:hover { background: var(--bg3); color: var(--text); }

/* Nav sections */
.s-section { padding: 12px 10px 4px; }
.s-section-label {
  font-size: 10px; font-weight: 600;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text2); padding: 0 8px;
  margin-bottom: 4px;
}
.s-link {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text2); font-size: 13.5px; font-weight: 500;
  transition: all var(--trans);
  margin-bottom: 1px;
  min-height: 38px;
}
.s-link:hover  { background: var(--bg3); color: var(--text); }
.s-link.active { background: rgba(47,129,247,.15); color: var(--accent); }
.s-link .si    { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }

/* Footer */
.s-footer {
  margin-top: auto;
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.s-user {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  background: var(--bg3); cursor: default;
}
.s-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #58a6ff);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.s-uname { font-size: 13px; font-weight: 600; line-height: 1.3; }
.s-urole { font-size: 11px; color: var(--text2); }

/* ══════════════════════════════════════════
   TOPBAR
══════════════════════════════════════════ */
#topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar);
  right: 0;
  height: var(--topbar);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
  z-index: 300;
  transition: left .28s cubic-bezier(.4,0,.2,1);
}

/* Burger */
#burger {
  display: none;
  background: none; border: none;
  cursor: pointer; padding: 6px;
  border-radius: 7px; color: var(--text);
  transition: background var(--trans);
  flex-shrink: 0;
}
#burger:hover { background: var(--bg3); }
#burger span {
  display: block;
  width: 20px; height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: all .22s ease;
  transform-origin: center;
}
#burger span + span { margin-top: 5px; }
/* Burger → X animation */
#burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#burger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
#burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.t-title {
  font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}
.t-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ══════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════ */
#main {
  margin-left: var(--sidebar);
  padding-top: var(--topbar);
  min-height: 100vh;
  transition: margin-left .28s cubic-bezier(.4,0,.2,1);
}
.page-content {
  padding: 24px;
}

/* ══════════════════════════════════════════
   BOTTOM NAV  (mobile only)
══════════════════════════════════════════ */
#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 58px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  z-index: 300;
  padding-bottom: env(safe-area-inset-bottom);
}
.bn-inner {
  display: flex;
  height: 58px;
  align-items: stretch;
}
.bn-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  color: var(--text2); font-size: 10px; font-weight: 500;
  transition: color var(--trans);
  min-width: 0;
}
.bn-item .bi { font-size: 21px; line-height: 1; }
.bn-item.active { color: var(--accent); }
/* FAB-style center button */
.bn-fab {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  color: white; font-size: 10px; font-weight: 500;
}
.bn-fab-circle {
  width: 44px; height: 44px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(47,129,247,.45);
  margin-top: -16px;
  transition: background var(--trans), transform var(--trans);
}
.bn-fab:active .bn-fab-circle { transform: scale(.94); }
.bn-fab-label { color: var(--text2); font-size: 10px; font-weight: 500; }

/* ══════════════════════════════════════════
   CARDS
══════════════════════════════════════════ */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ══════════════════════════════════════════
   STAT CARDS
══════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  display: flex; align-items: flex-start; gap: 12px;
  transition: border-color var(--trans);
}
.stat-card:hover { border-color: rgba(47,129,247,.4); }
.stat-icon {
  width: 42px; height: 42px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(47,129,247,.15); }
.stat-icon.green  { background: rgba(63,185,80,.15); }
.stat-icon.yellow { background: rgba(210,153,34,.15); }
.stat-icon.red    { background: rgba(248,81,73,.15); }
.stat-icon.cyan   { background: rgba(88,166,255,.12); }
.stat-label { font-size: 12px; color: var(--text2); margin-bottom: 3px; }
.stat-value { font-size: 20px; font-weight: 700; line-height: 1.1; }
.stat-sub   { font-size: 11px; color: var(--text2); margin-top: 3px; }

/* ══════════════════════════════════════════
   TABLE
══════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; min-width: 400px; }
thead tr { background: var(--bg3); }
th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 600;
  letter-spacing: .7px; text-transform: uppercase;
  color: var(--text2); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }

/* ══════════════════════════════════════════
   BADGES
══════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-blue   { background: rgba(47,129,247,.15);  color: #58a6ff; }
.badge-green  { background: rgba(63,185,80,.15);   color: #3fb950; }
.badge-yellow { background: rgba(210,153,34,.15);  color: #e3b341; }
.badge-red    { background: rgba(248,81,73,.15);   color: #ff7b72; }
.badge-gray   { background: rgba(125,133,144,.12); color: #8b949e; }

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13.5px; font-weight: 600;
  border: none; cursor: pointer;
  text-decoration: none;
  transition: all var(--trans);
  white-space: nowrap;
  min-height: 36px;
  line-height: 1;
}
.btn-primary  { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #2d333b; border-color: #484f58; }
.btn-danger   { background: rgba(248,81,73,.12); color: #ff7b72; border: 1px solid rgba(248,81,73,.3); }
.btn-danger:hover { background: rgba(248,81,73,.22); }
.btn-success  { background: rgba(63,185,80,.12); color: #3fb950; border: 1px solid rgba(63,185,80,.3); }
.btn-success:hover { background: rgba(63,185,80,.22); }
.btn-sm { padding: 5px 11px; font-size: 12px; min-height: 30px; }
.btn-back {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 7px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); font-size: 13px; font-weight: 500;
  transition: all var(--trans); white-space: nowrap;
}
.btn-back:hover { color: var(--text); border-color: #484f58; }

/* ══════════════════════════════════════════
   FORMS
══════════════════════════════════════════ */
.form-label, label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text2); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: .4px;
}
input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px; font-family: inherit;
  transition: border-color var(--trans), box-shadow var(--trans);
  outline: none;
  -webkit-appearance: none;
  min-height: 40px;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,129,247,.15);
}
select { cursor: pointer; }
select option { background: var(--bg2); }
textarea { resize: vertical; min-height: 80px; min-height: unset; }

/* ══════════════════════════════════════════
   PAGE HEADER
══════════════════════════════════════════ */
.page-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 10px; flex-wrap: wrap;
}
.page-header h1 {
  font-size: 20px; font-weight: 700;
}

/* ══════════════════════════════════════════
   FILTER BAR
══════════════════════════════════════════ */
.filter-bar {
  display: flex; gap: 8px;
  margin-bottom: 16px; flex-wrap: wrap; align-items: center;
}
.filter-bar input,
.filter-bar select { width: auto; min-width: 130px; }

/* ══════════════════════════════════════════
   MESSAGES
══════════════════════════════════════════ */
.messages { margin-bottom: 16px; }
.alert {
  padding: 10px 14px; border-radius: 8px;
  margin-bottom: 8px; font-size: 13.5px; font-weight: 500;
  border-left: 3px solid;
}
.alert-success { background: rgba(63,185,80,.1);  color: #3fb950; border-color: #3fb950; }
.alert-error   { background: rgba(248,81,73,.1);  color: #ff7b72; border-color: #f85149; }
.alert-warning { background: rgba(210,153,34,.1); color: #e3b341; border-color: #d29922; }

/* ══════════════════════════════════════════
   DETAIL
══════════════════════════════════════════ */
.detail-item { margin-bottom: 13px; }
.detail-label {
  font-size: 11px; color: var(--text2);
  text-transform: uppercase; letter-spacing: .4px; margin-bottom: 2px;
}
.detail-value { font-size: 14px; font-weight: 500; }

/* ══════════════════════════════════════════
   LOGIN
══════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(47,129,247,.08) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 20%, rgba(88,166,255,.05) 0%, transparent 50%);
}
.login-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; padding: 36px 32px;
  width: 100%; max-width: 400px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .big-icon { font-size: 38px; display: block; margin-bottom: 10px; }
.login-logo h1 {
  font-size: 26px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #58a6ff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-logo p { color: var(--text2); font-size: 13px; margin-top: 4px; }

/* ══════════════════════════════════════════
   UTILITIES
══════════════════════════════════════════ */
.text-muted   { color: var(--text2) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.fw-bold   { font-weight: 700; }
.mt-1 { margin-top: 8px; }   .mt-2 { margin-top: 16px; }  .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.w-full { width: 100%; }
.gap-2  { gap: 16px; }
.flex   { display: flex; }
.flex-center { display: flex; align-items: center; }
.justify-between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #2d333b; }


/* ══════════════════════════════════════════
   TABLET  ≤ 1024px
══════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --sidebar: 230px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3     { grid-template-columns: 1fr 1fr; }
}


/* ══════════════════════════════════════════
   MOBILE  ≤ 768px
══════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Sidebar → off-canvas drawer */
  #sidebar { transform: translateX(-100%); box-shadow: none; }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,.5);
  }
  .s-close { display: flex; }

  /* Topbar spans full width */
  #topbar { left: 0; padding: 0 14px; }
  #burger { display: flex; flex-direction: column; }

  /* Main no left margin */
  #main { margin-left: 0; }

  /* Extra bottom padding for bottom nav */
  .page-content {
    padding: 14px;
    padding-bottom: calc(14px + 58px + env(safe-area-inset-bottom));
  }

  /* Bottom nav visible */
  #bottom-nav { display: block; }

  /* Stats: 2 cols */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .stat-card  { padding: 14px 12px; gap: 10px; }
  .stat-value { font-size: 18px; }
  .stat-icon  { width: 38px; height: 38px; font-size: 17px; }

  /* Cards */
  .card { padding: 14px; border-radius: 9px; }

  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
  .page-header h1 { font-size: 17px; }

  /* Filter bar full-width */
  .filter-bar { gap: 6px; }
  .filter-bar input,
  .filter-bar select { width: 100%; min-width: 0; }

  /* Tables */
  th { padding: 8px 10px; font-size: 10px; }
  td { padding: 10px 10px; font-size: 13px; }

  /* Collapse all inline 2/3-col grids */
  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  /* Override inline style grids from templates */
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* Buttons */
  .btn { padding: 9px 14px; font-size: 13px; }
  .t-actions { gap: 6px; }

  /* Login */
  .login-box { padding: 26px 18px; }
}


/* ══════════════════════════════════════════
   SMALL PHONES  ≤ 400px
══════════════════════════════════════════ */
@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-content { padding: 10px; padding-bottom: calc(10px + 58px + env(safe-area-inset-bottom)); }
  .t-title { font-size: 13px; }
}
