:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #475569;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  direction: rtl;
}

body {
  font-family: Tahoma, 'Segoe UI', 'Iranian Sans', 'B Nazanin', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* Login Screen */
/* Login Background */
#login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        linear-gradient(rgba(8, 20, 45, 0.72), rgba(8, 20, 45, 0.78)),
        url('./login-bg.webp') center center / cover no-repeat;
}

/* Login Card */
.login-card {
    width: 100%;
    max-width: 420px;
    padding: 32px 28px;
    border-radius: 28px;
    background: rgba(20, 30, 55, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    text-align: center;
}

/* Logo */
.login-logo {
    display: block;
    width: 90px;
    height: 90px;
    object-fit: contain;
    margin: 0 auto 18px;
    border-radius: 18px;
}

/* Title */
#login-title {
    margin: 0 0 10px;
    font-size: 40px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.4;
}

/* اگر متن توضیح را نگه داشتی */
#login-desc {
    display: none;
}

/* Form */
.login-card .form-group {
    margin-top: 18px;
    text-align: right;
}

.login-card label {
    display: block;
    margin-bottom: 10px;
    font-size: 15px;
    color: #d7dfef;
    font-weight: 500;
}

.login-card input {
    width: 100%;
    height: 58px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
    font-size: 16px;
    padding: 0 18px;
    outline: none;
    box-sizing: border-box;
}

.login-card input::placeholder {
    color: rgba(255,255,255,0.60);
}

/* Login Button */
#login-btn,
.login-card .btn,
.login-card .btn-primary {
    width: 100%;
    height: 58px;
    margin-top: 22px;
    border: none;
    border-radius: 18px;
    background: linear-gradient(135deg, #ff6a1a, #ff4d00);
    color: #ffffff;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    display: block;
    box-sizing: border-box;
}

/* Hover */
#login-btn:hover,
.login-card .btn:hover,
.login-card .btn-primary:hover {
    filter: brightness(1.05);
}
/* App Layout */
#app {
  display: none;
  min-height: 100vh;
}

.app-header {
  background: var(--bg-card);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Sidebar / Nav */
.nav-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s;
  min-width: 60px;
}

.nav-item.active,
.nav-item:hover {
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.nav-item span.icon {
  font-size: 1.4rem;
}

/* Main Content */
.main-content {
  padding: 16px;
  padding-bottom: 90px;
  max-width: 1200px;
  margin: 0 auto;
}

.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  font-size: 1.4rem;
}

/* Cards & Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  padding: 16px;
  border-radius: var(--radius);
  text-align: center;
}

.stat-card .label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-card .value {
  font-size: 1.3rem;
  font-weight: 700;
}

.stat-card.income .value { color: var(--success); }
.stat-card.expense .value { color: var(--danger); }
.stat-card.stock .value { color: var(--primary); }

/* Tables */
.table-container {
  overflow-x: auto;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 12px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

th {
  background: rgba(0,0,0,0.2);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

tr:hover {
  background: rgba(255,255,255,0.03);
}

tr:last-child td {
  border-bottom: none;
}

.actions {
  display: flex;
  gap: 6px;
  justify-content: flex-start;
}

/* Forms & Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-overlay.show .modal {
  transform: scale(1);
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.15rem;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Search & Filters */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-bar input {
  flex: 1;
  min-width: 180px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text);
  font-family: inherit;
}

/* Invoice items */
.invoice-items {
  margin: 16px 0;
}

.invoice-item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.invoice-item-row input,
.invoice-item-row select {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.9rem;
}

.invoice-total {
  text-align: left;
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-buy { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge-sell { background: rgba(59, 130, 246, 0.2); color: var(--primary); }
.badge-receipt { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge-payment { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 300;
  opacity: 0;
  transition: all 0.3s;
  border: 1px solid var(--border);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* Responsive */
@media (max-width: 600px) {
  .invoice-item-row {
    grid-template-columns: 1fr 1fr;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  th, td {
    padding: 10px 8px;
    font-size: 0.85rem;
  }
}

/* Number formatting */
.num {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  display: inline-block;
}

/* Settings page */
.settings-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.settings-section h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.danger-zone {
  border: 1px solid var(--danger);
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* Login Background */
#login-screen {
    min-height: 100vh;
    background:
        linear-gradient(
            rgba(8, 20, 45, 0.72),
            rgba(8, 20, 45, 0.78)
        ),
        url('./login-bg.webp') center center / cover no-repeat;
}	

/* Polymer prices table fix */
#polymer-prices-table {
    min-width: 700px;
    width: 100%;
    table-layout: fixed;
}

#polymer-prices-table th,
#polymer-prices-table td {
    white-space: nowrap;
    text-align: center;
    vertical-align: middle;
}

#polymer-prices-table td.num {
    direction: rtl;
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
