/* ============================================================
   KLASSE CRM — style.css
   ============================================================ */

/* ===== CSS VARIABLES ===== */
:root {
  --primary: #2563eb;
  --primary-h: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #06b6d4;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --light: #94a3b8;

  --sb-bg: #1e293b;
  --sb-text: #cbd5e1;
  --sb-muted: #475569;
  --sb-active-bg: rgba(37, 99, 235, 0.18);
  --sb-active-text: #60a5fa;
  --sb-hover: rgba(255, 255, 255, 0.07);

  --sidebar-w: 240px;
  --header-h: 56px;
  --r: 8px;
  --r-sm: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .10);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .14);
}

/* ===== RESET ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
}

input,
select,
textarea {
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
}

/* ===== LAYOUT ===== */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR OVERLAY (mobile) ===== */
.sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 40;
  backdrop-filter: blur(2px);
}

.sb-overlay.show {
  display: block;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width .25s ease, transform .25s ease;
  z-index: 50;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 64px;
}

/* Logo */
.sb-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: var(--header-h);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  flex-shrink: 0;
}

.sb-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.sb-logo-text {
  font-size: 15px;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .2s;
}

.sidebar.collapsed .sb-logo-text {
  opacity: 0;
  pointer-events: none;
}

/* Nav */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: none;
}

.sb-nav::-webkit-scrollbar {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--sb-text);
  cursor: pointer;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}

.nav-item:hover {
  background: var(--sb-hover);
  color: #f1f5f9;
}

.nav-item.active {
  background: var(--sb-active-bg);
  color: var(--sb-active-text);
}

.nav-item-sub {
  padding-left: 38px;
  font-size: 13px;
  opacity: .9;
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.nav-label {
  font-size: 13.5px;
  font-weight: 500;
  transition: opacity .2s;
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  pointer-events: none;
}

/* Sidebar footer / user */
.sb-footer {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  flex-shrink: 0;
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  overflow: hidden;
  transition: background .15s;
}

.sb-user:hover {
  background: var(--sb-hover);
}

.sb-user-av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.sb-user-name {
  font-size: 13px;
  font-weight: 500;
  color: #e2e8f0;
  white-space: nowrap;
  transition: opacity .2s;
}

.sb-user-role {
  font-size: 11px;
  color: var(--sb-muted);
  white-space: nowrap;
  transition: opacity .2s;
}

.sidebar.collapsed .sb-user-name,
.sidebar.collapsed .sb-user-role {
  opacity: 0;
  pointer-events: none;
}

/* ===== MAIN WRAPPER ===== */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ===== TOP BAR ===== */
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--muted);
  transition: background .15s;
  flex-shrink: 0;
}

.topbar-btn:hover {
  background: var(--bg);
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.topbar-center {
  flex: 1;
  max-width: 420px;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0 12px;
  height: 34px;
  transition: border-color .15s;
}

.topbar-search:focus-within {
  border-color: var(--primary);
}

.topbar-search input {
  border: none;
  background: none;
  outline: none;
  font-size: 13.5px;
  color: var(--text);
  width: 100%;
}

.topbar-search input::placeholder {
  color: var(--light);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.topbar-icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--muted);
  position: relative;
  transition: background .15s;
}

.topbar-icon-btn:hover {
  background: var(--bg);
}

.topbar-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 16px;
  height: 16px;
  background: var(--danger);
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--surface);
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 34px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
  cursor: pointer;
}

.btn svg {
  flex-shrink: 0;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-h);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-ghost {
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-bg);
  color: #059669;
}

.badge-warning {
  background: var(--warning-bg);
  color: #d97706;
}

.badge-danger {
  background: var(--danger-bg);
  color: #dc2626;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-muted {
  background: #f1f5f9;
  color: var(--muted);
}

.badge-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 16px 20px;
}

/* ===== PAGE HEADER ===== */
.page-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-hdr h2 {
  font-size: 17px;
  font-weight: 600;
}

.page-hdr-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0 10px;
  height: 34px;
  min-width: 200px;
}

.toolbar-search input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  color: var(--text);
  width: 100%;
}

.toolbar-search input::placeholder {
  color: var(--light);
}

.toolbar-select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.toolbar-select:focus {
  border-color: var(--primary);
}

/* ===== TABLE ===== */
.tbl-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tbl-scroll {
  overflow-x: auto;
}

.tbl-scroll::-webkit-scrollbar {
  height: 6px;
}

.tbl-scroll::-webkit-scrollbar-track {
  background: #f8fafc;
}

.tbl-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

table.dt {
  width: 100%;
  border-collapse: collapse;
}

table.dt th {
  background: #f8fafc;
  padding: 11px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

table.dt td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
}

table.dt tbody tr:last-child td {
  border-bottom: none;
}

table.dt tbody tr {
  cursor: pointer;
  transition: background .1s;
}

table.dt tbody tr:hover {
  background: #f8fafc;
}

table.dt tbody tr.sel {
  background: #dbeafe;
}

table.dt tbody tr.sel td {
  color: var(--text);
}

table.dt tbody tr.low-stock td {
  background: #fffbeb !important;
}

table.dt tbody tr.crit-stock td {
  background: #fef2f2 !important;
}

.td-code {
  font-size: 12.5px;
  color: var(--muted);
  font-family: 'Courier New', monospace;
}

.td-link {
  color: var(--primary);
  font-weight: 500;
}

.td-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.dt th.td-num {
  text-align: right;
}

/* Table footer */
.tbl-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 8px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 3px;
}

.pg-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--muted);
  transition: background .12s;
}

.pg-btn:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
}

.pg-btn.active {
  background: var(--primary);
  color: #fff;
}

.pg-btn:disabled {
  opacity: .4;
  cursor: default;
}

/* ===== KPI CARDS ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 20px;
}

.kpi-card-link {
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}

.kpi-card-link:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 16px rgba(37, 99, 235, .12);
}

.kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.kpi-ico {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.kpi-ico.blue {
  background: #eff6ff;
}

.kpi-ico.green {
  background: #ecfdf5;
}

.kpi-ico.yellow {
  background: #fffbeb;
}

.kpi-ico.red {
  background: #fef2f2;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}

.kpi-sub {
  font-size: 12.5px;
  font-weight: 500;
}

.kpi-sub.up {
  color: var(--success);
}

.kpi-sub.down {
  color: var(--danger);
}

.kpi-sub.warn {
  color: var(--warning);
}

/* ===== CHARTS ===== */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 20px;
}

.chart-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

.chart-wrap {
  position: relative;
  height: 220px;
}

/* ===== DASHBOARD BOTTOM ===== */
.dash-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ===== CUSTOMERS 3-PANEL ===== */
.crm-page {
  display: flex;
  gap: 0;
  height: calc(100vh - var(--header-h) - 48px);
}

/* Filter panel */
.crm-filter {
  width: 185px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--r) 0 0 var(--r);
  overflow-y: auto;
  padding: 14px;
}

.crm-filter-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 10px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.crm-filter-search {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 12px;
}

.crm-filter-check {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text);
}

.crm-filter-check input[type=checkbox] {
  accent-color: var(--primary);
  width: 13px;
  height: 13px;
}

.crm-filter-more {
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  margin-top: 6px;
  display: block;
}

/* Table panel */
.crm-table-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}

.crm-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.crm-toolbar h2 {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-toolbar h2 select {
  font-size: 14px;
  font-weight: 600;
  border: none;
  background: none;
  outline: none;
  cursor: pointer;
  color: var(--text);
}

.crm-table-scroll {
  flex: 1;
  overflow: auto;
}

.crm-table-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.crm-table-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Detail panel */
.crm-detail {
  width: 300px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--r) var(--r) 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .2s ease;
}

.crm-detail.hidden {
  width: 0;
  overflow: hidden;
  border: none;
}

.detail-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 0 12px;
}

.detail-tab {
  padding: 11px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
  white-space: nowrap;
}

.detail-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.detail-body::-webkit-scrollbar {
  width: 4px;
}

.detail-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* Activity items */
.activity-list {
  padding: 8px 10px;
}

.act-item {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #f8fafc;
}

.act-item:last-child {
  border-bottom: none;
}

.act-ico {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
}

.act-ico.yellow {
  background: #fef9c3;
}

.act-ico.blue {
  background: #dbeafe;
}

.act-ico.green {
  background: #d1fae5;
}

.act-ico.red {
  background: #fee2e2;
}

.act-ico.purple {
  background: #ede9fe;
}

.act-ico.teal {
  background: #cffafe;
}

.act-ico.orange {
  background: #ffedd5;
}

.act-body {
  flex: 1;
  min-width: 0;
}

.act-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.act-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.act-meta {
  font-size: 11px;
  color: var(--light);
  margin-top: 3px;
}

/* ===== SLIDE-OVER ===== */
.so-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  z-index: 60;
  backdrop-filter: blur(1px);
}

.so-bg.open {
  display: block;
}

.slide-over {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 480px;
  max-width: 95vw;
  background: var(--surface);
  z-index: 70;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
}

.slide-over.open {
  transform: translateX(0);
}

.so-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.so-title {
  font-size: 15px;
  font-weight: 600;
}

.so-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--muted);
  transition: background .15s;
}

.so-close-btn:hover {
  background: var(--bg);
}

.so-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ===== FORMS ===== */
.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid-2 {
  grid-template-columns: 1fr 1fr;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.form-label .req {
  color: var(--danger);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}

.form-textarea {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== TABS (Reports) ===== */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab-item {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
}

.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-item:hover:not(.active) {
  color: var(--text);
}

/* ===== SETTINGS ===== */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.settings-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ===== SUMMARY STAT ROW ===== */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 20px;
}

.stat-box-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-box-value {
  font-size: 20px;
  font-weight: 700;
}

.stat-box-value.primary {
  color: var(--primary);
}

.stat-box-value.success {
  color: var(--success);
}

.stat-box-value.danger {
  color: var(--danger);
}

/* ===== MOBILE BOTTOM NAV ===== */
.mob-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 30;
  justify-content: space-around;
  align-items: center;
  padding: 0 4px;
}

.mob-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  transition: color .15s;
  min-width: 48px;
}

.mob-nav-item.active {
  color: var(--primary);
}

.mob-nav-icon {
  font-size: 18px;
  line-height: 1;
}

/* ===== EMPTY STATE ===== */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-ico {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .5;
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 13px;
  color: var(--light);
}

/* ===== DIVIDER ===== */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .charts-row {
    grid-template-columns: 1fr;
  }

  .dash-bottom {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .crm-filter {
    display: none;
  }

  .crm-filter.show {
    display: block;
    position: fixed;
    top: var(--header-h);
    left: var(--sidebar-w);
    height: calc(100vh - var(--header-h));
    z-index: 25;
    border-radius: 0;
    border: none;
    box-shadow: var(--shadow-md);
  }

  .crm-detail {
    display: none;
  }

  .crm-detail.show {
    display: flex;
    position: fixed;
    right: 0;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    width: 300px;
    z-index: 25;
    border-radius: 0;
    border: none;
    box-shadow: var(--shadow-md);
  }

  .crm-table-panel {
    border-radius: var(--r);
    border: 1px solid var(--border);
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .main-content {
    padding: 16px;
    padding-bottom: 80px;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .mob-nav {
    display: flex;
  }

  .topbar-center {
    display: none;
  }

  .slide-over {
    width: 100%;
    max-width: 100%;
  }

  .stat-row {
    grid-template-columns: 1fr;
  }

  .crm-page {
    height: auto;
    flex-direction: column;
    gap: 12px;
  }

  .crm-filter {
    width: 100%;
    border-radius: var(--r);
    border: 1px solid var(--border);
  }

  .crm-table-panel {
    border-radius: var(--r);
    border: 1px solid var(--border);
    height: 500px;
  }

  .crm-detail {
    display: none;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
  }

  .page-hdr {
    flex-direction: column;
    align-items: flex-start;
  }

  .kpi-value {
    font-size: 18px;
  }
}

/* ===== UTILITIES ===== */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.mt-1 {
  margin-top: 4px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-3 {
  margin-top: 12px;
}

.mt-4 {
  margin-top: 16px;
}

.mb-4 {
  margin-bottom: 16px;
}

.text-muted {
  color: var(--muted);
}

.text-primary {
  color: var(--primary);
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

.text-right {
  text-align: right;
}

.font-bold {
  font-weight: 600;
}

.font-mono {
  font-family: 'Courier New', monospace;
  font-size: 12.5px;
}

.w-full {
  width: 100%;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}