:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #e6eaf2;
  --text: #172033;
  --muted: #667085;
  --primary: #14213d;
  --accent: #d4a017;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --shadow: 0 10px 30px rgba(20,33,61,.08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { text-decoration: none; color: inherit; }
button, input, select, textarea { font: inherit; }
.app-shell { min-height: 100vh; display: flex; }
.mobile-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); opacity: 0; visibility: hidden;
  transition: .25s ease; z-index: 999;
}
.mobile-overlay.show { opacity: 1; visibility: visible; }
.sidebar {
  width: 270px; background: var(--primary); color: #fff; padding: 18px; position: fixed;
  top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 1000; transition: transform .25s ease;
}
.sidebar-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sidebar-close {
  display: none; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.12); color: #fff;
  width: 38px; height: 38px; border-radius: 12px; cursor: pointer;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 8px 6px 20px; border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 14px; flex:1; }
.brand-badge { width: 46px; height: 46px; border-radius: 14px; background: var(--accent); color: #1a1a1a; display:flex; align-items:center; justify-content:center; font-weight: 800; }
.brand-title { font-weight: 700; }
.brand-sub { font-size: 12px; opacity: .75; }
.nav-menu { display: grid; gap: 8px; }
.nav-menu a { padding: 13px 14px; border-radius: 14px; display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.88); }
.nav-menu a:hover, .nav-menu a.active { background: rgba(255,255,255,.12); color: #fff; }
.main-wrap { flex: 1; margin-left: 270px; display: flex; flex-direction: column; min-width: 0; }
.content {
  padding: 18px;
  min-width: 0;
}
.page-shell {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
  min-width: 0;
}
.topbar {
  min-height: 74px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display:flex; align-items:center; justify-content:space-between; padding: 12px 22px; position: sticky; top: 0; z-index: 100;
}
.topbar-left, .topbar-right { display:flex; align-items:center; gap: 14px; min-width: 0; }
.topbar h1 { font-size: 20px; margin: 0 0 4px; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 12px; width: 42px; height: 42px; font-size: 18px;
  display:none; align-items:center; justify-content:center; cursor: pointer;
}
.card, .panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  width: 100%; max-width: 100%; min-width: 0; overflow: hidden;
}
.panel { padding: 18px; }
.grid { display:grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid > *, .kpi-row > *, .form-grid > *, .form-grid-3 > * { min-width: 0; }
.stat-card { padding: 18px; }
.stat-label { color: var(--muted); font-size: 14px; }
.stat-value { font-size: 28px; font-weight: 800; margin: 8px 0 6px; }
.stat-foot { font-size: 13px; color: var(--muted); }
.success-line { border-left: 5px solid var(--success); }
.danger-line { border-left: 5px solid var(--danger); }
.warning-line { border-left: 5px solid var(--warning); }
.primary-line { border-left: 5px solid #2563eb; }
.page-actions { display:flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.btn {
  border: none; border-radius: 14px; padding: 12px 16px; cursor: pointer; font-weight: 700; display:inline-flex; align-items:center; justify-content:center; gap: 8px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-light { background: #eef2f7; color: var(--text); }
.btn-sm { padding: 9px 12px; border-radius: 12px; font-size: 13px; }
.chip { padding: 10px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.chip.warn { background: #fff5dd; color: #9a6700; }
.user-box { text-align:right; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.alert { padding: 14px 16px; border-radius: 14px; margin-bottom: 16px; }
.alert-success { background: #ecfdf3; color: #166534; }
.alert-error { background: #fef2f2; color: #991b1b; }
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: 13px; color: var(--muted); }
.form-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid-3 { display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.form-group { display:flex; flex-direction:column; gap: 8px; margin-bottom: 12px; }
label { font-weight: 700; font-size: 14px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid #d7dce5; background: #fff; font-size: 14px;
}
textarea { min-height: 96px; resize: vertical; }
.login-wrap { min-height: 100vh; display:grid; place-items:center; padding: 24px; }
.login-card { width: 100%; max-width: 430px; padding: 28px; }
.kpi-row { display:grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.product-cards { display:none; gap: 12px; }
.product-card { padding: 16px; }
.badge { padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; display:inline-block; }
.badge-success { background: #e9f9ef; color: #166534; }
.badge-warning { background: #fff7e6; color: #9a6700; }
.badge-danger { background: #fef2f2; color: #991b1b; }
.flex { display:flex; gap: 12px; align-items:center; flex-wrap: wrap; }
.flex-between { display:flex; justify-content:space-between; align-items:center; gap: 12px; }
.desktop-only { display:inline-flex; }
.mobile-only { display:none; }
.quick-total {
  position: sticky; bottom: 0; padding: 14px; border-top: 1px solid var(--line); background: #fff; margin: 18px -18px -18px;
  border-bottom-left-radius: 20px; border-bottom-right-radius: 20px;
}
@media (max-width: 991px) {
  .mobile-overlay.show { display: block; }
  .sidebar { transform: translateX(-105%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-flex; align-items:center; justify-content:center; }
  .main-wrap { margin-left: 0; }
  .icon-btn { display:inline-flex; }
  .grid-4, .grid-3, .grid-2, .kpi-row, .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .desktop-only { display:none; }
  body.menu-open { overflow: hidden; }
}
@media (max-width: 768px) {
  .content { padding: 12px; }
  .page-shell { gap: 14px; }
  .topbar { padding: 10px 14px; }
  .topbar h1 { font-size: 18px; }
  .topbar-right .chip, .topbar-right .user-box { display:none; }
  .product-cards { display:grid; }
  .table-products { display:none; }
  .table-mobile-hide { display:none; }
  table { min-width: 520px; }
  .flex-between { align-items: flex-start; }
  .flex-between form, form.flex { width: 100%; }
  form.flex input[type="text"], form.flex input[type="search"] { min-width: 0 !important; flex: 1 1 100%; width: 100%; }
  .btn { width: 100%; }
  .page-actions > .btn, .page-actions > a.btn { width: 100%; }
  .mobile-only { display:block; }
}
