:root {
  --primary: #0f172a;
  --primary-hover: #1e293b;
  --primary-light: #fdf2f7;
  --brand-pink: #f08bb8;
  --brand-pink-dark: #d86899;
  --brand-pink-light: #fdf2f7;
  --brand-yellow: #ffd95d;
  --brand-yellow-light: #fffbeb;
  --success: #10b981;
  --success-dark: #059669;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --bg-main: #faf8f9;
  --bg-surface: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --border: #f0e6eb;
  --border-focus: #f08bb8;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(240, 139, 184, 0.15), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px -5px rgba(240, 139, 184, 0.2), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* =========================================================
   HEADER & NAVIGATION
========================================================= */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.app-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #f08bb8, #ffd95d 50%, #f08bb8);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo-img {
  height: 38px;
  width: auto;
  display: block;
}

.brand-text-wrap {
  display: flex;
  flex-direction: column;
}

.brand h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-tagline {
  font-size: 12px;
  color: var(--text-muted);
}

.nav-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-main);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  border-bottom: 2px solid var(--brand-pink);
}

.header-status .badge {
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.header-status .badge.live {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

/* =========================================================
   MAIN LAYOUT & TABS
========================================================= */
.app-main {
  flex: 1;
  padding: 20px 24px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.tab-content {
  display: none;
}

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

.page-container {
  max-width: 1080px;
  margin: 0 auto;
}

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

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.page-header p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* =========================================================
   1. KASSA / POS VIEW
========================================================= */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 960px) {
  .pos-layout {
    grid-template-columns: 1fr;
  }
}

.pos-products-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pos-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-box input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-subtle);
  pointer-events: none;
}

.category-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.chip-btn {
  padding: 6px 14px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  border-color: var(--border-focus);
  color: var(--primary);
}

.chip-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* POS Products Grid */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.product-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: transform 0.1s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow: var(--shadow-sm);
  min-height: 140px;
  justify-content: space-between;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.product-card:active {
  transform: scale(0.96);
}

.product-card-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.product-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
  margin-bottom: 6px;
}

.product-card-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.product-card-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

.product-card-vat {
  font-size: 11px;
  color: var(--text-subtle);
}

.product-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--brand-pink);
  color: #0f172a;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 800;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(240, 139, 184, 0.4);
}

/* =========================================================
   CART & CHECKOUT COLUMN
========================================================= */
.cart-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 80px;
}

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

.cart-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.btn-text-danger {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.btn-text-danger:hover {
  background: #fee2e2;
}

.cart-items-container {
  padding: 14px 20px;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-cart-state {
  text-align: center;
  padding: 36px 12px;
  color: var(--text-muted);
}

.empty-cart-icon {
  font-size: 40px;
  margin-bottom: 10px;
  opacity: 0.6;
}

.empty-cart-state p {
  font-size: 14px;
  line-height: 1.4;
}

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}

.cart-item:last-child {
  border-bottom: none;
}

.cart-item-info {
  flex: 1;
  padding-right: 12px;
}

.cart-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.cart-item-price-unit {
  font-size: 12px;
  color: var(--text-muted);
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.1s ease;
}

.qty-btn:hover {
  border-color: var(--border-focus);
  color: var(--primary);
  background: var(--primary-light);
}

.cart-item-qty {
  font-size: 14px;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

.cart-item-total {
  font-size: 14px;
  font-weight: 700;
  min-width: 65px;
  text-align: right;
  color: var(--text-main);
}

/* Cart Summary */
.cart-summary {
  background: #f8fafc;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.summary-row.total-row {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px dashed var(--border);
}

.summary-row.total-row span:last-child {
  color: var(--success-dark);
}

/* Checkout Form */
.cart-checkout-form {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.seller-copy-notice {
  font-size: 12px;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  line-height: 1.4;
}

.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 10px;
  margin-top: 4px;
}

/* =========================================================
   COMMON UI ELEMENTS (BUTTONS, INPUTS, TABLES)
========================================================= */
.btn {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #0f172a;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-pink);
  border-color: var(--brand-pink);
  color: #0f172a;
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-large {
  padding: 13px 20px;
  font-size: 15px;
}

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

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

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

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.form-group label .required {
  color: var(--danger);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.input-with-icon {
  position: relative;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-subtle);
  pointer-events: none;
}

.input-with-icon input {
  padding-left: 36px;
}

.form-help {
  font-size: 12px;
  color: var(--text-muted);
}

.highlight-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 14px;
  border-radius: var(--radius-md);
}

/* Data Tables */
.product-management-table-card,
.history-table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: #f8fafc;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

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

.data-table tr:hover td {
  background: #fafafa;
}

/* =========================================================
   SETTINGS STYLES
========================================================= */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-card h3 {
  font-size: 16px;
  font-weight: 700;
}

.section-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -8px;
  margin-bottom: 6px;
}

.radio-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.radio-card:hover {
  border-color: var(--border-focus);
}

.radio-card input[type="radio"] {
  margin-top: 3px;
}

.radio-content strong {
  font-size: 14px;
  display: block;
}

.radio-content p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.smtp-test-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.status-msg {
  font-size: 13px;
}

.status-msg.success { color: var(--success-dark); }
.status-msg.error { color: var(--danger); }

/* =========================================================
   MODALS
========================================================= */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  animation: modalIn 0.2s ease;
}

.modal-large {
  max-width: 680px;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

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

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-main);
}

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

.modal-actions {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.receipt-preview-frame-wrap {
  width: 100%;
  height: 460px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
}

.receipt-preview-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.alert-banner {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-banner.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* =========================================================
   TOAST NOTIFICATIONS
========================================================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  background: #1e293b;
  color: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toastIn 0.25s ease forwards;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }

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