/* ═══════════════════════════════════════════════════════════════
   ANTALYA CITY INVOICE SYSTEM — Design System
   Color palette derived from the Antalya City branding
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* ─── Primary Palette (Teal from Antalya City branding) ─── */
  --primary-50:  #e8f5f3;
  --primary-100: #c5e8e3;
  --primary-200: #9dd9d0;
  --primary-300: #6dc9bc;
  --primary-400: #3dbdac;
  --primary-500: #0d8a7d;
  --primary-600: #0b7a6e;
  --primary-700: #0a6b61;
  --primary-800: #085c53;
  --primary-900: #064a43;

  /* ─── Neutral ─── */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* ─── Status Colors ─── */
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;

  /* ─── Semantic ─── */
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-focus: var(--primary-500);

  /* ─── Spacing ─── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* ─── Typography ─── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-arabic: 'Amiri', 'Traditional Arabic', serif;
  --font-mono: 'Cascadia Code', 'Fira Code', monospace;

  /* ─── Radius ─── */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* ─── Shadow ─── */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);

  /* ─── Sidebar Width ─── */
  --sidebar-width: 240px;

  /* ─── Transitions ─── */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-app);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-500); text-decoration: none; }
a:hover { color: var(--primary-700); }

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

/* ═══ UTILITIES ═══ */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

/* ═══ LOGIN SCREEN ═══ */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #064a43 0%, #0a6b61 40%, #0d8a7d 70%, #1a9e8f 100%);
  position: relative;
  overflow: hidden;
}

.login-screen::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  top: -150px;
  right: -100px;
}

.login-screen::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  bottom: -100px;
  left: -100px;
}

.login-card {
  position: relative;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 380px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.3);
}

.login-logo h1 {
  color: white;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 2px;
}

.login-logo p {
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.login-card .form-group {
  margin-bottom: 20px;
}

.login-card label {
  display: block;
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-md);
  color: white;
  font-size: 14px;
  font-family: var(--font-sans);
  transition: var(--transition-fast);
}

.login-card input:focus {
  outline: none;
  border-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.15);
}

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

.login-error {
  color: #fca5a5;
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
  min-height: 20px;
}

/* ═══ APP LAYOUT ═══ */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.06);
  z-index: 10;
}

.sidebar-header {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo {
  flex-shrink: 0;
}

.sidebar-title {
  display: flex;
  flex-direction: column;
}

.sidebar-name {
  color: white;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
}

.sidebar-sub {
  color: var(--primary-400);
  font-size: 11px;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--gray-400);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  cursor: pointer;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}

.nav-item.active {
  background: var(--primary-500);
  color: white;
  box-shadow: 0 4px 12px rgba(13,138,125,0.3);
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg {
  opacity: 1;
}

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 8px 14px;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  color: white;
  font-size: 12px;
  font-weight: 500;
}

.user-role {
  color: var(--gray-500);
  font-size: 11px;
}

.logout-btn {
  color: var(--gray-500);
  cursor: pointer;
}

.logout-btn:hover {
  color: var(--danger);
}

/* ═══ MAIN CONTENT ═══ */
.main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.page-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ═══ PAGE HEADER ═══ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

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

/* ═══ CARDS ═══ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

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

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
}

/* ═══ STAT CARDS ═══ */
.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-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition-fast);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.teal { background: var(--primary-50); color: var(--primary-500); }
.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.amber { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }

.stat-details { flex: 1; }

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 2px;
}

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
  line-height: 1.4;
}

.btn svg { flex-shrink: 0; }

.btn-primary {
  background: var(--primary-500);
  color: white;
}
.btn-primary:hover { background: var(--primary-600); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #059669; }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-warning {
  background: var(--warning);
  color: white;
}
.btn-warning:hover { background: #d97706; }

.btn-outline {
  background: transparent;
  color: var(--primary-500);
  border: 1px solid var(--primary-500);
}
.btn-outline:hover { background: var(--primary-50); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--gray-100); color: var(--text-primary); }

.btn-white {
  background: white;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-white:hover { background: var(--gray-50); }

.btn-outline-white {
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.5);
}
.btn-outline-white:hover { background: rgba(255,255,255,0.1); }

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

.btn-block {
  display: flex;
  width: 100%;
  justify-content: center;
}

.btn-icon {
  background: none;
  border: none;
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

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

/* ═══ FORMS ═══ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

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

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.form-row-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
  background: white;
  transition: var(--transition-fast);
  line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(13,138,125,0.1);
}

textarea {
  resize: vertical;
  min-height: 70px;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

input[type="search"] {
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}

.input-group {
  display: flex;
  gap: 0;
}

.input-group input {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group .btn {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* ═══ TABLES ═══ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  background: var(--gray-50);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--gray-50);
}

.data-table tbody td {
  padding: 10px 14px;
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table .actions-cell {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* ═══ STATUS BADGES ═══ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-draft { background: var(--gray-100); color: var(--gray-600); }
.badge-sent { background: var(--info-bg); color: var(--info); }
.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-accepted { background: var(--success-bg); color: var(--success); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }
.badge-expired { background: var(--gray-100); color: var(--gray-500); }
.badge-converted { background: #f5f3ff; color: #7c3aed; }
.badge-issued { background: var(--info-bg); color: var(--info); }
.badge-paid { background: var(--success-bg); color: var(--success); }
.badge-partially-paid { background: var(--warning-bg); color: var(--warning); }
.badge-unpaid { background: var(--danger-bg); color: var(--danger); }
.badge-cancelled { background: var(--gray-100); color: var(--gray-500); }

/* ═══ MODAL ═══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}

.modal-container {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
}

.modal-container.wide {
  max-width: 900px;
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

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

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══ TOAST NOTIFICATIONS ═══ */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  min-width: 280px;
  max-width: 420px;
}

.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-warning { background: var(--warning); color: white; }
.toast-info { background: var(--info); color: white; }

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100px); }
}

/* ═══ DOCUMENT PREVIEW ═══ */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.9);
  z-index: 150;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.preview-title {
  color: white;
  font-size: 15px;
  font-weight: 600;
}

.preview-actions {
  display: flex;
  gap: 8px;
}

.preview-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
}

.preview-iframe {
  width: 794px;
  height: 1123px;
  border: none;
  background: white;
  box-shadow: 0 4px 40px rgba(0,0,0,0.5);
  border-radius: 4px;
  transform-origin: top center;
}

/* ═══ DASHBOARD ═══ */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: center;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.quick-action:hover {
  border-color: var(--primary-300);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.quick-action .qa-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.quick-action .qa-icon.teal { background: var(--primary-50); color: var(--primary-500); }
.quick-action .qa-icon.blue { background: var(--info-bg); color: var(--info); }
.quick-action .qa-icon.green { background: var(--success-bg); color: var(--success); }
.quick-action .qa-icon.amber { background: var(--warning-bg); color: var(--warning); }
.quick-action .qa-icon.purple { background: #f5f3ff; color: #7c3aed; }
.quick-action .qa-icon.gray { background: var(--gray-100); color: var(--gray-600); }

/* ═══ DOCUMENT EDITOR ═══ */
.editor-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  position: sticky;
  top: -24px;
  z-index: 5;
}

.editor-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.editor-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.doc-number-display {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-600);
}

/* ─── Items Table Editor ─── */
.items-editor {
  overflow-x: auto;
}

.items-editor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.items-editor-table thead th {
  background: var(--primary-500);
  color: white;
  padding: 8px 10px;
  font-weight: 600;
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
}

.items-editor-table thead th.center { text-align: center; }
.items-editor-table thead th.right { text-align: right; }

.items-editor-table tbody tr {
  border-bottom: 1px solid var(--border);
}

.items-editor-table tbody tr:hover {
  background: var(--gray-50);
}

.items-editor-table tbody tr.section-row {
  background: var(--primary-50);
}

.items-editor-table tbody td {
  padding: 4px 6px;
  vertical-align: top;
}

.items-editor-table input,
.items-editor-table textarea,
.items-editor-table select {
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
  background: transparent;
  width: 100%;
}

.items-editor-table input:focus,
.items-editor-table textarea:focus,
.items-editor-table select:focus {
  border-color: var(--primary-300);
  background: white;
}

.items-editor-table textarea {
  min-height: 36px;
  resize: vertical;
}

.items-editor-table .sn-cell { width: 40px; text-align: center; }
.items-editor-table .desc-cell { min-width: 280px; }
.items-editor-table .qty-cell { width: 70px; }
.items-editor-table .unit-cell { width: 70px; }
.items-editor-table .rate-cell { width: 100px; }
.items-editor-table .amount-cell { width: 100px; text-align: right; }
.items-editor-table .actions-cell { width: 80px; }

.items-editor-table .amount-display {
  font-weight: 600;
  color: var(--text-primary);
  padding: 6px 8px;
  text-align: right;
}

.item-actions {
  display: flex;
  gap: 2px;
}

.items-toolbar {
  padding: 10px 0;
  display: flex;
  gap: 10px;
}

/* ─── Totals Panel ─── */
.totals-panel {
  display: flex;
  justify-content: flex-end;
  padding: 16px 0;
}

.totals-grid {
  min-width: 320px;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
}

.totals-row.grand-total {
  border-top: 2px solid var(--primary-500);
  margin-top: 8px;
  padding-top: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-700);
}

.totals-label {
  font-weight: 500;
  color: var(--text-secondary);
}

.totals-value {
  font-weight: 600;
  min-width: 120px;
  text-align: right;
}

.discount-input-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.discount-input-group input {
  width: 80px;
  padding: 4px 8px;
  font-size: 13px;
}

.discount-input-group select {
  width: 60px;
  padding: 4px;
  font-size: 12px;
}

/* ═══ FILTER BAR ═══ */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar input,
.filter-bar select {
  max-width: 200px;
}

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-secondary);
  transition: var(--transition-fast);
  font-family: var(--font-sans);
}

.filter-chip:hover { border-color: var(--primary-300); color: var(--primary-600); }
.filter-chip.active { background: var(--primary-500); color: white; border-color: var(--primary-500); }

/* ═══ TABS ═══ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-sans);
}

.tab:hover { color: var(--primary-500); }

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

.tab-content { display: none; }
.tab-content.active { display: block; }

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

.empty-state svg {
  margin: 0 auto 16px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  max-width: 300px;
  margin: 0 auto;
}

/* ═══ SETTINGS ═══ */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.file-upload {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-upload-preview {
  width: 60px;
  height: 60px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--gray-50);
}

.file-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ═══ PAYMENT PANEL ═══ */
.payment-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.payment-stat {
  padding: 14px;
  border-radius: var(--radius-md);
  text-align: center;
}

.payment-stat.total { background: var(--info-bg); }
.payment-stat.paid { background: var(--success-bg); }
.payment-stat.remaining { background: var(--warning-bg); }

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

.payment-stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ═══ REPORT ═══ */
.report-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.report-option {
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  font-family: var(--font-sans);
  text-align: left;
}

.report-option:hover {
  border-color: var(--primary-300);
  box-shadow: var(--shadow-sm);
}

.report-option.active {
  border-color: var(--primary-500);
  background: var(--primary-50);
}

.report-option .ro-title {
  font-size: 13px;
  font-weight: 600;
}

.report-option .ro-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* ═══ RESPONSIVE WITHIN WINDOW ═══ */
@media (max-width: 900px) {
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  .form-row-4 { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
