@font-face {
  font-family: 'IranianSans';
  src: url('../fonts/IranianSans.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-main: 'IranianSans', 'Segoe UI', sans-serif;
  --primary: #8B5A2B;
  --primary-hover: #5C3A21;
  --primary-light: #F3EDE5;
  --accent: #A0522D;
  --success: #6B8E23;
  --success-hover: #556B2F;
  --warning: #D2691E;
  --danger: #B22222;
  --bg-body: #FDFBF7;
  --bg-surface: #FFFFFF;
  --bg-input: #FAF6F0;
  --text-main: #2C1E0F;
  --text-muted: #5C4A3A;
  --border: #D2C4B0;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

[data-theme="dark"] {
  --bg-body: #1A1410;
  --bg-surface: #2A1F18;
  --bg-input: #3D2E24;
  --text-main: #F5EFE6;
  --text-muted: #CBB9A8;
  --border: #4E3E32;
  --primary-light: #3D2E24;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font-main);
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  font-size: 14px;
}
.app-wrapper {
  display: flex;
  flex: 1 0 auto;
  min-height: 0;
}

/* ===== سایدبار ===== */
.sidebar {
  width: 280px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
  flex-shrink: 0;
  transition: transform 0.3s ease;
}
.sidebar-header {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 32px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  word-break: break-word;
  flex-shrink: 0;
}
#logotext {
  flex: 1;
  font-size: 1.1rem;
}
.sidebar-close {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  transition: var(--transition);
}
.sidebar-close:hover {
  color: var(--danger);
}
.sidebar-nav {
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
.nav-item i {
  font-style: normal;
  font-size: 1.1rem;
}
.nav-item:hover,
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  transform: translateX(-4px);
}
.sidebar-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ===== محتوای اصلی ===== */
.main-content {
  flex: 1;
  padding: 28px 36px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}
.main-footer {
  flex-shrink: 0;
  background: var(--bg-body);
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
  flex-shrink: 0;
}
.main-header h2 {
  font-size: 1.7rem;
  font-weight: 700;
  word-break: break-word;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.user-badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 16px;
  border-radius: 40px;
  font-weight: 500;
  font-size: 0.8rem;
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-main);
  margin-left: 1rem;
  padding: 0 8px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 25;
}

/* ===== پنل‌ها ===== */
.panel {
  display: none;
  animation: fadeInUp 0.4s ease;
  flex: 1;
  min-height: 0;
  width: 100%;
}
.panel.active {
  display: flex;
  flex-direction: column;
}
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
  flex-shrink: 0;
}
.inventory-header-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  width: 100%;
}
.total-volume-badge {
  font-weight: bold;
  background: var(--bg-surface);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  white-space: nowrap;
}
.search-input {
  padding: 10px 18px;
  border-radius: 40px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  min-width: 200px;
  flex: 1;
  outline: none;
  font-size: 0.85rem;
}
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== داشبورد ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 10px;
}
.card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 20px 15px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}
.card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  background: var(--primary-light);
}
.card-icon {
  font-size: 2.8rem;
  margin-bottom: 16px;
}
.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
}
.card-desc {
  color: var(--text-muted);
  font-size: 0.8rem;
}
.stats-mini-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 12px;
}
.stat-mini-card {
  background: var(--bg-surface);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
}
.stat-mini-card:hover {
  background: var(--primary-light);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.stat-mini-card span {
  color: var(--text-muted);
  font-size: 0.8rem;
}
.stat-mini-card strong {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

/* ===== فرم‌ها ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  align-items: flex-end;
}
.form-row>* {
  flex: 1 1 160px;
  min-width: 140px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 140px;
}
.form-group label {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
}
input,
select,
textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-main);
  outline: none;
  font-family: inherit;
  transition: var(--transition);
  font-size: 0.85rem;
  width: 100%;
}
input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== نوع قیمت‌گذاری (دراپ‌داون) ===== */
.pricing-type-group {
  min-width: 160px;
  max-width: 200px;
}
.pricing-type-group label {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 4px;
  display: block;
}
.pricing-type-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
  cursor: pointer;
  appearance: auto;
}
.pricing-type-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== سبد خرید ===== */
.cart-section {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}
.cart-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.cart-controls select {
  flex: 2;
  min-width: 180px;
}
.cart-controls input[type="number"] {
  width: 80px;
  flex-shrink: 0;
}
.cart-controls input[type="text"] {
  width: 150px;
  flex-shrink: 0;
}
.cart-controls .btn {
  flex-shrink: 0;
}
.cart-header {
  display: grid;
  grid-template-columns: 0.8fr 1.8fr 0.6fr 1fr 1fr 1.2fr 1.5fr 0.6fr;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 12px 0;
  border: 1px solid var(--border);
}
.cart-item-row {
  display: grid;
  grid-template-columns: 0.8fr 1.8fr 0.6fr 1fr 1fr 1.2fr 1.5fr 0.6fr;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  transition: var(--transition);
}
.cart-item-row:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}
.cart-item-row .col-code {
  font-weight: 600;
  color: var(--primary);
}
.cart-item-row .col-name {
  font-weight: 500;
}
.cart-item-row .col-qty {
  text-align: center;
}
.cart-item-row .col-volume,
.cart-item-row .col-total-vol {
  font-family: monospace;
  text-align: center;
  font-size: 0.75rem;
}
.cart-item-row .col-price-m3 {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
}
.cart-item-row .col-price {
  text-align: left;
  font-weight: 700;
  color: var(--primary);
}
.cart-item-row .col-actions {
  text-align: center;
}
.cart-items-container {
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.empty-cart,
.empty-checks {
  text-align: center;
  color: var(--text-muted);
  padding: 16px 0;
  font-size: 0.85rem;
}
.cart-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--bg-surface);
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: 16px;
}
.summary-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  flex-wrap: wrap;
  font-size: 0.85rem;
}
.summary-item span {
  font-weight: 700;
  color: var(--primary);
  font-size: 1rem;
}
.summary-item input {
  padding: 6px 12px;
  width: 100px;
}

/* ===== پرداخت ===== */
.payment-section {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}
.payment-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}
.payment-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.payment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  padding: 8px 16px;
  border-radius: 40px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}
.payment-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.payment-item input[type="text"] {
  width: 120px;
  padding: 6px 10px;
  flex-shrink: 0;
}
.payment-submit {
  margin-right: auto;
  display: flex;
  align-items: center;
}
.payment-submit .btn {
  padding: 10px 24px;
  font-size: 0.9rem;
}
.check-section-hidden {
  display: none;
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}
.check-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.check-controls .form-group {
  min-width: 140px;
  flex: 1;
}
.checks-container {
  margin-top: 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.check-item-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  font-size: 0.8rem;
}
.check-item-row:last-child {
  border-bottom: none;
}

/* ===== دکمه‌ها ===== */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: white;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-main);
  white-space: nowrap;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  font-size: 0.85rem;
  min-height: 40px;
  min-width: 40px;
}
.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-3px);
  box-shadow: 0 8px 15px rgba(139, 90, 43, 0.2);
}
.btn-success {
  background: var(--success);
}
.btn-success:hover {
  background: var(--success-hover);
}
.btn-danger {
  background: var(--danger);
}
.btn-warning {
  background: var(--warning);
  color: white;
}
.btn-warning:hover {
  background: #b85e1a;
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  box-shadow: none;
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-2px);
}
.btn-sm {
  padding: 6px 14px;
  font-size: 0.75rem;
  min-height: 32px;
  min-width: 32px;
}
.btn-lg {
  padding: 12px 24px;
  font-size: 0.9rem;
}
.btn-icon {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 50%;
  min-width: 36px;
  min-height: 36px;
}
.btn-icon:hover {
  background: var(--border);
  color: var(--text-main);
}

/* ===== جدول‌ها ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  margin-top: 12px;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
  font-size: 0.8rem;
}
th,
td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  word-break: break-word;
  font-size: 0.8rem;
}
th {
  background: var(--bg-input);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 1;
}
tr:last-child td {
  border-bottom: none;
}
tr:hover {
  background: var(--primary-light);
  transition: background 0.2s;
}
td .btn {
  margin: 0 4px;
}

/* ===== انبار مشتری ===== */
.customer-stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
  overflow-y: auto;
  padding-right: 4px;
}
.stock-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stock-card h4 {
  font-size: 1.1rem;
  margin-bottom: 14px;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.stock-card .detail-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.8rem;
}
.stock-card .detail-label {
  font-weight: 600;
  color: var(--text-muted);
}
.stock-card .items-list {
  margin: 10px 0;
  padding-right: 16px;
  list-style-type: circle;
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.8rem;
}
.stock-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== فیلترها ===== */
.filter-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-row select {
  flex: 1 1 160px;
  min-width: 140px;
}

/* ===== گزارشات ===== */
.report-section-box {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.report-section-box h3 {
  margin-bottom: 0;
  color: var(--primary);
  font-size: 1.1rem;
}
.report-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}
.report-actions .btn {
  flex: 1 1 auto;
  min-width: 140px;
  justify-content: center;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-surface);
  padding: 20px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  text-align: center;
  transition: var(--transition);
  min-width: 0;
}
.stat-card:hover {
  background: var(--primary-light);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.stat-card span {
  color: var(--text-muted);
  font-size: 0.8rem;
  display: block;
  line-height: 1.35;
}
.stat-card strong {
  font-size: clamp(1.05rem, 2.5vw, 1.55rem);
  font-weight: 700;
  color: var(--primary);
  display: block;
  margin-top: 8px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* ===== مودال‌ها ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: var(--bg-surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 800px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.3s ease;
}
.large-modal {
  max-width: 1000px;
}
.small-modal {
  max-width: 420px;
}
.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.modal-header h3 {
  font-size: 1.1rem;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  font-size: 0.85rem;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ===== تنظیمات ===== */
.settings-tabs-container {
  background: var(--bg-surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 4px;
  margin-bottom: 24px;
}
#settings .tabs {
  display: flex;
  gap: 4px;
  margin: 0;
  border-bottom: none;
  flex-wrap: wrap;
}
#settings .tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: var(--transition);
  flex: 1;
  justify-content: center;
  min-width: 100px;
}
#settings .tab-btn .tab-icon {
  font-size: 1.1rem;
}
#settings .tab-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}
#settings .tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(139, 90, 43, 0.3);
}
#settings .tab-btn.active:hover {
  background: var(--primary-hover);
  color: white;
}
#settings .inner-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 4px;
  flex-wrap: wrap;
}
#settings .inner-tabs .tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: var(--transition);
}
#settings .inner-tabs .tab-btn .tab-icon {
  font-size: 1rem;
}
#settings .inner-tabs .tab-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}
#settings .inner-tabs .tab-btn.active {
  color: var(--primary);
  border-bottom: 3px solid var(--primary);
  background: var(--primary-light);
}
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}
.inner-tab-content {
  display: none;
}
.inner-tab-content.active {
  display: block;
}
.settings-card {
  background: var(--bg-surface);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.settings-card h3 {
  font-size: 1.1rem;
  margin-bottom: 4px;
  color: var(--text-main);
}
.settings-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 20px;
}
.theme-selector {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-input);
  flex: 1;
  min-width: 120px;
  justify-content: center;
}
.theme-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.theme-option input[type="radio"] {
  display: none;
}
.theme-option .theme-preview {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
}
.theme-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(139, 90, 43, 0.2);
}
.security-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 450px;
}
.security-form .form-group {
  min-width: unset;
}
.security-form .form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.security-form .btn {
  align-self: flex-start;
  min-width: 160px;
}
.log-box {
  background: #1E1512;
  color: #A5D6A7;
  padding: 16px;
  border-radius: var(--radius-sm);
  height: 300px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  direction: ltr;
  text-align: left;
  border: 1px solid #4E3A33;
  font-size: 0.8rem;
  line-height: 1.8;
}
.log-box .log-loading {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 0;
  direction: rtl;
}
.log-box .log-entry {
  border-bottom: 1px solid #4E3A33;
  padding: 6px 0;
  color: #A5D6A7;
}
.log-box .log-entry .log-time {
  color: #FFD54F;
}
.log-box .log-entry .log-user {
  color: #81D4FA;
}
.log-box .log-entry .log-ip {
  color: #CE93D8;
}

/* ===== وضعیت‌ها ===== */
.status-delivered {
  color: #2e7d32 !important;
  font-weight: 600;
  background-color: #e8f5e9;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-block;
  font-size: 0.75rem;
}
.status-cancelled {
  color: #c62828 !important;
  font-weight: 600;
  background-color: #ffebee;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-block;
  font-size: 0.75rem;
}
.status-warehouse {
  color: #ed6c02 !important;
  font-weight: 600;
  background-color: #fff3e0;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-block;
  font-size: 0.75rem;
}

/* ===== صفحه ورود ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #5C3A21 0%, #2C1E0F 100%);
  padding: 20px;
}
.login-container {
  width: 100%;
  max-width: 420px;
}
.login-card {
  background: var(--bg-surface);
  padding: 32px;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}
.login-header {
  text-align: center;
  margin-bottom: 28px;
}
.logo {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.login-subtitle {
  color: var(--text-muted);
  margin-top: 8px;
  font-size: 0.85rem;
}
.input-group {
  margin-bottom: 20px;
}
.input-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.85rem;
}
.input-group input {
  width: 100%;
}
.btn-block {
  width: 100%;
}
.error-message {
  color: var(--danger);
  text-align: center;
  margin-top: 16px;
  min-height: 24px;
  font-size: 0.85rem;
}
.login-footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ===== ریسپانسیو ===== */
@media (max-width: 1200px) {
  .stats-mini-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 992px) {
  .cart-header,
  .cart-item-row {
    grid-template-columns: 0.6fr 1.5fr 0.5fr 0.8fr 0.8fr 1fr 1.2fr 0.5fr;
    gap: 6px;
    font-size: 0.7rem;
    padding: 8px 10px;
  }
  .main-content {
    padding: 20px 24px 16px;
  }
}
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }
  .sidebar {
    position: fixed;
    right: -280px;
    top: 0;
    height: 100vh;
    transition: right 0.3s ease;
    z-index: 1000;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    overflow-y: auto !important;
    width: 280px;
    padding: 20px 16px;
  }
  .sidebar.open {
    right: 0;
  }
  .sidebar-overlay.active {
    display: block;
  }
  .sidebar-close {
    display: block;
  }
  body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }
  .main-content {
    padding: 16px;
    width: 100%;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    display: block;
  }
  .main-header h2 {
    font-size: 1.2rem;
  }
  .sidebar-header {
    font-size: 1.2rem;
  }
  .stats-mini-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .stats-mini-card {
    padding: 14px;
  }
  .stats-mini-card strong {
    font-size: 1.1rem;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .stat-card {
    padding: 16px;
  }
  .stat-card strong {
    font-size: 1.2rem;
  }
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .card {
    padding: 16px 12px;
  }
  .card-icon {
    font-size: 2rem;
  }
  .card-title {
    font-size: 0.95rem;
  }
  .form-row {
    flex-direction: column;
  }
  .form-row>* {
    flex: 1 1 auto;
    width: 100%;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .pricing-type-group {
    min-width: unset;
    max-width: 100%;
  }
  .cart-header {
    display: none;
  }
  .cart-item-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 12px 16px;
  }
  .cart-item-row .col-code::before {
    content: "کد: ";
    font-weight: 600;
    color: var(--text-muted);
  }
  .cart-item-row .col-name::before {
    content: "نام: ";
    font-weight: 600;
    color: var(--text-muted);
  }
  .cart-item-row .col-qty::before {
    content: "تعداد: ";
    font-weight: 600;
    color: var(--text-muted);
  }
  .cart-item-row .col-volume::before {
    content: "حجم هر قطعه: ";
    font-weight: 600;
    color: var(--text-muted);
  }
  .cart-item-row .col-total-vol::before {
    content: "حجم کل: ";
    font-weight: 600;
    color: var(--text-muted);
  }
  .cart-item-row .col-price-m3::before {
    content: "قیمت هر m³: ";
    font-weight: 600;
    color: var(--text-muted);
  }
  .cart-item-row .col-price::before {
    content: "قیمت کل: ";
    font-weight: 600;
    color: var(--text-muted);
  }
  .cart-item-row .col-actions {
    text-align: left;
    margin-top: 4px;
  }
  .cart-item-row .col-actions button {
    width: 100%;
  }
  .cart-controls {
    flex-direction: column;
  }
  .cart-controls select {
    width: 100%;
  }
  .cart-controls input[type="number"],
  .cart-controls input[type="text"] {
    width: 100%;
  }
  .cart-controls .btn {
    width: 100%;
  }
  .cart-summary-row {
    flex-direction: column;
    align-items: stretch;
  }
  .summary-item {
    justify-content: space-between;
  }
  .summary-item input {
    width: 100%;
  }
  .payment-row {
    flex-direction: column;
    align-items: stretch;
  }
  .payment-methods {
    flex-direction: column;
  }
  .payment-item {
    width: 100%;
    border-radius: var(--radius-sm);
  }
  .payment-item input[type="text"] {
    width: 100%;
  }
  .payment-submit {
    margin-right: 0;
    width: 100%;
  }
  .payment-submit .btn {
    width: 100%;
  }
  .check-controls {
    flex-direction: column;
  }
  .check-controls .form-group {
    width: 100%;
  }
  .check-controls .btn {
    width: 100%;
  }
  .customer-stock-grid {
    grid-template-columns: 1fr;
  }
  .modal {
    max-width: 100%;
    max-height: 90vh;
    margin: 10px;
  }
  .small-modal {
    max-width: 100%;
  }
  .modal-body {
    padding: 16px;
  }
  .tabs {
    gap: 4px;
  }
  .tab-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
  }
  .filter-row {
    flex-direction: column;
  }
  .filter-row select {
    width: 100%;
  }
  .inventory-header-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .total-volume-badge {
    text-align: center;
    white-space: normal;
  }
  .report-actions {
    flex-direction: column;
    width: 100%;
  }
  .report-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .search-input {
    width: 100%;
    min-width: unset;
  }
  .table-wrapper table {
    min-width: unset;
    width: 100%;
  }
  .table-wrapper table thead {
    display: none;
  }
  .table-wrapper table tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    padding: 12px 14px;
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
  }
  .table-wrapper table tbody tr td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 0.85rem;
    text-align: right;
    flex-wrap: wrap;
    gap: 4px;
  }
  .table-wrapper table tbody tr td:last-child {
    border-bottom: none;
  }
  .table-wrapper table tbody tr td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: 10px;
  }

  .table-wrapper table tbody tr.baseline-separator-row,
  .table-wrapper table tbody tr.deleted-section-header {
    box-shadow: none;
    border: none;
    padding: 6px 0;
    margin-bottom: 6px;
    background: transparent;
  }
  .table-wrapper table tbody tr.baseline-separator-row td,
  .table-wrapper table tbody tr.deleted-section-header td {
    display: block;
    border-bottom: none;
    padding: 6px 0;
  }
  .table-wrapper table tbody tr.baseline-separator-row td::before,
  .table-wrapper table tbody tr.deleted-section-header td::before {
    content: none;
  }
  .table-wrapper table tbody tr.deleted-stats-row {
    opacity: 1;
    border-color: var(--border);
    background: var(--bg-input) !important;
    color: var(--text-main);
  }
  .table-wrapper table tbody tr td .btn {
    margin: 2px;
    font-size: 0.7rem;
    padding: 4px 10px;
  }
  .table-wrapper table tbody tr td:last-child {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
  }
  .login-card {
    padding: 24px;
  }
  #settings .tabs {
    flex-direction: column;
  }
  #settings .tab-btn {
    width: 100%;
    justify-content: center;
    padding: 10px;
  }
  #settings .inner-tabs {
    flex-direction: column;
  }
  #settings .inner-tabs .tab-btn {
    width: 100%;
    justify-content: center;
    border-radius: var(--radius-sm);
  }
  #settings .inner-tabs .tab-btn.active {
    border-bottom: none;
    background: var(--primary);
    color: white;
  }
  .theme-selector {
    flex-direction: column;
  }
  .theme-option {
    width: 100%;
    justify-content: center;
  }
  .security-form {
    max-width: 100%;
  }
  .security-form .btn {
    width: 100%;
    justify-content: center;
  }
  .settings-card {
    padding: 16px;
  }
}
@media (max-width: 600px) {
  .filter-row {
    flex-direction: column;
  }
  .filter-row select {
    width: 100%;
    min-width: unset;
  }
  .form-row {
    flex-direction: column;
  }
  .form-row>* {
    flex: 1 1 auto;
    width: 100%;
    min-width: unset;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .pricing-type-group {
    min-width: unset;
    max-width: 100%;
  }
  .report-actions {
    flex-direction: column;
    width: 100%;
  }
  .report-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card {
    padding: 14px;
  }
  .stat-card strong {
    font-size: 1.2rem;
  }
}
@media (max-width: 480px) {
  .stats-mini-grid {
    grid-template-columns: 1fr 1fr;
  }
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
  .main-header h2 {
    font-size: 1rem;
  }
  .user-badge {
    font-size: 0.7rem;
    padding: 4px 10px;
  }
  .btn {
    font-size: 0.75rem;
    padding: 8px 14px;
  }
  .btn-sm {
    font-size: 0.65rem;
    padding: 4px 10px;
  }
  body {
    font-size: 13px;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .customer-stock-grid {
    grid-template-columns: 1fr;
  }
  .stock-card {
    padding: 16px;
  }
  .stock-card .detail-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .stock-actions {
    flex-direction: column;
  }
  .stock-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .modal {
    max-width: 100%;
    max-height: 95vh;
    margin: 8px;
    border-radius: var(--radius-sm);
  }
  .modal-header {
    padding: 12px 16px;
  }
  .modal-header h3 {
    font-size: 1rem;
  }
  .modal-body {
    padding: 14px;
    font-size: 0.8rem;
  }
  .modal-footer {
    padding: 12px 16px;
    flex-direction: column;
  }
  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
  .small-modal {
    max-width: 100%;
  }
}

/* ===== مخفی کردن اسکرول‌بار ===== */
.main-content,
.sidebar,
.table-wrapper,
.customer-stock-grid,
.modal-body,
.cart-items-container,
.log-box {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.main-content::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar,
.customer-stock-grid::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.cart-items-container::-webkit-scrollbar,
.log-box::-webkit-scrollbar {
  display: none;
}
/* ===== گزارشات: خط قرمز مبنا و بخش حذف‌شده ===== */
.baseline-separator-row td {
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
}
.baseline-separator-cell {
  padding: 14px 8px !important;
  display: flex !important;
  align-items: center;
  gap: 12px;
}
.baseline-separator-line {
  height: 3px;
  background: var(--danger);
  border-radius: 2px;
  flex: 1;
}
.baseline-separator-label {
  color: var(--danger);
  font-weight: 700;
  white-space: nowrap;
  font-size: 0.85rem;
}
.deleted-section-header td {
  background: var(--primary-light) !important;
  border: none !important;
  padding: 8px 12px !important;
}
.deleted-section-label {
  color: var(--danger);
  font-weight: 700;
  text-align: center;
  font-size: 0.9rem;
}
.deleted-stats-row {
  background: var(--bg-input) !important;
  color: var(--text-main);
  opacity: 1;
}
.deleted-stats-row td {
  color: var(--text-main) !important;
  border-bottom-color: var(--border) !important;
}
.deleted-stats-row:hover {
  background: var(--primary-light) !important;
}
.deleted-badge {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}
.report-section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.report-section-header h3 {
  margin: 0;
  flex: 0 0 auto;
}
.report-filter-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
}
.report-filter-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.profit-filter-chips {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--bg-body, #f5f0eb);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.profit-chip {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  white-space: nowrap;
  line-height: 1.2;
}
.profit-chip:hover {
  background: rgba(139, 90, 43, 0.08);
  color: var(--primary);
}
.profit-chip.active {
  background: var(--primary, #8B5A2B);
  color: #fff;
  box-shadow: 0 2px 8px rgba(139, 90, 43, 0.28);
}
.profit-filter-select {
  display: none;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #ccc);
  background: var(--bg-surface, #fff);
  color: inherit;
  font-family: inherit;
  font-size: 0.9rem;
  min-width: 160px;
  max-width: 100%;
  width: 100%;
}
.report-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* گزارشات — ریسپانسیو */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .report-filter-box {
    justify-content: flex-start;
    width: 100%;
  }
  .report-section-header {
    flex-direction: column;
    align-items: stretch;
  }
}
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-card {
    padding: 14px 10px;
  }
  .stat-card span {
    font-size: 0.72rem;
  }
  .stat-card strong {
    font-size: 1.05rem;
  }
  .report-section-box {
    padding: 14px;
    margin-top: 14px;
  }
  .report-actions {
    flex-direction: column;
  }
  .report-actions .btn {
    width: 100%;
    min-width: 0;
  }
  .profit-filter-chips {
    width: 100%;
    justify-content: stretch;
  }
  .profit-chip {
    flex: 1 1 0;
    text-align: center;
    padding: 10px 8px;
    font-size: 0.8rem;
  }
    .baseline-separator-label {
    font-size: 0.75rem;
    white-space: normal;
    text-align: center;
  }
  .baseline-separator-cell {
    flex-wrap: wrap;
    justify-content: center;
  }
  .deleted-section-label {
    font-size: 0.85rem;
  }
}
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .stat-card {
    padding: 12px 8px;
  }
  .stat-card strong {
    font-size: 0.98rem;
  }
  .profit-filter-chips {
    display: none;
  }
  .profit-filter-select {
    display: block;
  }
  .report-filter-label {
    width: 100%;
  }
  .report-filter-box {
    flex-direction: column;
    align-items: stretch;
  }
}
