/* ============================================
   STOCKPRO v2 — Shared Design System
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --dark:       #0a0e17;
  --panel:      #111827;
  --card:       #1a2233;
  --card2:      #1e2840;
  --border:     #2a3347;
  --border2:    #364057;
  --teal:       #10d9a0;
  --teal-dim:   rgba(16,217,160,.12);
  --blue:       #3b82f6;
  --blue-dim:   rgba(59,130,246,.12);
  --purple:     #8b5cf6;
  --purple-dim: rgba(139,92,246,.12);
  --amber:      #f59e0b;
  --amber-dim:  rgba(245,158,11,.12);
  --red:        #ef4444;
  --red-dim:    rgba(239,68,68,.12);
  --green:      #22c55e;
  --green-dim:  rgba(34,197,94,.12);
  --muted:      #6b7280;
  --text:       #f1f5f9;
  --subtle:     #cbd5e1;
  --sidebar-w:  260px;
  --topbar-h:   64px;
  --radius:     10px;
  --radius-lg:  16px;
  --shadow:     0 4px 24px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--dark);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
  line-height: 1.5;
}

/* ── SIDEBAR ─────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 200;
  display: flex; flex-direction: column;
  transition: transform .3s;
  overflow-y: auto; overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.sb-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem;
  text-decoration: none; flex-shrink: 0;
}
.sb-brand .logo-box {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; color: #fff; flex-shrink: 0;
  box-shadow: 0 0 20px rgba(16,217,160,.25);
}
.sb-brand .brand-text { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.15rem; color: var(--text); }
.sb-brand .brand-text span { color: var(--teal); }

.sb-section {
  padding: .9rem 1.25rem .3rem;
  font-size: .65rem; font-weight: 700;
  color: var(--muted); letter-spacing: 1.2px; text-transform: uppercase;
}

.sb-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem 1rem; margin: .1rem .65rem;
  border-radius: 8px;
  color: var(--muted); font-size: .845rem; font-weight: 500;
  text-decoration: none; border: none; background: none;
  width: calc(100% - 1.3rem); text-align: left; cursor: pointer;
  transition: background .15s, color .15s;
  position: relative;
}
.sb-link i { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.sb-link:hover { background: rgba(255,255,255,.05); color: var(--text); }
.sb-link.active { background: rgba(16,217,160,.1); color: var(--teal); }
.sb-link .sb-badge {
  margin-left: auto;
  background: var(--teal); color: #0a0e17;
  font-size: .6rem; font-weight: 800;
  padding: .1rem .4rem; border-radius: 999px;
  line-height: 1.4;
}
.sb-link .sb-badge.red { background: var(--red); color: #fff; }
.sb-link .sb-badge.amber { background: var(--amber); color: #0a0e17; }

.sb-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-user {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .75rem; border-radius: 9px;
  background: var(--card); border: 1px solid var(--border);
  cursor: pointer; transition: border-color .2s;
  text-decoration: none;
}
.sb-user:hover { border-color: var(--teal); }
.sb-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: #fff; flex-shrink: 0;
  background: linear-gradient(135deg, var(--purple), var(--blue));
}
.sb-user .u-name { font-size: .82rem; font-weight: 600; color: var(--text); }
.sb-user .u-role { font-size: .7rem; color: var(--muted); }

/* ── MAIN LAYOUT ─────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1.75rem;
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
}
.topbar-title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 1rem; color: var(--text); flex: 1; }

.search-box {
  position: relative; flex: 1; max-width: 300px;
}
.search-box i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85rem; pointer-events: none; }
.search-box input {
  width: 100%; padding: .45rem .85rem .45rem 2.1rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .84rem;
  outline: none; transition: border-color .2s;
}
.search-box input:focus { border-color: var(--teal); }
.search-box input::placeholder { color: var(--muted); }

.tb-btn {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--muted); font-size: .95rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative; transition: all .15s;
}
.tb-btn:hover { border-color: var(--teal); color: var(--teal); }
.tb-btn .notif-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--red);
  position: absolute; top: 5px; right: 5px;
  border: 2px solid var(--panel);
}

.page-content { padding: 1.5rem 1.75rem; flex: 1; }

/* ── PAGE HEADER ─────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .75rem;
  margin-bottom: 1.4rem;
}
.page-header-left h1 {
  font-family: 'Space Grotesk', sans-serif; font-weight: 700;
  font-size: 1.35rem; color: var(--text); margin-bottom: .15rem;
}
.page-header-left p { font-size: .83rem; color: var(--muted); }

.breadcrumb {
  display: flex; align-items: center; gap: .35rem;
  font-size: .76rem; color: var(--muted); margin-bottom: 1.2rem;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--teal); }
.breadcrumb .sep { font-size: .6rem; color: var(--border2); }
.breadcrumb .cur { color: var(--subtle); }

/* ── BUTTONS ─────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .52rem 1rem; border-radius: 8px;
  font-size: .845rem; font-weight: 600;
  cursor: pointer; transition: all .15s; border: none;
  font-family: 'Inter', sans-serif; text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--teal), var(--blue)); color: #fff; }
.btn-primary:hover { opacity: .88; color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--subtle); }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }
.btn-danger-outline { background: transparent; border: 1px solid rgba(239,68,68,.4); color: var(--red); }
.btn-danger-outline:hover { background: var(--red); color: #fff; }
.btn-sm { padding: .35rem .7rem; font-size: .78rem; }
.btn-xs { padding: .22rem .55rem; font-size: .72rem; }

/* ── CARDS ───────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.3rem;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.1rem;
}
.card-header h4 {
  font-family: 'Space Grotesk', sans-serif; font-weight: 600;
  font-size: .9rem; color: var(--text);
}

/* ── STAT CARDS ──────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.15rem 1.3rem;
  position: relative; overflow: hidden;
}
.stat-card .sc-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; margin-bottom: .8rem;
}
.stat-card .sc-label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; margin-bottom: .3rem; }
.stat-card .sc-value { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.65rem; color: var(--text); margin-bottom: .35rem; line-height: 1; }
.stat-card .sc-delta { font-size: .76rem; display: flex; align-items: center; gap: .3rem; }
.sc-up { color: var(--teal); }
.sc-down { color: var(--red); }
.sc-icon.teal { background: var(--teal-dim); color: var(--teal); }
.sc-icon.blue { background: var(--blue-dim); color: var(--blue); }
.sc-icon.purple { background: var(--purple-dim); color: var(--purple); }
.sc-icon.amber { background: var(--amber-dim); color: var(--amber); }
.sc-icon.red { background: var(--red-dim); color: var(--red); }
.sc-icon.green { background: var(--green-dim); color: var(--green); }

/* ── TABLE ───────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .845rem; }
.data-table thead tr { border-bottom: 1px solid var(--border); }
.data-table th {
  padding: .6rem .9rem; text-align: left;
  font-size: .68rem; font-weight: 700; color: var(--muted);
  letter-spacing: .6px; text-transform: uppercase; white-space: nowrap;
}
.data-table td {
  padding: .7rem .9rem; color: var(--subtle);
  border-bottom: 1px solid rgba(42,51,71,.6); vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover td { background: rgba(255,255,255,.025); }
.td-main { color: var(--text) !important; font-weight: 500; }
.td-code { font-family: monospace; font-size: .8rem; color: var(--blue); background: var(--blue-dim); padding: .15rem .45rem; border-radius: 5px; }

/* ── BADGES ──────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .18rem .6rem; border-radius: 999px;
  font-size: .69rem; font-weight: 700; white-space: nowrap;
}
.badge::before { content:''; width:5px; height:5px; border-radius:50%; background:currentColor; }
.badge-teal   { background: var(--teal-dim);   color: var(--teal); }
.badge-blue   { background: var(--blue-dim);   color: var(--blue); }
.badge-purple { background: var(--purple-dim); color: var(--purple); }
.badge-amber  { background: var(--amber-dim);  color: var(--amber); }
.badge-red    { background: var(--red-dim);    color: var(--red); }
.badge-green  { background: var(--green-dim);  color: var(--green); }
.badge-muted  { background: rgba(107,114,128,.15); color: var(--muted); }

/* ── TABLE TOOLBAR ───────────────────────── */
.table-toolbar {
  display: flex; align-items: center; gap: .6rem;
  flex-wrap: wrap; margin-bottom: 1.1rem;
}
.filter-select {
  padding: .42rem .8rem; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--subtle); font-size: .8rem; cursor: pointer;
  appearance: none; outline: none;
}
.filter-select:focus { border-color: var(--teal); }

/* ── ACTION BUTTONS (table row) ──────────── */
.row-actions { display: flex; gap: .3rem; align-items: center; }
.act-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); font-size: .82rem;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s;
}
.act-btn:hover { background: var(--card2); color: var(--text); }
.act-btn.edit:hover  { border-color: var(--blue);   color: var(--blue); }
.act-btn.del:hover   { border-color: var(--red);    color: var(--red); }
.act-btn.view:hover  { border-color: var(--teal);   color: var(--teal); }
.act-btn.print:hover { border-color: var(--purple); color: var(--purple); }

/* ── PAGINATION ──────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .5rem;
  padding: .9rem 1.1rem; border-top: 1px solid var(--border);
}
.pagination .pg-info { font-size: .78rem; color: var(--muted); }
.pg-btns { display: flex; gap: .3rem; }
.pg-btn {
  min-width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); font-size: .78rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s; padding: 0 .4rem;
}
.pg-btn:hover, .pg-btn.active { background: var(--teal-dim); border-color: var(--teal); color: var(--teal); }

/* ── MODAL ───────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%;
  max-height: 90vh; overflow-y: auto;
  animation: modalIn .22s ease;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.modal-sm { max-width: 420px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }
@keyframes modalIn { from { opacity:0; transform:scale(.95) translateY(10px); } to { opacity:1; transform:scale(1) translateY(0); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--card); z-index: 2;
}
.modal-header h5 { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: .95rem; color: var(--text); }
.modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: none;
  color: var(--muted); cursor: pointer; font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.modal-close:hover { border-color: var(--red); color: var(--red); }
.modal-body { padding: 1.4rem 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: .6rem;
  position: sticky; bottom: 0; background: var(--card);
}

/* ── FORM ────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block; font-size: .72rem; font-weight: 700;
  color: var(--muted); letter-spacing: .5px;
  text-transform: uppercase; margin-bottom: .4rem;
}
.form-control {
  width: 100%; padding: .62rem .9rem;
  background: var(--panel); border: 1.5px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .875rem;
  outline: none; transition: border-color .2s, box-shadow .2s;
  font-family: 'Inter', sans-serif;
}
.form-control:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(16,217,160,.1); }
.form-control::placeholder { color: var(--muted); }
select.form-control { appearance: none; cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: .75rem; }
.form-error {
  display: none; background: var(--red-dim);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 8px; padding: .6rem .9rem;
  font-size: .82rem; color: var(--red); margin-top: .5rem;
}
.form-error.show { display: flex; align-items: center; gap: .5rem; }

/* ── TOAST ───────────────────────────────── */
.toast-stack { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .4rem; }
.toast {
  background: var(--card2); border: 1px solid var(--border2);
  border-radius: 10px; padding: .7rem 1rem;
  display: flex; align-items: center; gap: .6rem;
  font-size: .82rem; color: var(--text); min-width: 240px;
  box-shadow: var(--shadow); animation: toastIn .25s ease;
}
.toast.success { border-left: 3px solid var(--teal); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.warning { border-left: 3px solid var(--amber); }
.toast.info    { border-left: 3px solid var(--blue); }
@keyframes toastIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }

/* ── MISC ────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 1.2rem 0; }
.text-teal { color: var(--teal); }
.text-muted { color: var(--muted); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.font-mono { font-family: monospace; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* checkbox accent */
input[type=checkbox] { accent-color: var(--teal); }

/* scrollbar global */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

@media(max-width:768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
