@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg-canvas: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-dark: #090d16;
  --bg-header: #0f172a;

  --border: #e2e8f0;
  --border-default: #cbd5e1;
  --border-strong: #94a3b8;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-inverse: #ffffff;

  --emerald-600: #059669;
  --emerald-700: #047857;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --amber-600: #d97706;
  --amber-700: #b45309;
  --crimson-600: #dc2626;
  --crimson-700: #b91c1c;
  --purple-600: #7e22ce;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --font-sans: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.5;
  direction: rtl;
  text-align: right;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.num, .number-large, .calc-box-value {
  font-variant-numeric: tabular-nums;
}

.container {
  width: 100%;
  max-width: 1260px;
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;
}

.login-overlay {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 30%, #1e293b 0%, #090d16 100%);
  position: relative;
}

.login-card {
  background: #ffffff;
  width: 100%;
  max-width: 620px;
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
  text-align: right;
  box-sizing: border-box;
}

.login-accounts-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
}

.account-selector-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: #ffffff;
  border: 2px solid var(--border-default);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: right;
  transition: all 0.15s ease-in-out;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}

.account-selector-btn:hover {
  background: #f8fafc;
  border-color: var(--emerald-600);
  transform: translateY(-1px);
}

.account-selector-btn.active {
  border-color: var(--emerald-600);
  background: #ecfdf5;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.acc-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.acc-text {
  flex: 1;
}

.acc-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.acc-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1.4;
}

.header {
  background-color: var(--bg-header);
  color: var(--text-inverse);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 16px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
}

.logo-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: #ffffff;
  line-height: 1.3;
}

.logo-subtitle {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 600;
}

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

.notify-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

.notify-pill.pending {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1d4ed8;
}

.notify-pill.rejected {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #dc2626;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 6px 12px;
  border-radius: var(--radius-md);
}

.user-badge-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.user-badge-icon.badge-storage { background: #059669; }
.user-badge-icon.badge-accounting { background: #2563eb; }
.user-badge-icon.badge-owner { background: #7e22ce; }

.user-badge-info .role-label {
  font-size: 0.68rem;
  color: #94a3b8;
  font-weight: 600;
  line-height: 1.1;
}

.user-badge-info .role-title {
  font-size: 0.85rem;
  color: #ffffff;
  font-weight: 800;
  line-height: 1.2;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  border: 1px solid transparent;
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
  padding: 10px 18px;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-secondary);
  border: 1.5px solid var(--border-default);
  padding: 9px 16px;
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-danger {
  background: #dc2626;
  color: #ffffff;
  padding: 9px 16px;
}

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

.btn-dark {
  background: #0f172a;
  color: #ffffff;
  padding: 9px 16px;
}

.btn-dark:hover {
  background: #1e293b;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 24px;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
}

.tabs-container {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(241, 245, 249, 0.7);
  border-radius: 8px 8px 0 0;
}

.tab-btn.active {
  color: var(--emerald-600);
  border-bottom-color: var(--emerald-600);
  background: #f0fdf4;
  border-radius: 8px 8px 0 0;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 900;
  background: var(--border-default);
  color: var(--text-secondary);
}

.tab-btn.active .tab-badge {
  background: var(--emerald-600);
  color: #ffffff;
}

.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--bg-subtle);
  flex-wrap: wrap;
  gap: 10px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text-primary);
}

.card-title svg {
  color: var(--emerald-600);
  flex-shrink: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

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

.form-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 14px;
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--text-primary);
  transition: all 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--emerald-600);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.form-input.number-large {
  font-size: 1.25rem;
  font-weight: 800;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.calc-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  padding: 18px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1.5px solid #a7f3d0;
  border-radius: var(--radius-lg);
  margin-top: 16px;
  margin-bottom: 8px;
}

.calc-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.calc-box.highlight {
  border: 2px solid var(--emerald-600);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.1);
}

.calc-box-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.calc-box-value {
  font-size: 1.85rem;
  font-weight: 900;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.2;
}

.calc-box-desc {
  font-size: 0.72rem;
  color: var(--text-light);
  font-weight: 600;
}

.defects-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.defect-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 20px;
  border: 1.5px solid var(--border-default);
  background: #ffffff;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  font-family: inherit;
}

.defect-tag:hover {
  border-color: var(--amber-600);
  background: #fffbeb;
  color: var(--amber-700);
}

.defect-tag.selected {
  border-color: var(--amber-600);
  background: #fef3c7;
  color: #92400e;
  font-weight: 800;
  box-shadow: 0 2px 4px rgba(217, 119, 6, 0.15);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.88rem;
}

.table th {
  background: var(--bg-canvas);
  padding: 12px 14px;
  font-weight: 800;
  color: var(--text-secondary);
  border-bottom: 1.5px solid var(--border-default);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-weight: 600;
  vertical-align: middle;
}

.table tr:hover td {
  background: #f8fafc;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge.confirmed {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.status-badge.pending {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.status-badge.rejected {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-container {
  background: #ffffff;
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
}

@media print {
  .no-print, header, .header, .tabs-container, button, .chat-widget-container {
    display: none !important;
  }

  body, html {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .print-area {
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
}

.chat-widget-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 95;
  font-family: 'Vazirmatn', sans-serif;
}

.chat-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  border: 3px solid #ffffff;
  box-shadow: 0 10px 25px -5px rgba(5, 150, 105, 0.55), 0 8px 10px -6px rgba(15, 23, 42, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 14px 28px -5px rgba(5, 150, 105, 0.65), 0 10px 12px -6px rgba(15, 23, 42, 0.3);
}

.chat-fab-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 900;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.5);
}

.chat-popup {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.32);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 98;
}

.chat-popup.open {
  display: flex;
}

.chat-popup-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.chat-popup-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.98rem;
  font-weight: 900;
}

.chat-popup-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-clear-btn {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  transition: all 0.15s ease;
}

.chat-clear-btn:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

.chat-close-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

.chat-partner-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px 10px;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.chat-partner-tab {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  transition: all 0.15s ease;
}

.chat-partner-tab.active {
  background: #059669;
  color: #ffffff;
  border-color: #047857;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}

.chat-partner-unread {
  background: #ef4444;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 900;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-empty-state {
  margin: auto;
  text-align: center;
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 24px 16px;
}

.chat-bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  position: relative;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.chat-bubble.sent {
  align-self: flex-start;
  background: #dcfce7;
  color: #064e3b;
  border: 1px solid #86efac;
  border-bottom-right-radius: 4px;
}

.chat-bubble.received {
  align-self: flex-end;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-bottom-left-radius: 4px;
}

.chat-bubble-sender {
  font-size: 0.72rem;
  font-weight: 900;
  margin-bottom: 3px;
  color: #047857;
}

.chat-bubble.received .chat-bubble-sender {
  color: #2563eb;
}

.chat-bubble-text {
  font-weight: 600;
  white-space: pre-wrap;
}

.chat-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 5px;
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 700;
  direction: ltr;
}

.chat-checkmarks {
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: -2px;
}

.chat-checkmarks.sent {
  color: #64748b;
}

.chat-checkmarks.read {
  color: #0284c7;
}

.chat-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.chat-input-field {
  flex: 1;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.88rem;
  font-family: inherit;
  font-weight: 600;
  outline: none;
  color: #0f172a;
  background: #f8fafc;
}

.chat-input-field:focus {
  border-color: #059669;
  background: #ffffff;
}

.chat-send-btn {
  background: #059669;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  transition: background 0.15s ease;
}

.chat-send-btn:hover {
  background: #047857;
}

@media (max-width: 768px) {
  .login-card {
    padding: 24px 18px;
  }

  .header-content {
    flex-direction: column;
    height: auto;
    padding: 12px 0;
    gap: 10px;
  }

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

  .calc-banner {
    grid-template-columns: 1fr;
  }

  .chat-widget-container {
    bottom: 18px;
    right: 18px;
  }

  .chat-popup.open {
    position: fixed;
    inset: 0;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    z-index: 200;
  }
}

