

:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --dark: #111827;
  --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

body {
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
}

button {
  cursor: pointer;
}

input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
  outline: none;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input[readonly], input:disabled, select:disabled, textarea:disabled {
  background: #f3f4f6;
  color: #6b7280;
}

/* Login */
.login-page, #loginPage {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 45%, #2563eb 100%);
}

.login-card, .login-box {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.login-card h1, .login-box h1, .login-card h2, .login-box h2 {
  margin: 0 0 10px;
  color: var(--dark);
}

.login-card p, .login-box p {
  margin: 0 0 20px;
  color: var(--muted);
}

.login-card input, .login-box input {
  width: 100%;
  margin-bottom: 12px;
}

/* Premium Login Layout */
.premium-login-page {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(59, 130, 246, 0.35), transparent 32%),
    radial-gradient(circle at 85% 10%, rgba(14, 165, 233, 0.25), transparent 30%),
    linear-gradient(135deg, #020617 0%, #0f172a 50%, #1e3a8a 100%);
}

.login-glow {
  position: absolute;
  border-radius: 999px;
  filter: blur(20px);
  opacity: 0.42;
  pointer-events: none;
}

.login-glow-one {
  width: 280px;
  height: 280px;
  left: -90px;
  bottom: 12%;
  background: #38bdf8;
}

.login-glow-two {
  width: 360px;
  height: 360px;
  right: -120px;
  top: 8%;
  background: #2563eb;
}

.premium-login-shell {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
}

.login-intro-panel {
  padding: 44px;
  color: #fff;
  background:
    linear-gradient(160deg, rgba(37, 99, 235, 0.9), rgba(15, 23, 42, 0.55)),
    rgba(15, 23, 42, 0.68);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 34px;
}

.login-intro-panel h1 {
  margin: 8px 0 12px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.02;
  letter-spacing: -1.5px;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #bfdbfe;
}

.intro-copy {
  margin: 0;
  max-width: 420px;
  color: #dbeafe;
  line-height: 1.7;
}

.login-feature-list {
  display: grid;
  gap: 12px;
}

.login-feature-list div {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #eff6ff;
  font-weight: 700;
}

.login-feature-list span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.premium-login-box {
  max-width: none;
  border-radius: 0;
  box-shadow: none;
  padding: 44px;
  background: rgba(255, 255, 255, 0.96);
}

.login-brand.compact {
  margin-bottom: 26px;
}

.brand-mark.large {
  width: 70px;
  height: 70px;
  border-radius: 22px;
  font-size: 22px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: none;
}

.input-shell {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 0 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.input-shell:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.input-icon {
  width: 22px;
  text-align: center;
  opacity: 0.78;
}

.input-shell input {
  border: none;
  box-shadow: none !important;
  padding: 12px 0;
  background: transparent;
}

.premium-login-btn {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.3);
}

.premium-login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 36px rgba(37, 99, 235, 0.36);
}

.btn-arrow {
  font-size: 18px;
  line-height: 1;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Login UI Enhancements */
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2563eb;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.5px;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.35);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-field input {
  margin-bottom: 0;
}

.login-help {
  margin-top: 14px;
  text-align: center;
  line-height: 1.4;
}

.auth-message {
  min-height: 20px;
  margin-bottom: 12px;
}

.auth-message.error {
  color: #991b1b;
  font-weight: 700;
}

.auth-message.warning {
  color: #92400e;
  font-weight: 700;
}

.auth-message.success {
  color: #166534;
  font-weight: 700;
}

/* Main layout */
#mainPage, .main-page {
  min-height: 100vh;
  padding: 18px;
}

.topbar, .header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.topbar h1, .header-bar h1 {
  margin: 0;
  font-size: 22px;
}

.small-muted, .muted {
  color: var(--muted);
  font-size: 12px;
}

.card, .panel, .section-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.toolbar, .filter-bar, .actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.toolbar input, .toolbar select,
.filter-bar input, .filter-bar select {
  min-width: 160px;
}

/* Buttons */
.btn, button {
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
}

button:hover, .btn:hover {
  opacity: 0.92;
}

button:active, .btn:active {
  transform: translateY(1px);
}

.primary-btn, .save-btn, .login-btn {
  background: var(--primary);
  color: #fff;
}

.primary-btn:hover, .save-btn:hover, .login-btn:hover {
  background: var(--primary-dark);
}

.secondary-btn, .gray-btn {
  background: #374151;
  color: #fff;
}

.print-btn {
  background: #0f766e;
  color: #fff;
}

.edit-btn {
  background: var(--warning);
  color: #111827;
}

.delete-btn, .danger-btn {
  background: var(--danger);
  color: #fff;
}

.success-btn {
  background: var(--success);
  color: #fff;
}

/* Tables */
.table-wrap, .table-container {
  width: 100%;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 13px;
}

thead {
  background: #111827;
  color: #fff;
}

th, td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: center;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}

th {
  white-space: nowrap;
  font-weight: 700;
}

#receiptTable th:nth-child(5),
#receiptTable td:nth-child(5),
#receiptTable th:nth-child(7),
#receiptTable td:nth-child(7),
#receiptTable th:nth-child(11),
#receiptTable td:nth-child(11),
#receiptTable th:nth-child(12),
#receiptTable td:nth-child(12) {
  min-width: 125px;
  white-space: nowrap;
}

#receiptTable th:nth-child(4),
#receiptTable td:nth-child(4),
#receiptTable th:nth-child(6),
#receiptTable td:nth-child(6),
#receiptTable th:nth-child(8),
#receiptTable td:nth-child(8),
#receiptTable th:nth-child(9),
#receiptTable td:nth-child(9),
#receiptTable th:nth-child(10),
#receiptTable td:nth-child(10) {
  min-width: 95px;
  max-width: 130px;
}

#receiptTable td:nth-child(5),
#receiptTable td:nth-child(7),
#receiptTable td:nth-child(8),
#receiptTable td:nth-child(11),
#receiptTable td:nth-child(12) {
  text-align: center;
}

tbody tr:hover {
  background: #f8fafc;
}

.receipt-no {
  font-weight: 700;
  color: var(--primary-dark);
  white-space: nowrap;
}

.receipt-customer {
  font-weight: 700;
}

.net-highlight {
  display: inline-block;
  font-weight: 800;
  color: #92400e;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.row-actions button {
  padding: 7px 9px;
  font-size: 12px;
}

.checkbox-cell {
  text-align: center;
  vertical-align: middle;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #e5e7eb;
  color: #374151;
  white-space: nowrap;
}

.status-badge.ok {
  background: #dcfce7;
  color: #166534;
}

.status-badge.pending {
  background: #fef3c7;
  color: #92400e;
}

.locked-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

.empty-state {
  padding: 28px !important;
  text-align: center;
  color: var(--muted);
}

/* Pagination */
.pagination, .pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
}

.pagination button, .pager button {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}

.pagination button.active, .pager button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Modal */
.modal, .popup, .dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.62);
  padding: 20px;
}

.modal.show, .popup.show, .dialog-backdrop.show {
  display: flex;
}

.modal-content, .popup-content, .dialog {
  width: min(1100px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.35);
  padding: 18px;
}

.modal-header, .dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.close-btn {
  background: #e5e7eb;
  color: #111827;
  border-radius: 999px;
  width: 34px;
  height: 34px;
  padding: 0;
}

/* Forms */
.form-grid, .settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.form-row label, .form-grid label, .settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.form-grid input, .form-grid select, .form-grid textarea,
.settings-grid input, .settings-grid select, .settings-grid textarea {
  width: 100%;
}

/* Totals */
.total-box, .summary-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.total-box > div, .summary-box > div {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.total-box .net, .summary-box .net {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e3a8a;
  font-weight: 800;
}

/* User-friendly dashboard / edit enhancements */
.dashboard-header,
.page-header {
  align-items: flex-start;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #e0f2fe;
  color: #075985;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.loading {
  background: #fef3c7;
  color: #92400e;
}

.status-pill.success {
  background: #dcfce7;
  color: #166534;
}

.status-pill.error {
  background: #fee2e2;
  color: #991b1b;
}

.page-alert {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 600;
}

.info-card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}

.dashboard-summary {
  margin-bottom: 16px;
}

/* Premium dashboard UI */
.dashboard-header {
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(14, 165, 233, 0.08)),
    var(--panel);
}

/* Dashboard Company Logo */
.dashboard-brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dashboard-logo-box {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.dashboard-company-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  padding: 4px;
}

.dashboard-logo-fallback {
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
}

.nav-btn,
.soft-btn {
  background: #eef2ff;
  color: #1e3a8a;
  border: 1px solid #c7d2fe;
}

.nav-btn:hover,
.soft-btn:hover {
  background: #e0e7ff;
}

.dashboard-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -30px;
  width: 90px;
  height: 90px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.primary-metric {
  border-color: #bfdbfe;
}

.success-metric {
  border-color: #bbf7d0;
}

.success-metric::after {
  background: rgba(22, 163, 74, 0.1);
}

.warning-metric {
  border-color: #fde68a;
}

.warning-metric::after {
  background: rgba(245, 158, 11, 0.12);
}

.ai-only-actions {
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 12px;
}

.filter-card .section-heading,
.table-card .section-heading,
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.section-heading p {
  margin: 0;
}

.filter-grid {
  align-items: stretch;
}

.filter-grid input,
.filter-grid select {
  flex: 1 1 170px;
}

.bulk-actions {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 4px;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-card .section-heading {
  padding: 16px 16px 0;
}

.table-card .table-container {
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.table-wrap {
  -webkit-overflow-scrolling: touch;
}

.action-col {
  width: 110px;
  text-align: center;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--border);
  padding-top: 12px;
  backdrop-filter: blur(8px);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 2000;
  max-width: 360px;
  background: #111827;
  color: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
  font-weight: 600;
}

.toast.success {
  background: #166534;
}

.toast.error {
  background: #991b1b;
}

.toast.warning {
  background: #92400e;
}

button:disabled,
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none !important;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 5;
}

/* Print helpers */
@media print {
  body {
    background: #fff;
  }

  .topbar,
  .toolbar,
  .filter-bar,
  .row-actions,
  .pagination,
  .pager,
  button,
  .no-print {
    display: none !important;
  }

  .card, .panel, .section-card, .table-wrap, .table-container {
    box-shadow: none;
    border: none;
  }
}

/* Responsive */
@media (max-width: 768px) {
  #mainPage, .main-page {
    padding: 10px;
  }

  .topbar, .header-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar input, .toolbar select,
  .filter-bar input, .filter-bar select {
    width: 100%;
    min-width: 0;
  }

  th, td {
    padding: 8px 7px;
    font-size: 12px;
  }

  .modal-content, .popup-content, .dialog {
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .filter-card .section-heading,
  .table-card .section-heading,
  .section-heading {
    flex-direction: column;
  }

  .header-actions,
  .bulk-actions,
  .actions,
  .sticky-actions {
    width: 100%;
  }

  .header-actions button,
  .bulk-actions button,
  .filter-card button,
  .actions button,
  .sticky-actions button {
    flex: 1 1 auto;
  }

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

  .total-box,
  .summary-box {
    grid-template-columns: 1fr;
  }

  .table-section .section-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .table-section .section-title button {
    width: 100%;
  }

  .toast {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }
 
  .premium-login-page {
    padding: 16px;
  }

  .premium-login-shell {
    grid-template-columns: 1fr;
    border-radius: 22px;
  }

  .login-intro-panel {
    padding: 26px;
  }

  .premium-login-box {
    padding: 26px;
  }

  .login-feature-list {
    gap: 8px;
  }

  .dashboard-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .ai-only-actions {
    align-items: stretch;
  }

  .ai-only-actions button {
    width: 100%;
  }
}
@media (max-width: 480px) {
  .dashboard-summary-grid {
    grid-template-columns: 1fr;
  }
}