/* ===== EURO BODEN — SHARED STYLES ===== */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --surface3: #eef2f7;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-glow: rgba(37,99,235,0.10);
  --text: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --success: #059669;
  --success-bg: rgba(5,150,105,0.10);
  --danger: #dc2626;
  --danger-bg: rgba(220,38,38,0.10);
  --warning: #d97706;
  --warning-bg: rgba(217,119,6,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 18px 48px rgba(15,23,42,0.12);
  --shadow-sm: 0 8px 22px rgba(15,23,42,0.08);
  --transition: 0.18s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  font-size: 14px;
}
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; font-family: inherit; }
button { cursor: pointer; }
a { text-decoration: none; color: inherit; }
input, select, textarea { outline: none; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ===== UTILITY ===== */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.tabular-nums { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-through { text-decoration: line-through; }
.whitespace-nowrap { white-space: nowrap; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }

/* ===== PAGE WRAPPER ===== */
.page-wrap {
  padding: 1.5rem;
  width: 100%;
  max-width: none;
  margin: 0;
}
@media (max-width: 640px) { .page-wrap { padding: 1rem; } }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-header-left { display: flex; align-items: center; gap: 12px; }
.page-icon {
  width: 44px; height: 44px;
  background: var(--primary-glow);
  border: 1px solid rgba(37,99,235,0.24);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}
.page-title { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.card-title { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.card-content { padding: 1.25rem; }

/* ===== INPUTS ===== */
.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.input::placeholder { color: var(--text-dim); }
.input-lg { height: 46px; font-size: 0.9rem; }

.select {
  width: 100%;
  height: 40px;
  padding: 0 34px 0 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.875rem;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238892b0' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color var(--transition);
}
.select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.select option { background: var(--surface); color: var(--text); }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

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

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), opacity var(--transition), transform 0.1s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border-light); }
.btn-outline:hover:not(:disabled) { background: var(--surface2); border-color: var(--text-dim); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); }

.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(220,38,38,0.24); }
.btn-danger:hover:not(:disabled) { background: rgba(220,38,38,0.16); }

.btn-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(5,150,105,0.24); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 0.8rem; }
.btn-lg { height: 46px; padding: 0 24px; font-size: 0.9rem; }
.btn-icon { width: 32px; height: 32px; padding: 0; }
.btn-full { width: 100%; }

/* ===== BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-primary { background: var(--primary-glow); color: var(--primary); border: 1px solid rgba(37,99,235,0.24); }
.badge-secondary { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(5,150,105,0.24); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(220,38,38,0.24); }

/* ===== STATS GRID ===== */
.stats-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.stat-card:hover { border-color: var(--border-light); box-shadow: var(--shadow-sm); }
.stat-icon {
  width: 40px; height: 40px;
  background: var(--primary-glow);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}
.stat-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1.15rem; font-weight: 700; color: var(--text); margin-top: 2px; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead { background: var(--surface2); }
th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--surface2); }
tfoot td { background: var(--surface2); font-weight: 600; border-top: 2px solid var(--border-light); }
tr.row-selected td { background: var(--primary-glow); }

/* ===== SPINNER ===== */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
.spinner-sm { width: 14px; height: 14px; }
.spinner-lg { width: 32px; height: 32px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; justify-content: center; align-items: center; padding: 3rem 0; }

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
  width: calc(100vw - 2rem);
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
  backdrop-filter: blur(10px);
}
.toast-success { background: rgba(5,150,105,0.12); border: 1px solid rgba(5,150,105,0.24); color: var(--success); }
.toast-error { background: rgba(220,38,38,0.12); border: 1px solid rgba(220,38,38,0.24); color: var(--danger); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== MODAL ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.42);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.overlay.hidden { display: none; }
.dialog {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 32rem;
  max-height: 90vh;
  overflow-y: auto;
  animation: dialogIn 0.18s ease;
}
.dialog-sm { max-width: 24rem; }
@keyframes dialogIn { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
.dialog-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dialog-header h2 { font-size: 1rem; font-weight: 600; }
.dialog-body { padding: 1.25rem 1.5rem; }
.dialog-footer {
  padding: 0.75rem 1.5rem 1.25rem;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
}

/* ===== SEARCH ===== */
.search-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
  display: flex;
}
.search-wrap .input { padding-left: 34px; padding-right: 34px; }
.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
}
.clear-btn:hover { color: var(--text); }

/* ===== DROPDOWN ===== */
.dropdown-list {
  position: absolute;
  z-index: 100;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
}
.dropdown-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--surface2); }
.item-name { font-weight: 500; font-size: 0.875rem; }
.item-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.dropdown-empty { padding: 12px; font-size: 0.85rem; color: var(--text-muted); text-align: center; }

/* ===== SUMMARY BOX ===== */
.summary-box {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.summary-box-primary {
  background: var(--primary-glow);
  border: 1px solid rgba(37,99,235,0.22);
}
.summary-box-muted {
  background: var(--surface2);
  border: 1px solid var(--border);
}
.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 3px 0;
}
.summary-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-light);
  padding-top: 8px;
  margin-top: 6px;
}
.summary-total-label { font-size: 0.875rem; font-weight: 500; color: var(--text-muted); }
.summary-total-value { font-size: 1.5rem; font-weight: 800; color: var(--primary); }

/* ===== GRID HELPERS ===== */
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; gap: 0.75rem; grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
.grid-auto { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.col-span-2 { grid-column: span 2; }
.col-span-full { grid-column: 1 / -1; }

/* ===== INVOICE ===== */
.invoice-a4 {
  background: white;
  color: #111;
  border-radius: var(--radius);
  padding: 2.5rem;
  max-width: 48rem;
  margin: 1.5rem auto;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.invoice-header { display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 2px solid #111; padding-bottom: 1.25rem; margin-bottom: 1.5rem; }
.invoice-company-info h2 { font-size: 1.5rem; font-weight: 700; }
.invoice-company-info .sub { font-size: 0.8rem; margin-top: 3px; opacity: 0.7; }
.invoice-number-block { text-align: right; }
.invoice-number-block h3 { font-size: 1.5rem; font-weight: 800; }
.invoice-buyer { margin-bottom: 1.5rem; border: 1px solid #ccc; border-radius: 6px; padding: 10px 14px; }
.invoice-buyer .label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.6; }
.invoice-buyer .name { font-size: 1rem; font-weight: 600; margin-top: 2px; }
.invoice-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.invoice-table thead tr { background: #f3f4f6; border-bottom: 2px solid #111; }
.invoice-table th { padding: 10px; text-align: left; }
.invoice-table th:nth-child(n+3) { text-align: right; }
.invoice-table td { padding: 12px 10px; border-bottom: 1px solid #e5e7eb; }
.invoice-table td:nth-child(n+3) { text-align: right; }
.invoice-totals { margin-top: 1.5rem; display: flex; justify-content: flex-end; }
.invoice-totals-box { width: 280px; border: 2px solid #111; border-radius: 6px; overflow: hidden; }
.invoice-totals-row { display: flex; justify-content: space-between; padding: 8px 14px; border-bottom: 1px solid #e5e7eb; font-size: 0.85rem; }
.invoice-totals-row:last-child { border-bottom: none; }
.invoice-totals-final { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: #111; color: white; }
.invoice-totals-final .label { font-weight: 700; font-size: 0.9rem; }
.invoice-totals-final .value { font-size: 1.2rem; font-weight: 800; }
.invoice-sigs { margin-top: 4rem; display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; font-size: 0.85rem; }
.invoice-sig { border-top: 1px solid #111; padding-top: 8px; text-align: center; }
.invoice-footer { margin-top: 2rem; text-align: center; font-size: 0.72rem; opacity: 0.6; }
.invoice-logo { width: 64px; height: 64px; object-fit: contain; }

/* ===== CHECKBOX ===== */
.checkbox { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

/* ===== REMEMBER ROW ===== */
.remember-row { display: flex; align-items: center; gap: 8px; }

/* ===== PRINT ===== */
@media print {
  body * { visibility: hidden; }
  .invoice-a4, .invoice-a4 * { visibility: visible; }
  .invoice-a4 {
    position: absolute; left: 0; top: 0;
    width: 100%; padding: 20mm;
    background: white; color: black;
    border: none; box-shadow: none;
    margin: 0; max-width: none; border-radius: 0;
  }
  .no-print { display: none !important; }
  @page { size: A4; margin: 0; }
}

/* ===== MOBILE CARD (Stock) ===== */
.stock-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.stock-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.stock-card-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  text-align: center;
}
.metric-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.metric-value { font-size: 0.875rem; font-weight: 600; margin-top: 2px; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state svg { width: 40px; height: 40px; opacity: 0.3; margin: 0 auto 12px; display: block; }
.empty-state p { font-size: 0.875rem; }


/* ===== LIGHT THEME RESPONSIVE POLISH ===== */
html { color-scheme: light; }
body { background: var(--bg); }
.card, .stat-card, .stock-card, .dialog, .dropdown-list { background: var(--surface); }
.input, .select, textarea { min-height: 42px; }
.input, .select { box-shadow: 0 1px 0 rgba(15,23,42,0.02); }
.input:disabled, .select:disabled { background: var(--surface3); color: var(--text-muted); }
.card-header { background: linear-gradient(180deg, rgba(248,250,252,0.9), rgba(255,255,255,0)); }
.table-wrap { background: var(--surface); }
@media (max-width: 760px) {
  .page-header { align-items: stretch; }
  .page-header-left { width: 100%; }
  .card-header { align-items: stretch; }
  .card-header > div { width: 100%; }
  .search-wrap, .search-wrap .input, .card-header .select { width: 100% !important; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .btn { min-height: 38px; }
}
@media print {
  html, body { background: white !important; }
  @page { size: A4; margin: 12mm; }
}

/* ===== GLASS EFFECT FOR CHILD PAGES (iframe) ===== */
/* Applied when page is inside iframe */
@media not print {
  body.glass-body {
    background: transparent !important;
  }
}

/* ===== FORCE LIGHT THEME — NO DARK MODE ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface2: #f8fafc;
    --surface3: #eef2f7;
    --border: #e2e8f0;
    --border-light: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
  }
  html { color-scheme: light !important; }
  body { background: var(--bg) !important; color: var(--text) !important; }
}
