/* ==========================================================
   SaleReport — گروه لوازم خانگی یاس
   رنگ برند: C8A2C8  |  رنگ سایدبار: #9B7A9B
   ========================================================== */

/* ---------- FONTS ---------- */
@font-face { font-family: 'Pinar'; src: url('/fonts/PINAR-LIGHT.ttf') format('truetype');   font-weight: 300; font-display: swap; }
@font-face { font-family: 'Pinar'; src: url('/fonts/PINAR-REGULAR.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Pinar'; src: url('/fonts/PINAR-MEDIUM.ttf') format('truetype');  font-weight: 500; font-display: swap; }
@font-face { font-family: 'Pinar'; src: url('/fonts/PINAR-SEMIBOLD.ttf') format('truetype');font-weight: 600; font-display: swap; }
@font-face { font-family: 'Pinar'; src: url('/fonts/PINAR-BOLD.ttf') format('truetype');    font-weight: 700; font-display: swap; }

/* ---------- TOKENS ---------- */
:root {
  --primary: #C8A2C8;
  --primary-dark: #8A6BA8;
  --primary-light: #F0E6F0;
  --primary-soft: #FAF4FA;

  --sidebar-bg: #9B7A9B;
  --sidebar-bg-2: #8A6B8A;
  --sidebar-w: 72px;
  --sidebar-w-open: 250px;

  --accent-1: #A8C8C8;
  --accent-2: #C8C8A2;
  --accent-3: #C8A8B8;
  --accent-4: #D8B8C8;

  --white: #ffffff;
  --bg: #F6F1F8;
  --bg-soft: #EFE7F2;
  --border: #E0D4E0;
  --border-soft: #EFE7F0;
  --text: #2C2033;
  --text-muted: #6D6072;

  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --warning: #f59e0b;
  --warning-soft: #fff7ed;
  --success: #10b981;
  --success-soft: #ecfdf5;
  --info: #3b82f6;
  --info-soft: #eff6ff;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(140,110,150,.06);
  --shadow: 0 4px 16px rgba(140,110,150,.10);
  --shadow-lg: 0 10px 30px rgba(138,107,168,.20);

  --field-h: 42px;
  --btn-h: 42px;
}

[data-theme="dark"] {
  --bg: #17131D;
  --bg-soft: #1E1826;
  --white: #231C2C;
  --border: rgba(200,162,200,.20);
  --border-soft: rgba(200,162,200,.10);
  --text: #F2EBF5;
  --text-muted: #B0A5B8;
  --primary-light: #3A2C44;
  --primary-soft: #2A2136;
  --sidebar-bg: #5B475B;
  --sidebar-bg-2: #4A3A4A;
}

/* ---------- BASE ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Pinar', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  font-size: 14px;
  line-height: 1.7;
  height: 100vh;
  overflow: hidden;
}

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 0% 0%, rgba(200, 162, 200, 0.18) 0%, transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(200, 162, 200, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(138, 107, 168, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(168, 200, 200, 0.10) 0%, transparent 45%),
    linear-gradient(135deg, #F2EAF4 0%, #F6F1F8 50%, #EFE7F2 100%);
  background-attachment: fixed;
}
[data-theme="dark"] body {
  background-image:
    radial-gradient(circle at 0% 0%, rgba(200, 162, 200, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 100% 100%, rgba(138, 107, 168, 0.10) 0%, transparent 50%),
    linear-gradient(135deg, #17131D 0%, #1E1826 100%);
}

a { color: var(--primary-dark); text-decoration: none; transition: .2s; }
a:hover { color: var(--primary); }

table, th, td, .mono, .kpi-value, input, select, textarea, button {
  font-family: 'Pinar', Tahoma, sans-serif;
}

/* ==========================================================
   LOGIN
   ========================================================== */
body.login-body {
  background: #9B7A9B !important;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.18) 0%, transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(0,0,0,.12) 0%, transparent 50%),
    radial-gradient(circle at 50% 100%, rgba(200,162,200,.35) 0%, transparent 55%) !important;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: auto;
}

.login-card {
  background: rgba(255,255,255,.97);
  border-radius: 22px;
  padding: 38px 36px 30px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: 0 30px 80px rgba(0,0,0,.28), 0 0 0 1px rgba(255,255,255,.4) inset;
  position: relative;
  z-index: 2;
  animation: loginSlide .55s cubic-bezier(.4,.2,.2,1) both;
}
@keyframes loginSlide {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: none; }
}

.login-brand { margin-bottom: 22px; }
.login-logo {
  width: 180px;
  height: 180px;
  object-fit: contain;
  margin-bottom: 12px;
  filter: drop-shadow(0 10px 26px rgba(138,107,168,.30));
}
.login-brand h1 {
  font-size: 22px; font-weight: 700;
  color: #6E4E6E; line-height: 1.4;
}
.login-brand p {
  margin-top: 6px;
  color: #8A7A8A; font-size: 13.5px;
}

/* نشان‌های امنیتی */
.security-badges {
  display: flex; align-items: center; justify-content: center; gap: 22px;
  margin-top: 22px; padding-top: 18px;
  border-top: 1px dashed rgba(155,122,155,.30);
}
.security-badge {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: #8A7A8A; font-size: 11px; font-weight: 500; transition: .2s;
}
.security-badge:hover { color: #6E4E6E; }
.security-badge svg {
  width: 28px; height: 28px; stroke: #9B7A9B; fill: none;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: .2s;
}
.security-badge:hover svg { stroke: var(--primary-dark); transform: translateY(-2px); }

/* ==========================================================
   FORMS
   ========================================================== */
.form-group { margin-bottom: 16px; text-align: right; }
.form-group label {
  display: block;
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text);
}
.form-control {
  width: 100%;
  height: var(--field-h);
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  transition: .2s;
  background: var(--white);
  color: var(--text);
  outline: none;
}
.form-control::placeholder { color: var(--text-muted); opacity: .7; }
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(200,162,200,.18);
}
textarea.form-control {
  height: auto;
  min-height: 80px;
  padding: 10px 14px;
  resize: vertical;
}
select.form-control { cursor: pointer; }

/* ==========================================================
   BUTTONS
   ========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-h);
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(138,107,168,.28);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(138,107,168,.38);
  color: #fff;
}
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-block { width: 100%; height: 50px; font-size: 14.5px; }
.btn-outline {
  background: var(--white);
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 12.5px; border-radius: 8px; }

.btn-mini {
  height: 32px;
  padding: 0 12px;
  font-size: 11.5px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid var(--border);
  transition: .2s;
  font-family: inherit;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.btn-mini:hover { background: var(--primary); color: #fff; border-color: transparent; }
.btn-mini.danger { background: rgba(231,111,81,.15); color: #E76F51; }
.btn-mini.danger:hover { background: #E76F51; color: #fff; }

/* ==========================================================
   ALERTS
   ========================================================== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13.5px;
  border: 1px solid transparent;
  flex-shrink: 0;
}
.alert-danger  { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.alert-success { background: #f0fdfa; color: #065f56; border-color: #b3ece4; }

/* ==========================================================
   LAYOUT
   ========================================================== */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ==========================================================
   SIDEBAR
   ========================================================== */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  border-left: 1px solid rgba(255,255,255,.08);
  padding: 16px 10px;
  position: relative;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width .25s ease;
  z-index: 100;
  box-shadow: -4px 0 20px rgba(90,60,90,.20);
}
.sidebar.open { width: var(--sidebar-w-open); }

/* Sidebar Brand */
.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid rgba(255,255,255,.18);
  margin-bottom: 12px;
  overflow: hidden;
  transition: .25s;
}
.sidebar-brand img {
  height: 46px;
  width: 46px;
  object-fit: contain;
  flex-shrink: 0;
  background: #fff;
  border-radius: 12px;
  padding: 5px;
  box-shadow: 0 6px 16px rgba(0,0,0,.22);
  transition: .25s;
}
.sidebar.open .sidebar-brand img {
  width: 100%;
  max-width: 150px;
  height: auto;
  max-height: 80px;
  background: transparent;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  object-fit: contain;
}
.sidebar-brand .brand-text {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity .2s, max-height .25s;
  color: #fff;
}
.sidebar-brand .brand-text small {
  display: block;
  font-size: 10.5px;
  font-weight: 400;
  color: rgba(255,255,255,.75);
  margin-top: 2px;
}
.sidebar.open .sidebar-brand .brand-text {
  opacity: 1;
  max-height: 80px;
}

/* Nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  width: 100%;
  height: 46px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.92);
  font-weight: 500;
  font-size: 13.5px;
  transition: .2s;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: inherit;
  text-decoration: none;
}
.sidebar.open .nav-link {
  justify-content: flex-start;
  gap: 12px;
  padding: 0 12px;
}

.nav-link:hover { background: rgba(255,255,255,.15); color: #fff; }
.nav-link.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
}
.nav-link.active .nav-icon svg { stroke: var(--primary-dark); }

.nav-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  margin: 0;
}
.nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
  fill: none;
  display: block;
  flex-shrink: 0;
}

.nav-label { display: none; }
.sidebar.open .nav-label {
  display: inline-block;
  font-size: 13px;
  white-space: nowrap;
}

/* Tooltip */
.sidebar:not(.open) .nav-link::after,
.sidebar:not(.open) .nav-more-btn::after {
  content: attr(title);
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-right: 10px;
  padding: 6px 10px;
  background: #2C2033;
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 200;
}
.sidebar:not(.open) .nav-link:hover::after,
.sidebar:not(.open) .nav-more-btn:hover::after { opacity: 1; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,.18);
  margin: 10px 6px;
  flex-shrink: 0;
}

/* --- NAV MORE (...) --- */
.nav-more-btn {
  /* کاملاً شبیه nav-link */
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  font-weight: 500;
  color: rgba(255,255,255,.92);
  padding: 0;
  width: 100%;
  height: 46px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  transition: .2s;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  line-height: inherit;
}
.sidebar.open .nav-more-btn {
  justify-content: flex-start;
  gap: 12px;
  padding: 0 12px;
}
.nav-more-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.nav-more-btn.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
}
.nav-more-btn.active .nav-icon svg { stroke: var(--primary-dark); }

.nav-more-menu {
  display: none;
  flex-direction: column;
  gap: 2px;
  background: rgba(255,255,255,.10);
  border-radius: var(--radius-sm);
  padding: 6px;
  margin: 2px 0;
}
.nav-more-menu.open { display: flex; }

.nav-more-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  height: 40px;
  border-radius: 8px;
  color: rgba(255,255,255,.88);
  font-weight: 500;
  font-size: 12.5px;
  text-decoration: none;
  transition: .2s;
  white-space: nowrap;
  justify-content: center;
}
.sidebar.open .nav-more-item { justify-content: flex-start; }
.nav-more-item:hover { background: rgba(255,255,255,.15); color: #fff; }
.nav-more-item.active { background: #fff; color: var(--primary-dark); }
.nav-more-item.active .nav-icon svg { stroke: var(--primary-dark); }

.nav-more-divider {
  height: 1px;
  background: rgba(255,255,255,.14);
  margin: 4px 0;
}

/* Sidebar Toggle */
.sidebar-toggle {
  margin-top: auto;
  width: 100%;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(255,255,255,.20);
  background: rgba(255,255,255,.12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .2s;
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.4);
}
.sidebar-toggle svg { transition: transform .25s; }
.sidebar.open .sidebar-toggle svg { transform: rotate(180deg); }

/* ==========================================================
   MAIN CONTENT
   ========================================================== */
.main-content {
  flex: 1;
  padding: 16px 22px 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
  gap: 12px;
}

/* ==========================================================
   TOPBAR
   ========================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius);
  padding: 10px 18px;
  box-shadow: 0 4px 18px rgba(138,107,168,.10);
  border: 1px solid rgba(200,162,200,.20);
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
  min-height: 62px;
  position: relative;
  z-index: 50;
  background-image:
    radial-gradient(circle at 0% 0%, rgba(200,162,200,.15) 0%, transparent 30%),
    radial-gradient(circle at 15% 100%, rgba(138,107,168,.08) 0%, transparent 35%),
    linear-gradient(135deg, #ffffff 0%, #faf5fb 60%, #f2e8f4 100%);
}
[data-theme="dark"] .topbar {
  background-image: linear-gradient(135deg, #241C2E 0%, #1B1524 100%);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.topbar-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.topbar h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0;
  line-height: 1.3;
  white-space: nowrap;
}
[data-theme="dark"] .topbar h2 { color: var(--primary); }
.topbar-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 460px;
}
@media (max-width: 900px) {
  .topbar-subtitle { max-width: 200px; font-size: 10.5px; }
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: .2s;
  flex-shrink: 0;
  text-decoration: none;
}
.icon-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

/* ==========================================================
   USER CHIP
   ========================================================== */
.user-chip { position: relative; z-index: 60; }

.user-chip-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 5px 6px;
  height: var(--field-h);
  border-radius: 12px;
  background: rgba(255,255,255,.7);
  border: 1.5px solid rgba(200,162,200,.22);
  cursor: pointer;
  transition: .2s;
  font-family: inherit;
}
[data-theme="dark"] .user-chip-btn { background: rgba(40,32,50,.7); }
.user-chip-btn:hover {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(138,107,168,.15);
}
[data-theme="dark"] .user-chip-btn:hover { background: #2A2136; }

.user-chip-btn .user-info { text-align: right; line-height: 1.35; }
.user-chip-btn .user-info strong {
  font-size: 12.5px;
  display: block;
  color: var(--primary-dark);
}
[data-theme="dark"] .user-chip-btn .user-info strong { color: var(--primary); }
.user-chip-btn .user-info small {
  font-size: 10.5px;
  color: var(--text-muted);
}
.user-chip-btn .avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 3px 8px rgba(138,107,168,.3);
  flex-shrink: 0;
}
.user-chip-btn .chevron {
  color: var(--text-muted);
  transition: transform .2s;
  flex-shrink: 0;
}
.user-chip.open .user-chip-btn .chevron { transform: rotate(180deg); }

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 190px;
  background: var(--white);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: 0 15px 40px rgba(140,110,150,.18);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: .2s;
  z-index: 500;
}
.user-chip.open .user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: .15s;
}
.dropdown-item:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.dropdown-item-danger { color: var(--danger); }
.dropdown-item-danger:hover {
  background: var(--danger-soft);
  color: #b91c1c;
}

/* ==========================================================
   PAGE HEAD — حذف شد
   ========================================================== */
.page-head { display: none; }
.text-muted-sm { color: var(--text-muted); font-size: 12.5px; margin: 0; }

/* ==========================================================
   FILTER BAR
   ========================================================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.filter-field {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--field-h);
  padding: 0 10px;
  background: var(--bg-soft);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: .2s;
  flex-shrink: 0;
}
.filter-field:focus-within {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(200,162,200,.15);
}
.filter-field svg {
  width: 16px;
  height: 16px;
  color: var(--primary-dark);
  flex-shrink: 0;
}
.filter-field label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  margin: 0;
}
.filter-field input,
.filter-field select {
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  height: 100%;
  padding: 0 4px;
  cursor: text;
  min-width: 0;
}
.filter-field select { cursor: pointer; padding-left: 4px; }
.filter-field input::placeholder { color: var(--text-muted); opacity: .6; }

.filter-field.date-field input {
  width: 105px;
  text-align: center;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  direction: ltr;
}
.filter-field.search-field { min-width: 200px; }
.filter-field.search-field input { width: 100%; }

.filter-submit,
.filter-reset {
  height: 38px;
  padding: 0 14px;
  font-size: 12.5px;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .filter-bar { gap: 6px; padding: 8px; }
  .filter-field { flex: 1 1 100%; }
  .filter-submit,
  .filter-reset { flex: 1 1 calc(50% - 3px); }
}

/* ==========================================================
   CARDS
   ========================================================== */
.glass, .card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #ffffff 0%, #faf5fb 100%);
}
[data-theme="dark"] .card-header {
  background: linear-gradient(135deg, #241C2E 0%, #1F1828 100%);
}
.card-header h3 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0;
}
[data-theme="dark"] .card-header h3 { color: var(--primary); }
.card-body { padding: 20px; }

/* ==========================================================
   KPI CARDS
   ========================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  flex-shrink: 0;
}
@media (max-width: 1400px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px)  { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.kpi-card {
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  transition: transform .25s, box-shadow .25s;
  min-height: 130px;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  color: #fff;
  border: none;
  box-shadow: 0 8px 22px rgba(140,110,150,.18);
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: -30px; left: -30px;
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(255,255,255,.28) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.kpi-card::after {
  content: '';
  position: absolute;
  bottom: -40px; right: -20px;
  width: 130px; height: 130px;
  background: radial-gradient(circle, rgba(255,255,255,.16) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 34px rgba(140,110,150,.28);
}

.kpi-card.k1 { background: linear-gradient(135deg, #C8A2C8 0%, #8A6BA8 100%); }
.kpi-card.k2 { background: linear-gradient(135deg, #A8C8C8 0%, #5C9C9C 100%); }
.kpi-card.k3 { background: linear-gradient(135deg, #C8C8A2 0%, #9C9C5C 100%); }
.kpi-card.k4 { background: linear-gradient(135deg, #C8A8B8 0%, #A86B87 100%); }
.kpi-card.k5 { background: linear-gradient(135deg, #D8B8C8 0%, #B07A92 100%); }
.kpi-card.k6 { background: linear-gradient(135deg, #8FB4C8 0%, #4F7C98 100%); }
.kpi-card.k6.grow-up   { background: linear-gradient(135deg, #7FD8A8 0%, #2A9D8F 100%); }
.kpi-card.k6.grow-down { background: linear-gradient(135deg, #F0A890 0%, #E76F51 100%); }

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  background: rgba(255,255,255,.22);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.30);
  align-self: flex-start;
}
.kpi-icon svg { width: 22px; height: 22px; }

.kpi-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.kpi-label {
  font-size: 11.5px;
  color: rgba(255,255,255,.88);
  margin-bottom: 4px;
  font-weight: 500;
}
.kpi-value {
  font-size: 21px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.kpi-hint {
  font-size: 10.5px;
  color: rgba(255,255,255,.75);
  margin-top: 3px;
}

/* ==========================================================
   CHARTS
   ========================================================== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-inline-end: 4px;
  padding-bottom: 8px;
}
@media (max-width: 1200px) { .charts-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px)  { .charts-grid { grid-template-columns: 1fr; } }

.chart-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 280px;
  animation: fadeIn .5s ease both;
  background: var(--white);
}
.chart-card.span-2 { grid-column: span 2; }
@media (max-width: 760px) { .chart-card.span-2 { grid-column: span 1; } }

.chart-head {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
  flex-shrink: 0;
}
.chart-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.chart-body {
  position: relative;
  flex: 1;
  min-height: 220px;
  height: 220px;
  width: 100%;
}
.chart-body canvas {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ==========================================================
   TABLES
   ========================================================== */
.table-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.table-scroll { overflow: auto; flex: 1; min-height: 0; }

.table-modern {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.table-modern th,
.table-modern td {
  padding: 10px 12px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-soft);
}
.table-modern thead th {
  background: #F4ECF6;
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 12.5px;
  border-bottom: 1.5px solid rgba(200,162,200,.35);
}
[data-theme="dark"] .table-modern thead th {
  background: #2A2136;
  color: var(--primary);
  border-bottom: 1.5px solid rgba(200,162,200,.30);
}
.table-modern tbody tr:nth-child(odd)  { background: var(--primary-soft); }
.table-modern tbody tr:nth-child(even) { background: var(--white); }
.table-modern tbody tr:hover { background: rgba(200,162,200,.14); }

.table-modern .mono {
  font-variant-numeric: tabular-nums;
  direction: rtl;
  text-align: right;
}
.table-modern .strong { font-weight: 700; }
.table-modern .trunc { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.table-modern .empty {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
}

.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 500;
}

/* ==========================================================
   PAGINATION
   ========================================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.pg-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--primary-dark);
  background: var(--primary-light);
  font-weight: 600;
  font-size: 13px;
  transition: .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pg-btn:hover { background: var(--primary); color: #fff; }
.pg-info { color: var(--text-muted); font-size: 13px; }

/* ==========================================================
   TABS
   ========================================================== */
.tabs {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  padding: 6px;
  flex-shrink: 0;
}
.tab {
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  transition: .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tab:hover { background: var(--primary-soft); color: var(--primary-dark); }
.tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(138,107,168,.30);
}

/* ==========================================================
   TOP SELLER
   ========================================================== */
.top-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
@media (max-width: 1100px) { .top-grid { grid-template-columns: 1fr; } }
.top-card { padding: 18px; }
.top-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.brand { background: var(--primary); }
.dot.a { background: var(--accent-1); }
.dot.b { background: var(--accent-2); }

.table-mini { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table-mini th,
.table-mini td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border-soft);
}
.table-mini th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11.5px;
}
.table-mini .mono {
  font-variant-numeric: tabular-nums;
  direction: rtl;
}
.table-mini .trunc {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table-mini .empty {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
}

.rank {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 11.5px;
  font-weight: 600;
}
.rank-1 { background: linear-gradient(135deg, #FFD86B, #E8A825); color: #5a3d00; }
.rank-2 { background: linear-gradient(135deg, #D8D8D8, #A0A0A0); color: #333; }
.rank-3 { background: linear-gradient(135deg, #E8B88A, #B87848); color: #4a2708; }

/* ==========================================================
   UPLOAD
   ========================================================== */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 14px;
  flex: 1;
  min-height: 0;
}
@media (max-width: 1000px) { .upload-grid { grid-template-columns: 1fr; } }
.upload-card,
.history-card { padding: 20px; overflow: auto; }

.drop-zone {
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  cursor: pointer;
  background: rgba(200,162,200,.08);
  transition: .2s;
  color: var(--primary-dark);
}
.drop-zone:hover,
.drop-zone.dragover {
  background: rgba(200,162,200,.18);
  transform: scale(1.01);
}
.drop-zone p { margin: 10px 0 4px; font-size: 13.5px; }
.file-name {
  display: block;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12.5px;
}

/* ==========================================================
   USERS
   ========================================================== */
.users-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.card-title { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.form-grid button { grid-column: span 2; justify-self: start; }

.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 0;
}
.inline-form select.form-control { min-width: 170px; }

.check {
  display: flex;
  gap: 5px;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-muted);
  height: var(--field-h);
}
.sub-row td {
  background: rgba(200,162,200,.06);
  padding: 6px 12px !important;
  white-space: normal;
}

.badge-ok {
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 11px;
  background: rgba(42,157,143,.16);
  color: #2A9D8F;
  font-weight: 500;
}
.badge-off {
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 11px;
  background: rgba(231,111,81,.15);
  color: #E76F51;
  font-weight: 500;
}

/* ==========================================================
   MODAL
   ========================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44,32,51,.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  overflow: hidden;
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--white);
  border-radius: 20px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  border: 1px solid rgba(200,162,200,.25);
  overflow: hidden;
  animation: modalIn .3s cubic-bezier(.4,.2,.2,1) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #ffffff 0%, #faf5fb 100%);
  flex-shrink: 0;
}
[data-theme="dark"] .modal-header {
  background: linear-gradient(135deg, #241C2E 0%, #1F1828 100%);
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0;
}
[data-theme="dark"] .modal-header h3 { color: var(--primary); }

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: var(--primary-soft);
  color: var(--primary-dark);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: .2s;
  font-family: inherit;
}
.modal-close:hover { background: var(--danger); color: #fff; }

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.modal-body .form-grid { gap: 12px; }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
}

/* ==========================================================
   FOOTER
   ========================================================== */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 0 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}
.footer-sep { color: var(--border); }

/* ==========================================================
   SCROLLBAR
   ========================================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(138,107,168,.35);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(138,107,168,.6); }

/* ==========================================================
   MOBILE
   ========================================================== */
.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  html, body { overflow: auto; height: auto; }
  .app-layout { height: auto; min-height: 100vh; }
  .main-content { height: auto; overflow: visible; padding: 14px; }

  .sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: var(--sidebar-w-open) !important;
    transform: translateX(100%);
    box-shadow: -10px 0 30px rgba(90,60,90,.25);
    transition: transform .3s ease;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar .brand-text { opacity: 1; max-height: 80px; }
  .sidebar .nav-label { display: inline-block; }
  .sidebar .nav-link { justify-content: flex-start; padding: 0 12px; gap: 12px; }
  .sidebar .nav-more-btn { justify-content: flex-start; padding: 0 12px; gap: 12px; }
  .sidebar .nav-more-item { justify-content: flex-start; }
  .sidebar .nav-more-item .nav-label { display: inline-block; }
  .sidebar .sidebar-brand img {
    width: 100%; max-width: 150px; height: auto; max-height: 80px;
    background: transparent; padding: 0; border-radius: 0; box-shadow: none;
  }
  .sidebar .sidebar-toggle { display: none; }

  .menu-toggle { display: inline-flex; }

  .table-wrap { flex: none; }
  .table-scroll { max-height: 65vh; }

  .user-chip-btn .user-info { display: none; }
  .user-dropdown { left: auto; right: 0; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-card { min-height: 240px; }
  .chart-body { min-height: 180px; height: 180px; }
}

@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .filter-bar { padding: 6px; }
}