:root {
  --bg: #0a0f1a;
  --bg-card: #111827;
  --bg-hover: #1e293b;
  --border: #1e3a5f;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #f59e0b;
  --primary-hover: #d97706;
  --gold: #fbbf24;
  --gold-glow: rgba(251, 191, 36, 0.15);
  --income: #22c55e;
  --income-bg: rgba(34, 197, 94, 0.1);
  --expense: #ef4444;
  --expense-bg: rgba(239, 68, 68, 0.1);
  --balance: #f59e0b;
  --balance-bg: rgba(245, 158, 11, 0.12);
  --today: #3b82f6;
  --today-bg: rgba(59, 130, 246, 0.1);
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 100% 0%, rgba(245, 158, 11, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 0% 100%, rgba(59, 130, 246, 0.05) 0%, transparent 50%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.app {
  display: flex;
  min-height: 100vh;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.sync-status {
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  min-width: 88px;
  text-align: center;
  white-space: nowrap;
}

.sync-status.online { border-color: var(--income); color: var(--income); }
.sync-status.saving { border-color: var(--primary); color: var(--gold); }
.sync-status.offline { color: var(--text-muted); }
.sync-status.need-login { border-color: var(--primary); color: var(--gold); }
.sync-status.error { border-color: var(--expense); color: var(--expense); }

.btn-save-now {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.bulk-add-card {
  margin-top: 16px;
}

.bulk-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.bulk-textarea {
  width: 100%;
  min-height: 140px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
}

.bulk-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-logout {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 100% 0%, rgba(245, 158, 11, 0.1) 0%, transparent 50%);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  border: 2px solid var(--primary);
  margin-bottom: 16px;
}

.login-card h1 {
  background: linear-gradient(135deg, var(--gold), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.login-card > p {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.login-btn {
  width: 100%;
  margin-top: 8px;
}

.login-error {
  color: var(--expense);
  font-size: 0.85rem;
  min-height: 20px;
  margin-top: 8px;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.logo-img {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--primary);
  box-shadow: 0 0 16px var(--gold-glow);
  background: #0f172a;
}

.logo-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo h1 {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.shop-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--gold-glow);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--gold);
  margin-bottom: 4px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-align: right;
}

.nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-btn.active {
  background: linear-gradient(135deg, var(--primary), #b45309);
  color: #0a0f1a;
  font-weight: 600;
}

.nav-icon {
  font-size: 1.1rem;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Main */
.main {
  flex: 1;
  margin-right: 260px;
  padding: 32px;
  max-width: 1200px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}

.header h2 {
  font-size: 1.75rem;
  font-weight: 700;
}

.header p {
  color: var(--text-muted);
  margin-top: 4px;
}

.header-date {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Pages */
.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-card.income { border-color: rgba(16, 185, 129, 0.3); background: var(--income-bg); }
.stat-card.expense { border-color: rgba(239, 68, 68, 0.3); background: var(--expense-bg); }
.stat-card.balance { border-color: rgba(245, 158, 11, 0.35); background: var(--balance-bg); }
.stat-card.today { border-color: rgba(59, 130, 246, 0.3); background: var(--today-bg); }
.stat-card.today h3 { color: var(--today); }
.stat-card.today .stat-icon { color: var(--today); }

.shop-banner {
  background: linear-gradient(135deg, #111827 0%, #1a2332 50%, rgba(245, 158, 11, 0.08) 100%);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.shop-banner-content {
  display: flex;
  align-items: center;
  gap: 20px;
}

.banner-logo {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  border: 2px solid var(--primary);
  box-shadow: 0 0 24px var(--gold-glow);
}

.shop-banner h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 4px;
}

.shop-banner p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.quick-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.quick-btn.income:hover {
  border-color: var(--income);
  background: var(--income-bg);
}

.quick-btn.expense:hover {
  border-color: var(--expense);
  background: var(--expense-bg);
}

.quick-btn span:first-child {
  font-size: 1.2rem;
}

.monthly-legend {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

.legend-dot.income { background: var(--income); }
.legend-dot.expense { background: var(--expense); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--bg-hover);
}

.stat-card.income .stat-icon { color: var(--income); }
.stat-card.expense .stat-icon { color: var(--expense); }
.stat-card.balance .stat-icon { color: var(--balance); }

.stat-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stat-card h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2px;
}

.stat-card.income h3 { color: var(--income); }
.stat-card.expense h3 { color: var(--expense); }
.stat-card.balance h3 { color: var(--balance); }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.dashboard-grid,
.reports-grid,
.categories-grid {
  display: grid;
  gap: 24px;
}

.dashboard-grid {
  grid-template-columns: 1fr 1fr;
}

.reports-grid {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 24px;
}

.categories-grid {
  grid-template-columns: 1fr 1fr 1fr;
}

/* Transactions */
.transaction-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.transaction-list.full {
  max-height: 600px;
  overflow-y: auto;
}

.transaction-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}

.transaction-item:hover {
  border-color: var(--border);
}

.transaction-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.transaction-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.transaction-icon.income { background: var(--income-bg); color: var(--income); }
.transaction-icon.expense { background: var(--expense-bg); color: var(--expense); }

.transaction-details h4 {
  font-size: 0.95rem;
  font-weight: 500;
}

.transaction-details p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.transaction-amount {
  text-align: left;
  font-weight: 600;
  font-size: 1rem;
}

.transaction-amount.income { color: var(--income); }
.transaction-amount.expense { color: var(--expense); }

.transaction-actions {
  display: flex;
  gap: 8px;
  margin-right: 12px;
}

.delete-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.delete-btn:hover {
  border-color: var(--expense);
  color: var(--expense);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

/* Chart */
.chart-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chart-bar-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chart-bar-label {
  width: 100px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.chart-bar-track {
  flex: 1;
  height: 24px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--gold));
  border-radius: 6px;
  transition: width 0.5s ease;
  min-width: 4px;
}

.chart-bar-fill.expense {
  background: linear-gradient(90deg, var(--expense), #f87171);
}

.chart-bar-value {
  width: 80px;
  text-align: left;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Forms */
.form-card {
  max-width: 600px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.type-toggle {
  display: flex;
  gap: 8px;
}

.type-btn {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.type-btn.active[data-type="income"] {
  background: var(--income-bg);
  border-color: var(--income);
  color: var(--income);
}

.type-btn.active[data-type="expense"] {
  background: var(--expense-bg);
  border-color: var(--expense);
  color: var(--expense);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* Buttons */
.btn-primary,
.btn-secondary {
  padding: 12px 24px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}

.link-btn:hover {
  text-decoration: underline;
}

/* Filters */
.filters {
  display: flex;
  gap: 8px;
}

.filters select,
.filters input {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}

/* Categories */
.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.category-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
}

.category-tag.income { border-color: rgba(16, 185, 129, 0.3); }
.category-tag.expense { border-color: rgba(239, 68, 68, 0.3); }

.category-tag button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.category-tag button:hover {
  color: var(--expense);
}

/* Report bars */
.report-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}

.report-bar-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.report-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.report-bar-track {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.report-bar-fill.income {
  height: 100%;
  background: var(--income);
  border-radius: 4px;
}

.report-bar-fill.expense {
  height: 100%;
  background: var(--expense);
  border-radius: 4px;
}

/* Monthly chart */
.monthly-chart {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  height: 200px;
  margin-top: 20px;
  padding: 0 8px;
}

.month-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.month-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  flex: 1;
  width: 100%;
}

.month-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.5s ease;
}

.month-bar.income { background: var(--income); }
.month-bar.expense { background: var(--expense); }

.month-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-group.full-width {
  grid-column: 1 / -1;
}

/* Currency */
.currency-toggle .curr-btn.active[data-curr="IQD"] {
  background: rgba(59, 130, 246, 0.15);
  border-color: #3b82f6;
  color: #60a5fa;
}

.currency-toggle .curr-btn.active[data-curr="foreign"] {
  background: var(--gold-glow);
  border-color: var(--primary);
  color: var(--gold);
}

.foreign-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.conversion-result {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(59, 130, 246, 0.08));
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  padding: 16px;
  margin-top: 8px;
}

.conversion-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.conversion-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.conversion-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
}

.conversion-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.currency-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.rate-status {
  display: inline-block;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
  margin-left: 8px;
}

.rate-status.online { border-color: var(--income); color: var(--income); }
.rate-status.manual { border-color: var(--primary); color: var(--gold); }
.rate-status.offline { border-color: var(--expense); color: var(--expense); }

.rate-updated {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.converter-card {
  margin-bottom: 24px;
}

.card-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.converter-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.swap-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--gold);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 16px;
}

.swap-btn:hover {
  background: var(--gold-glow);
  border-color: var(--primary);
  transform: rotate(180deg);
}

.conv-result-box {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gold);
  min-height: 48px;
  display: flex;
  align-items: center;
}

.conv-rate-info {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.hint-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.rates-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rate-row {
  display: grid;
  grid-template-columns: 140px 1fr 1fr 120px 100px;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}

.rate-row:hover {
  border-color: var(--border);
}

.rate-row.header {
  background: transparent;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 16px;
}

.rate-currency {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.rate-value {
  font-size: 0.9rem;
}

.rate-value.online-val {
  color: var(--text-muted);
}

.rate-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.rate-input:focus {
  outline: none;
  border-color: var(--primary);
}

.rate-input.has-override {
  border-color: var(--primary);
  background: var(--gold-glow);
}

.rate-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
}

.rate-badge.online { background: var(--income-bg); color: var(--income); }
.rate-badge.manual { background: var(--balance-bg); color: var(--gold); }
.rate-badge.none { background: var(--expense-bg); color: var(--expense); }

.rate-clear-btn {
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.rate-clear-btn:hover {
  border-color: var(--expense);
  color: var(--expense);
}

.tx-foreign-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Inventory */
.inventory-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}

.inventory-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.inv-product-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 520px;
  overflow-y: auto;
}

.inv-product-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}

.inv-product-row:hover {
  border-color: var(--border);
}

.inv-product-row.low-stock {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.05);
}

.inv-product-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.inv-product-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.inv-product-info h4 {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-brand {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.inv-product-info p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.inv-product-prices {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.inv-stock-badge {
  text-align: center;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--bg-hover);
  min-width: 70px;
}

.inv-stock-badge strong {
  display: block;
  font-size: 1.3rem;
}

.inv-stock-badge span {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.inv-stock-badge em {
  display: block;
  font-size: 0.65rem;
  color: var(--expense);
  font-style: normal;
  margin-top: 2px;
}

.inv-stock-badge.ok strong { color: var(--income); }
.inv-stock-badge.low strong { color: var(--expense); }
.inv-stock-badge.empty strong { color: var(--text-muted); }

.inv-product-actions {
  display: flex;
  gap: 6px;
}

.inv-action-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.inv-action-btn.in:hover { border-color: var(--income); background: var(--income-bg); }
.inv-action-btn.out:hover { border-color: var(--expense); background: var(--expense-bg); }
.inv-action-btn.edit:hover { border-color: var(--primary); background: var(--gold-glow); }
.inv-action-btn.del:hover { border-color: var(--expense); color: var(--expense); }

.inv-movement-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 400px;
  overflow-y: auto;
}

.inv-movement-row {
  display: grid;
  grid-template-columns: 90px 1fr 60px 90px 100px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.85rem;
}

.inv-mov-type {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  text-align: center;
}

.inv-mov-type.in { background: var(--income-bg); color: var(--income); }
.inv-mov-type.out { background: var(--expense-bg); color: var(--expense); }
.inv-mov-type.adjust { background: var(--balance-bg); color: var(--gold); }

.inv-mov-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.inv-mov-info strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-mov-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.inv-mov-qty {
  font-weight: 700;
  text-align: center;
}

.inv-mov-balance {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.inv-mov-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: left;
}

.inv-dash-grid {
  margin-top: 24px;
}

.inv-dash-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.inv-dash-stats div {
  text-align: center;
  padding: 16px 10px;
  background: var(--bg);
  border-radius: 8px;
}

.inv-dash-stats span {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.inv-dash-stats strong {
  font-size: 1.2rem;
  color: var(--gold);
}

.inv-dash-stats div.warn strong {
  color: var(--expense);
}

.inv-alert-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inv-alert-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  font-size: 0.9rem;
}

.inv-alert-qty {
  font-weight: 700;
  color: var(--expense);
  font-size: 0.85rem;
}

.field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Sales / قائمة بيع */
.sales-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
  align-items: start;
}

.sale-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  max-height: 560px;
  overflow-y: auto;
  padding: 4px;
}

.sale-product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  color: var(--text);
  text-align: center;
}

.sale-product-card:hover {
  border-color: var(--primary);
  background: var(--gold-glow);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.sale-in-cart {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--primary);
  color: #0a0f1a;
  font-weight: 700;
  font-size: 0.75rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sale-prod-icon {
  font-size: 2rem;
}

.sale-product-card strong {
  font-size: 0.85rem;
  line-height: 1.3;
}

.sale-prod-brand {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.sale-prod-price {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gold);
}

.sale-prod-stock {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sales-cart {
  position: sticky;
  top: 20px;
}

.sale-cart-badge {
  background: var(--gold-glow);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--gold);
}

.sale-cart-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.sale-empty {
  padding: 30px 10px !important;
}

.sale-cart-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
}

.sale-cart-info strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.sale-cart-price-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sale-price-input {
  width: 80px;
  padding: 4px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}

.sale-cart-qty {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sale-cart-qty button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
}

.sale-cart-qty button:hover {
  border-color: var(--primary);
  color: var(--gold);
}

.sale-cart-qty span {
  min-width: 20px;
  text-align: center;
  font-weight: 600;
}

.sale-cart-line-total {
  font-weight: 700;
  color: var(--income);
  font-size: 0.9rem;
  white-space: nowrap;
}

.sale-remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
}

.sale-remove-btn:hover {
  color: var(--expense);
}

.sale-total-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: linear-gradient(135deg, var(--gold-glow), rgba(34, 197, 94, 0.08));
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 10px;
  margin-bottom: 16px;
}

.sale-total-box span {
  color: var(--text-muted);
}

.sale-total-box strong {
  font-size: 1.5rem;
  color: var(--gold);
}

.sale-pay-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.sale-actions {
  margin-top: 8px;
}

.btn-sale {
  flex: 1;
  font-size: 1rem;
  padding: 14px;
}

.sale-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sale-history-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 8px;
  gap: 16px;
}

.sale-hist-info strong {
  color: var(--income);
  font-size: 1.05rem;
}

.sale-hist-foreign {
  display: block;
  font-size: 0.82rem;
  color: var(--gold);
  margin-top: 2px;
}

.sale-hist-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.sale-hist-info em {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: normal;
}

.sale-hist-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.sale-hist-customer {
  display: block;
  font-size: 0.82rem;
  color: #60a5fa;
  margin-top: 2px;
}

/* Customers */
.customers-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

.customer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 600px;
  overflow-y: auto;
}

.customer-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.customer-card:hover {
  border-color: var(--primary);
  background: var(--gold-glow);
}

.customer-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #b45309);
  color: #0a0f1a;
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.customer-card-info {
  flex: 1;
  min-width: 0;
}

.customer-card-info h4 {
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.customer-card-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.customer-card-meta {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--gold);
}

.customer-last {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.customer-detail-panel {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.customer-detail-panel.open {
  display: flex;
}

.customer-detail-inner {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.cust-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.cust-detail-grid div {
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
}

.cust-detail-grid span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.cust-detail-grid strong {
  font-size: 0.9rem;
}

.cust-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.cust-history-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  gap: 12px;
}

.cust-history-item strong {
  color: var(--income);
}

.cust-history-item p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.cust-history-item span {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.cust-search-wrap {
  position: relative;
}

.cust-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 50;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 4px;
}

.cust-dropdown-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.cust-dropdown-item:last-child {
  border-bottom: none;
}

.cust-dropdown-item:hover {
  background: var(--gold-glow);
}

.cust-dropdown-item strong {
  font-size: 0.9rem;
}

.cust-dropdown-item span {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.cust-dropdown-empty {
  padding: 12px 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.sale-customer-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}

.sale-customer-box > label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.sale-customer-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 8px;
  font-size: 0.82rem;
  color: #60a5fa;
}

.cust-badge {
  background: rgba(34, 197, 94, 0.15);
  color: var(--income);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
}

.tx-customer-note {
  font-size: 0.78rem;
  color: #60a5fa;
  margin-top: 2px;
}

.export-card {
  margin-bottom: 24px;
  background: linear-gradient(135deg, #111827, rgba(245, 158, 11, 0.08));
  border-color: rgba(245, 158, 11, 0.35);
}

.export-card-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 20px;
}

.export-card h3 {
  color: var(--gold);
  margin-bottom: 6px;
}

.export-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 480px;
}

.export-filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.export-filters .form-group {
  margin-bottom: 0;
  min-width: 140px;
}

.btn-export-excel {
  white-space: nowrap;
  padding: 12px 20px;
}

.sidebar-footer .btn-primary {
  font-size: 0.85rem;
  padding: 10px 12px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 14px 24px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: all 0.3s;
  z-index: 1000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success { border-color: var(--income); }
.toast.error { border-color: var(--expense); }

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    width: 70px;
    padding: 16px 8px;
  }

  .logo div,
  .nav-label,
  .sidebar-footer .btn-secondary,
  .sidebar-footer .btn-primary,
  .shop-badge span:last-child {
    display: none;
  }

  .nav-btn {
    justify-content: center;
    padding: 12px;
  }

  .nav-icon {
    font-size: 1.25rem;
  }

  .shop-banner-content {
    flex-direction: column;
    text-align: center;
  }

  .quick-actions {
    justify-content: center;
  }

  .main {
    margin-right: 70px;
    padding: 20px;
  }

  .dashboard-grid,
  .reports-grid,
  .categories-grid,
  .inv-dash-grid,
  .form-row {
    grid-template-columns: 1fr;
  }

  .inventory-layout {
    grid-template-columns: 1fr;
  }

  .sales-layout {
    grid-template-columns: 1fr;
  }

  .sales-cart {
    position: static;
  }

  .customers-layout {
    grid-template-columns: 1fr;
  }

  .cust-detail-grid {
    grid-template-columns: 1fr;
  }

  .inv-product-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .inv-product-actions {
    justify-content: flex-end;
  }

  .inv-movement-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .inv-dash-stats {
    grid-template-columns: 1fr 1fr;
  }

  .export-card-content {
    flex-direction: column;
  }

  .export-filters {
    flex-direction: column;
    width: 100%;
  }

  .export-filters .form-group {
    width: 100%;
  }

  .filters {
    flex-direction: column;
  }

  .rate-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .rate-row.header {
    display: none;
  }

  .converter-grid {
    grid-template-columns: 1fr;
  }

  .swap-btn {
    margin: 0 auto 8px;
  }
}

/* الإعدادات والمستخدمين */
.user-badge {
  font-size: 0.85rem;
  color: var(--gold);
  padding: 6px 12px;
  background: rgba(212, 175, 55, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(212, 175, 55, 0.25);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.settings-card {
  padding: 24px;
}

.settings-card h3 {
  margin-bottom: 16px;
  color: var(--gold);
}

.settings-form .form-group {
  margin-bottom: 14px;
}

.users-admin {
  margin-top: 8px;
}

.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.user-row .muted {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-right: 8px;
}

.user-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.user-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-danger {
  background: rgba(220, 53, 69, 0.15);
  color: #ff6b7a;
  border: 1px solid rgba(220, 53, 69, 0.35);
}

.badge-ok {
  color: #4ade80;
}

.badge-off {
  color: #f87171;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin: 12px 0 16px;
}

.perm-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}
