:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --emerald: #059669;
  --emerald-dark: #047857;
  --text: #1e293b;
  --muted: #64748b;
  --ok: #16a34a;
  --err: #dc2626;
  --warn: #d97706;
  --border: #e2e8f0;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  background: #f8fafc;
  color: var(--text);
  line-height: 1.5;
}

/* TOPBAR / NAVIGATION */
.topbar {
  background: var(--bg);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 32px;
}
.topbar .brand {
  color: white;
  font-weight: 800;
  font-size: 1.3rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.5px;
}
.brand-icon {
  font-size: 1.4rem;
  color: #fbbf24;
}
.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.main-nav a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  transition: all 0.15s ease;
}
.main-nav a:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}
.main-nav a.active {
  color: white;
  background: rgba(255, 255, 255, 0.14);
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-quick {
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.btn-quick span {
  font-size: 1.1rem;
  line-height: 1;
}
.btn-quick-pos {
  background: var(--primary);
  color: white;
}
.btn-quick-pos:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}
.btn-quick-b2b {
  background: var(--emerald);
  color: white;
}
.btn-quick-b2b:hover {
  background: var(--emerald-dark);
  transform: translateY(-1px);
}

.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }
h1 { margin-top: 0; }
.muted { color: var(--muted); font-size: 0.9rem; }
.muted-small { color: var(--muted); font-size: 0.8rem; display: block; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.alert-ok { background: #dcfce7; color: #166534; }
.alert-err { background: #fee2e2; color: #991b1b; }
.alert-warn { background: #fef3c7; color: #92400e; }

/* DASHBOARD HEADER & PILL */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}
.page-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 4px;
  letter-spacing: -0.5px;
}
.page-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.business-pill {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
}

/* QUICK LAUNCH HERO CARDS */
.quick-launch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.launch-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 18px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.launch-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}
.launch-card-pos {
  border-left: 5px solid var(--primary);
}
.launch-card-b2b {
  border-left: 5px solid var(--emerald);
}
.launch-icon {
  font-size: 2.2rem;
  background: #f1f5f9;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  flex-shrink: 0;
}
.launch-card-pos .launch-icon {
  background: #eff6ff;
}
.launch-card-b2b .launch-icon {
  background: #ecfdf5;
}
.launch-content h3 {
  margin: 0 0 6px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #0f172a;
}
.launch-content p {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}
.launch-btn {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
}
.launch-btn-b2b {
  color: var(--emerald);
}

/* STATS GRID */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}
.stat-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
  margin-bottom: 4px;
}
.stat-value small {
  font-size: 1.1rem;
  color: var(--muted);
}
.stat-desc {
  font-size: 0.78rem;
  color: var(--muted);
}
.stat-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  display: inline-block;
  margin-top: 4px;
}
.stat-link:hover {
  text-decoration: underline;
}

/* DASHBOARD TABLES GRID */
.dashboard-tables-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.table-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}
.table-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.table-card-header h3 {
  margin: 0;
  font-size: 1.15rem;
  color: #0f172a;
}
.empty-state {
  text-align: center;
  padding: 30px 10px;
  color: var(--muted);
}
.empty-state p {
  margin: 0 0 12px;
}

/* CARDS & TABLES */
.cards { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  flex: 1;
  min-width: 240px;
}
.card h3 { margin-top: 0; }
.big-number { font-size: 2.4rem; font-weight: 700; margin: 4px 0; color: var(--primary); }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; display: inline-block; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-err { background: #fee2e2; color: #991b1b; }
.badge-warn { background: #fef3c7; color: #92400e; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.9rem; }
.table th { background: #f8fafc; font-weight: 700; color: #475569; }
.form { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 22px; margin-bottom: 20px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; margin-bottom: 14px; font-weight: 600; }
.form input, .form select, .form textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 400;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.actions { margin-top: 16px; }
.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  transition: all 0.15s ease;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 0.82rem;
}
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #f1f5f9; }
.btn-remove-row { background: #fee2e2; color: #991b1b; border: none; border-radius: 6px; padding: 6px 10px; cursor: pointer; }
/* Receipt & Thermal POS Print Styling */
.receipt-wrap {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}
.receipt {
  background: white;
  border: 1px solid #cbd5e1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  padding: 24px 20px;
  width: 360px;
  max-width: 100%;
  font-family: 'Courier New', Courier, monospace;
  color: #000000;
  line-height: 1.35;
}
.receipt-header {
  text-align: center;
  margin-bottom: 8px;
}
.receipt-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0 0 4px;
  text-transform: uppercase;
}
.receipt-subtitle {
  font-size: 0.85rem;
  font-weight: 700;
  margin: 4px 0 8px;
  letter-spacing: 1px;
}
.receipt-meta {
  font-size: 0.8rem;
  margin: 2px 0;
  color: #1e293b;
}
.receipt hr {
  border: none;
  border-top: 1px dashed #475569;
  margin: 8px 0;
}
.receipt-info {
  font-size: 0.8rem;
  margin: 3px 0;
  display: flex;
  justify-content: space-between;
}
.receipt-items, .receipt-totals {
  width: 100%;
  border-collapse: collapse;
}
.receipt-items td, .receipt-totals td {
  padding: 2px 0;
  font-size: 0.82rem;
}
.receipt-items .item-name {
  font-weight: 700;
  padding-top: 4px;
}
.receipt-items .sub td {
  color: #334155;
  font-size: 0.78rem;
  padding-bottom: 4px;
}
.right { text-align: right; }
.grand td {
  font-weight: 900;
  font-size: 1.05rem;
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
  padding: 6px 0;
}
.receipt-payments {
  margin: 6px 0;
}
.receipt-payments p {
  margin: 3px 0;
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
}
.qr {
  text-align: center;
  margin-top: 12px;
}
.qr img {
  width: 160px;
  height: 160px;
  display: inline-block;
}
.qr p {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: #475569;
}
.receipt-footer {
  text-align: center;
  margin-top: 12px;
  font-size: 0.78rem;
  font-weight: 600;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 260px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.side-panel h3 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 1rem;
}
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 20px; }

/* A4 INVOICE STYLING (B2B) */
.a4-invoice-container {
  background: white;
  max-width: 850px;
  margin: 0 auto 30px;
  padding: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #1e293b;
}
.a4-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.company-name {
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 6px;
}
.company-details {
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.5;
  margin: 0;
}
.a4-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #059669;
  letter-spacing: 1px;
}
.a4-inv-number {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  margin: 4px 0 8px;
}
.a4-dates {
  font-size: 0.85rem;
  color: #475569;
}
.a4-dates p {
  margin: 2px 0;
}
.a4-divider {
  border: none;
  border-top: 2px solid #e2e8f0;
  margin: 18px 0;
}
.a4-parties-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}
.party-box {
  background: #f8fafc;
  padding: 16px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}
.party-title {
  font-size: 0.75rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.party-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
}
.party-info {
  font-size: 0.85rem;
  color: #334155;
  line-height: 1.5;
  margin: 0;
}
.a4-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}
.a4-items-table th {
  background: #0f172a;
  color: white;
  padding: 10px 12px;
  font-size: 0.85rem;
  text-align: left;
}
.a4-items-table td {
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.9rem;
}
.a4-totals-section {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  align-items: start;
  margin-bottom: 30px;
}
.notes-box {
  background: #f8fafc;
  padding: 14px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}
.a4-totals-table {
  width: 100%;
  border-collapse: collapse;
}
.a4-totals-table td {
  padding: 6px 0;
  font-size: 0.95rem;
}
.a4-grand-total td {
  font-size: 1.25rem;
  font-weight: 800;
  color: #059669;
  border-top: 2px solid #0f172a;
  border-bottom: 2px solid #0f172a;
  padding: 10px 0;
}
.a4-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
  padding-top: 20px;
}
.sig-box {
  width: 220px;
  text-align: center;
}
.sig-box p {
  font-size: 0.85rem;
  color: #475569;
  margin-bottom: 40px;
}
.sig-line {
  border-top: 1px dashed #94a3b8;
  margin-bottom: 6px;
}
.sig-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}
.a4-footer-note {
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 30px;
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
}

/* Preview Modal (para-shikimi para printimit/fiskalizimit) */
.preview-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 30px 16px;
}
.preview-modal-box {
  background: #f1f5f9;
  border-radius: 12px;
  max-width: 900px;
  width: 100%;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.preview-modal-title {
  text-align: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #0f172a;
  margin: 0 0 16px;
}
.preview-modal-content {
  display: flex;
  justify-content: center;
}
.preview-modal-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 20px;
}

/* Thermal & A4 Print Optimizations */
@media print {
  @page {
    margin: 8mm;
    size: auto;
  }
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .topbar, .side-panel, .footer, .btn, .actions, .alert, .brand, nav, .no-print {
    display: none !important;
  }
  .container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .receipt-wrap {
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
  }
  .receipt {
    width: 80mm !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 6mm 4mm !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    font-size: 11pt !important;
    color: #000000 !important;
  }
  .a4-invoice-container {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
  }
  .qr img {
    width: 140px !important;
    height: 140px !important;
  }
}

/* Responsive tweaks */
@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px 16px;
  }
  .topbar-left {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .main-nav {
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .topbar-actions {
    justify-content: stretch;
  }
  .btn-quick {
    flex: 1;
    justify-content: center;
  }
  .quick-launch-grid,
  .dashboard-tables-grid,
  .a4-parties-grid,
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* LOGIN / AUTH */
.user-badge {
  color: #cbd5e1;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  white-space: nowrap;
}
.logout-form { display: inline-flex; }
.btn-quick-logout {
  background: #334155;
  color: white;
  border: none;
  cursor: pointer;
  font: inherit;
}
.btn-quick-logout:hover {
  background: #1e293b;
  transform: translateY(-1px);
}
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}
.login-wrap {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.5rem;
  color: #0f172a;
  margin-bottom: 4px;
}
.login-subtitle {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 24px;
}
.login-form {
  display: flex;
  flex-direction: column;
}
.login-form label {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #334155;
}
.login-form input {
  font: inherit;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 18px;
}
.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.btn-login {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 13px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-login:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}
.login-footer {
  margin: 18px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* ADMIN PANEL */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}
.form-grid label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #334155;
}
.form-grid input {
  width: 100%;
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
}
.form-grid select {
  width: 100%;
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: white;
}
.btn-small {
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  cursor: pointer;
}
.btn-small:hover {
  background: #f1f5f9;
}
.actions-cell {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 18px;
}
.alert-ok {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
.alert-err {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  background: #e2e8f0;
  color: #475569;
  white-space: nowrap;
}
.badge-ok {
  background: #dcfce7;
  color: #166534;
}
.badge-warn {
  background: #fef3c7;
  color: #92400e;
}
.badge-err {
  background: #fee2e2;
  color: #991b1b;
}
@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}
