/* Laser Orders UI - dodatkowe style */
:root {
  --card-radius: 14px;
  --primary-gradient: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
}

body {
  background: #f6f7fb;
}

/* Fix dropdown menu - ensure it's hidden by default */
.dropdown-menu {
  display: none;
}
.dropdown-menu.show {
  display: block;
}

/* === LOGIN PAGE STYLES === */
body.login-body {
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
}

.login-card {
  border: none;
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.login-card .card-body {
  padding: 3.5rem 2.5rem;
  background: #ffffff;
}

.login-title {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #1a1a1a;
  margin-bottom: 0.5rem;
}

.login-subtitle {
  font-size: 0.95rem;
  color: #6c757d;
  font-weight: 500;
  margin-bottom: 1.5rem;
}

.login-form .form-label {
  color: #1a1a1a;
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
}

.login-form .form-control,
.login-form .form-control-lg {
  border: 2px solid #e9ecef;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  transition: all 0.3s ease;
  background-color: #f8f9fa;
}

.login-form .form-control:focus,
.login-form .form-control-lg:focus {
  border-color: #0d6efd;
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.login-form .btn-primary {
  background: var(--primary-gradient);
  border: none;
  border-radius: 10px;
  padding: 0.85rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(13, 110, 253, 0.3);
}

.login-form .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(13, 110, 253, 0.4);
}

.login-form .btn-primary:active {
  transform: translateY(0);
}

.login-demo-users {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  font-size: 0.85rem;
  color: #495057;
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 10px;
}

.login-demo-users div {
  padding: 0.5rem 0.75rem;
  background: #ffffff;
  border-radius: 6px;
  border-left: 3px solid #0d6efd;
}

.login-demo-users strong {
  color: #0d6efd;
  font-weight: 600;
}

.login-card .alert {
  border: none;
  border-radius: 10px;
  border-left: 4px solid #dc3545;
  margin-bottom: 1.5rem;
}

.login-card .alert-danger {
  background-color: #fff5f5;
  color: #721c24;
}

.login-card .alert-warning {
  border-left-color: #ff6c00;
  background-color: #fffbf0;
  color: #663c00;
}

@media (max-width: 576px) {
  .login-card .card-body {
    padding: 2rem 1.5rem;
  }
  
  .login-title {
    font-size: 1.5rem;
  }
  
  .login-demo-users {
    grid-template-columns: 1fr;
  }
}
/* === END LOGIN PAGE STYLES ==== */

.card {
  border-radius: var(--card-radius);
}

.card-header {
  background: #ffffff;
}

.kpi-card {
  border: 1px solid rgba(0,0,0,.06);
}

.table thead th {
  font-size: .85rem;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.badge {
  font-weight: 600;
}

.navbar-brand {
  letter-spacing: .02em;
}
.app-logo {
  height: 48px;
  width: auto;
  display: block;
  transition: transform 0.2s ease;
}
.app-logo:hover {
  transform: scale(1.05);
}
.login-logo {
  max-width: 420px;
  width: 100%;
  height: auto;
  display: inline-block;
  margin-bottom: 1rem;
  transition: transform 0.3s ease;
}
.login-logo:hover {
  transform: scale(1.02);
}
@media (max-width: 576px) {
  .app-logo { height: 36px; }
  .login-logo { max-width: 280px; }
}

.container {
  max-width: 1200px;
}

/* Custom priority color */
.bg-orange{ background-color:#fd7e14 !important; }
@media print {
  .bg-orange{ -webkit-print-color-adjust:exact; print-color-adjust:exact; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}


/* Priorytet / express */
.badge {
  letter-spacing: .02em;
}
.badge.bg-warning {
  color: #111;
}

/* Kiosk / panel produkcji */
.kiosk-wrap {
  max-width: 1100px;
}
.kiosk-timer {
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}
.kiosk-actions .btn {
  min-width: 180px;
  padding: 16px 18px;
  font-size: 1.05rem;
  font-weight: 700;
}
@media (min-width: 992px) {
  .kiosk-actions .btn {
    min-width: 220px;
    font-size: 1.15rem;
  }
}
@media print {
  .navbar, .btn, .no-print { display: none !important; }
  main.container { max-width: 100% !important; padding: 0 !important; }
}


/* --- App shell (sidebar + content) --- */
.app-shell{display:flex;min-height:calc(100vh - 56px);}
.app-shell > .grid{flex:1 1 auto;min-width:0;width:100%;}
.app-sidebar{width:260px;flex:0 0 260px;position:sticky;top:56px;height:calc(100vh - 56px);overflow:auto;}
.app-content{flex:1;min-width:0;}
/* Make tables nicer */
.table thead th{white-space:nowrap;}
.table td, .table th{vertical-align:middle;}
.table-responsive{border-radius:.5rem;}
/* Sticky header for responsive tables */
.table-sticky thead th{position:sticky;top:0;background:var(--bs-body-bg);z-index:2;}
/* Kiosk mode */
.kiosk-body{background:#0b0f14;color:#fff;}
.kiosk-content{padding:16px;max-width:1200px;margin:0 auto;}
.kiosk-card{background:#111827;border:1px solid rgba(255,255,255,.08);border-radius:16px;padding:16px;}
.kiosk-btn{font-size:1.35rem;padding:18px 20px;border-radius:16px;}
.kiosk-metric{font-size:2rem;font-weight:700;letter-spacing:.5px;}
.kiosk-sub{color:rgba(255,255,255,.7);}
body.kiosk .app-topbar{display:none;}
body.kiosk .app-shell{min-height:100vh;}
body.kiosk .app-content{padding:16px;}
body.kiosk .container-fluid.app-shell{padding-left:12px;padding-right:12px;}
/* Fold 7 (folded) */
@media (max-width: 430px) {
  .container-fluid.app-shell { padding-left: 10px; padding-right: 10px; }
  .app-sidebar { width: 100%; flex: 0 0 auto; position: static; height: auto; top: auto; }
  .erp-sidebar { margin: 8px 0; padding: 10px; }
  .app-content { padding: 10px 2px 16px; }
  .page-title { padding: 10px 12px; }
  .page-title .fs-4 { font-size: 1.05rem; }
  .list-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
  .list-group-item { padding: 8px 10px; font-size: 0.8rem; }
  .navbar .container-fluid { flex-wrap: wrap; gap: 8px; }
  .navbar-brand .brand-title { font-size: 0.95rem; }
  .table-responsive { overflow-x: auto; }
  .kiosk-wrap { max-width: 100%; }
  .kiosk-actions .btn { min-width: auto; width: 100%; }
  .kiosk-btn { font-size: 1.05rem; padding: 12px 14px; }
  .kiosk-metric { font-size: 1.5rem; }
  .kiosk-scan { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
}
/* Fold 7 + tablets */
@media (min-width: 700px) and (max-width: 1024px) {
  .container-fluid.app-shell { padding-left: 12px; padding-right: 12px; }
  .app-shell { flex-direction: column; }
  .app-shell > .grid { display: block; }
  .app-sidebar {
    width: 100%;
    flex: 0 0 auto;
    position: static;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 8px 12px;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .app-sidebar .list-group {
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .app-sidebar .list-group-item {
    flex: 0 0 auto;
    min-width: 160px;
    white-space: nowrap;
    margin-bottom: 0;
    border-radius: 12px;
    font-size: 0.9rem;
  }
  .app-sidebar .nav-chevron { display: none; }
  .app-content {
    grid-column: span 12 / span 12 !important;
    padding: 18px 16px 24px;
    width: 100%;
  }
  .erp-sidebar { padding: 10px; min-height: 0; height: auto; }
  .fold-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .kiosk-scan { padding-top: 2rem !important; padding-bottom: 2rem !important; }
  .fold-filters { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .fold-filters .md\\:col-span-2,
  .fold-filters .md\\:col-span-3,
  .fold-filters .md\\:col-span-4 {
    grid-column: auto !important;
  }
  .fold-filters .fold-actions {
    grid-column: 1 / -1 !important;
  }
}
/* Print A4 tweaks */
@media print{
  .app-navbar, .app-sidebar, .btn, .alert{display:none !important;}
  .app-shell{display:block !important;}
  .app-content{padding:0 !important;}
}

/* WOW palette */
.bg-purple{background:#6f42c1 !important;}
/* WOW row highlighting (subtle) */
tr.row-express{box-shadow: inset 6px 0 0 rgba(220,53,69,.85); background: rgba(220,53,69,.06);}
tr.row-overdue{box-shadow: inset 6px 0 0 rgba(255,193,7,.95); background: rgba(255,193,7,.08);}
tr.row-due-soon{box-shadow: inset 6px 0 0 rgba(13,110,253,.8); background: rgba(13,110,253,.05);}
tr.row-blocked{opacity:.75;}
/* Make important columns easier to scan */
td.col-order-no{font-weight:700; letter-spacing:.2px;}
.badge{font-weight:600;}



/* ERP polish */
.order-card { border-left: 6px solid rgba(13,110,253,.35); }
.order-card .badge { font-weight: 600; }
.kiosk body, body.kiosk { font-size: 18px; }
.kiosk .btn { font-size: 20px; padding: 14px 18px; }
.kiosk .card { border-radius: 14px; }
.erp-sidebar { min-height: calc(100vh - 56px); }
.table thead th { white-space: nowrap; }

/* ERP theme refresh */
:root {
  --erp-bg: #eef2f7;
  --erp-surface: #ffffff;
  --erp-surface-2: #f8fafc;
  --erp-border: #e2e8f0;
  --erp-text: #0f172a;
  --erp-muted: #64748b;
  --erp-accent: #1d4ed8;
  --erp-accent-2: #0ea5e9;
  --erp-success: #16a34a;
  --erp-warning: #f59e0b;
  --erp-danger: #dc2626;
  --erp-radius: 14px;
  --erp-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  --erp-shadow-sm: 0 6px 14px rgba(15, 23, 42, 0.08);
}

body {
  background: var(--erp-bg);
  color: var(--erp-text);
  font-family: "Segoe UI Variable", "Trebuchet MS", "Noto Sans", sans-serif;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 12% -12%, rgba(14, 165, 233, 0.18), transparent 60%),
    radial-gradient(900px 500px at 92% 0%, rgba(29, 78, 216, 0.12), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0));
  pointer-events: none;
  z-index: -1;
}

.navbar {
  background: linear-gradient(90deg, #0f172a, #1f2937);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.navbar-brand { font-weight: 800; letter-spacing: .03em; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  margin-right: 8px;
}
.brand-mark img {
  width: 32px;
  height: 32px;
  display: block;
}
.navbar-dark .navbar-text { color: rgba(255,255,255,.7); }

.container-fluid.app-shell { padding-left: 18px; padding-right: 18px; }
.erp-sidebar {
  background: var(--erp-surface);
  border: 1px solid var(--erp-border);
  border-radius: 16px;
  padding: 14px;
  margin: 16px 0;
  box-shadow: var(--erp-shadow-sm);
}
@media (min-width: 992px) {
  .erp-sidebar {
    position: sticky;
    top: 72px;
    height: calc(100vh - 88px);
    overflow: auto;
  }
}
.app-content { padding: 16px 6px 24px 6px; }

.list-group { gap: 8px; }
.list-group-item {
  border: 1px solid var(--erp-border);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--erp-text);
  background: var(--erp-surface);
}
.list-group-item-action:hover {
  background: var(--erp-surface-2);
  transform: translateY(-1px);
  box-shadow: var(--erp-shadow-sm);
}
.list-group-item.active {
  background: linear-gradient(135deg, var(--erp-accent), var(--erp-accent-2));
  color: #fff;
  border-color: transparent;
  box-shadow: var(--erp-shadow);
}

.page-title {
  background: var(--erp-surface);
  border: 1px solid var(--erp-border);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--erp-shadow-sm);
}
.page-title .fs-4 { font-weight: 800; letter-spacing: .02em; }

.card {
  border-radius: var(--erp-radius);
  border: 1px solid var(--erp-border);
  box-shadow: var(--erp-shadow-sm);
  background: var(--erp-surface);
}
.card-header {
  background: var(--erp-surface-2);
  border-bottom: 1px solid var(--erp-border);
  text-transform: uppercase;
  font-size: .75rem;
  letter-spacing: .12em;
  color: var(--erp-muted);
}
.card-body { padding: 16px; }

.kpi-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}
.kpi-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(14, 165, 233, 0.12);
  color: var(--erp-accent);
  font-size: 1.2rem;
}

.order-card { border-left: 6px solid rgba(14, 165, 233, 0.55); }
.order-card .badge { border-radius: 999px; }
.order-card .fw-semibold { letter-spacing: .01em; }

.table thead th {
  background: var(--erp-surface-2);
  color: var(--erp-muted);
  font-weight: 700;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.table tbody tr:hover { background: rgba(15, 23, 42, 0.03); }

.nav-tabs { border-bottom: 1px solid var(--erp-border); }
.nav-tabs .nav-link {
  border: 1px solid transparent;
  border-radius: 10px 10px 0 0;
  padding: 8px 14px;
  font-weight: 600;
  color: var(--erp-muted);
}
.nav-tabs .nav-link.active {
  background: var(--erp-surface);
  border-color: var(--erp-border);
  color: var(--erp-text);
  box-shadow: var(--erp-shadow-sm);
}

.btn {
  border-radius: 10px;
  font-weight: 600;
}
.btn-primary {
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  border: none;
}
.btn-outline-primary {
  border-color: rgba(29, 78, 216, 0.5);
  color: var(--erp-accent);
}
.btn-outline-primary:hover { background: var(--erp-accent); color: #fff; }

.alert { border-radius: 12px; }
.badge { font-weight: 700; letter-spacing: .04em; }

.erp-animate .row > [class*='col-'] {
  animation: erpFade .35s ease both;
}
.erp-animate .row > [class*='col-']:nth-child(2) { animation-delay: .03s; }
.erp-animate .row > [class*='col-']:nth-child(3) { animation-delay: .06s; }
.erp-animate .row > [class*='col-']:nth-child(4) { animation-delay: .09s; }
.erp-animate .row > [class*='col-']:nth-child(5) { animation-delay: .12s; }
.erp-animate .row > [class*='col-']:nth-child(6) { animation-delay: .15s; }

@keyframes erpFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .erp-animate .row > [class*='col-'] { animation: none; }
}

/* Login screen */
.login-body { background: var(--erp-bg); }
.login-card { border-radius: 18px; box-shadow: var(--erp-shadow); }
.login-title { font-weight: 800; letter-spacing: .03em; }
.login-subtitle { color: var(--erp-muted); }

/* ===== iOS look ===== */
:root {
  --brand-blue: #2f4a8f;
  --brand-blue-dark: #22386a;
  --brand-yellow: #ffd200;
  --brand-accent-rgb: 47, 74, 143;
  --brand-yellow-rgb: 255, 210, 0;
  --ios-bg: #f4f6fb;
  --ios-surface: #ffffff;
  --ios-surface-2: #f6f8fc;
  --ios-border: #dbe2f0;
  --ios-text: #16213b;
  --ios-muted: #6b7895;
  --ios-accent: var(--brand-blue);
  --ios-success: #34c759;
  --ios-warning: var(--brand-yellow);
  --ios-danger: #ff3b30;
  --ios-radius: 22px;
  --ios-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
  --ios-shadow-sm: 0 8px 18px rgba(15, 23, 42, 0.08);
}

body {
  background: var(--ios-bg);
  color: var(--ios-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: .01em;
}
body::before { display: none; }

.navbar {
  background: linear-gradient(135deg, var(--brand-blue-dark), var(--brand-blue)) !important;
  border-bottom: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.25);
}
.navbar-dark .navbar-brand { color: #fff; }
.navbar-dark .navbar-text { color: rgba(255,255,255,0.75); }
.navbar-brand { font-weight: 800; font-size: 1.1rem; }
.brand-title { color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,0.15); }
.brand-chip {
  display: inline-flex;
  align-items: center;
  background: transparent;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
}
.app-logo { height: 36px; }
.btn-outline-light {
  color: #fff;
  border-color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.08);
}
.btn-outline-light:hover {
  color: #1b1f2a;
  background: var(--brand-yellow);
  border-color: var(--brand-yellow);
}

.page-title {
  background: var(--ios-surface);
  border: 1px solid var(--ios-border);
  border-radius: var(--ios-radius);
  box-shadow: var(--ios-shadow-sm);
  padding: 18px 20px;
}
.page-title .fs-4 { font-size: 1.35rem; }

.erp-sidebar {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--ios-border);
  border-radius: 24px;
  box-shadow: var(--ios-shadow-sm);
  backdrop-filter: blur(10px) saturate(180%);
}

.list-group-item {
  border: 1px solid var(--ios-border);
  border-radius: 16px;
  background: var(--ios-surface);
  color: var(--ios-text);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.list-group-item-action:hover {
  background: var(--ios-surface-2);
  box-shadow: var(--ios-shadow-sm);
}
.list-group-item.active {
  background: var(--ios-accent);
  color: #fff;
  border-color: var(--ios-accent);
}
.nav-main {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: rgba(var(--brand-accent-rgb), 0.12);
  color: var(--ios-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
}
.nav-icon svg { width: 16px; height: 16px; }
.nav-chevron {
  color: var(--ios-muted);
  font-weight: 700;
  margin-left: 10px;
}
.list-group-item.active .nav-icon {
  background: rgba(255,255,255,0.25);
  color: #fff;
}
.list-group-item.active .nav-chevron { color: rgba(255,255,255,0.85); }

.card {
  border-radius: var(--ios-radius);
  border: 1px solid var(--ios-border);
  box-shadow: var(--ios-shadow-sm);
  background: var(--ios-surface);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card-header {
  background: var(--ios-surface-2);
  color: var(--ios-muted);
  border-bottom: 1px solid var(--ios-border);
  text-transform: none;
  letter-spacing: .02em;
  font-size: .85rem;
}
.card-body { padding: 20px; }
.kpi-card {
  background: linear-gradient(180deg, #ffffff, #f3f4f8);
}
.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(var(--brand-accent-rgb), 0.14);
  color: var(--ios-accent);
}
.kpi-icon svg { width: 20px; height: 20px; }

.app-content { padding: 20px 10px 28px 10px; }
.order-card { border-left: 6px solid rgba(var(--brand-accent-rgb), 0.6); }
.order-card .card-body { padding: 18px; }

.card-list .order-card {
  margin-bottom: 0;
  border-radius: 14px;
  border: none;
  box-shadow: none;
  background: transparent;
}
.card-list {
  background: var(--ios-surface);
  border: 1px solid var(--ios-border);
  border-radius: 22px;
  padding: 6px;
  box-shadow: var(--ios-shadow-sm);
}
.card-list .order-card + .order-card { border-top: 1px solid var(--ios-border); }
.card-list .order-card .card-body { padding: 14px 12px; }
.card-list .order-card:last-child { border-bottom: 0; }
.card-list .order-card .badge { font-size: .72rem; }
.card-list .order-card .text-muted { color: var(--ios-muted); }

.table.table-card {
  border-collapse: separate;
  border-spacing: 0 12px;
  background: transparent;
}
.table.table-card thead th {
  border: none;
  background: transparent;
  color: var(--ios-muted);
  font-weight: 700;
}
.table.table-card tbody tr {
  background: var(--ios-surface);
  box-shadow: var(--ios-shadow-sm);
}
.table.table-card tbody tr td {
  border-top: 1px solid var(--ios-border);
  border-bottom: 1px solid var(--ios-border);
}
.table.table-card tbody tr td:first-child {
  border-left: 1px solid var(--ios-border);
  border-top-left-radius: 16px;
  border-bottom-left-radius: 16px;
}
.table.table-card tbody tr td:last-child {
  border-right: 1px solid var(--ios-border);
  border-top-right-radius: 16px;
  border-bottom-right-radius: 16px;
}
.table.table-card tbody tr:hover { background: #f7f7fb; }

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--ios-shadow);
}
.card-list .order-card:hover { transform: none; box-shadow: none; }

.nav-tabs {
  border-bottom: none;
  background: #eaeaef;
  border-radius: 16px;
  padding: 6px;
  gap: 6px;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.nav-tabs .nav-link {
  border: none;
  border-radius: 12px;
  background: transparent;
  white-space: nowrap;
}
.nav-tabs .nav-link.active {
  background: #ffffff;
  box-shadow: var(--ios-shadow-sm);
}

.table-responsive {
  border-radius: 16px;
  border: 1px solid var(--ios-border);
  background: var(--ios-surface);
  box-shadow: var(--ios-shadow-sm);
}
.table thead th {
  background: var(--ios-surface-2);
  color: var(--ios-muted);
}
.table tbody tr td { padding: .7rem .75rem; }
.table tbody tr { transition: background .15s ease, box-shadow .15s ease; }

.nav-tabs .nav-link {
  color: var(--ios-muted);
  padding: 10px 16px;
  border-radius: 14px 14px 0 0;
}
.nav-tabs .nav-link.active {
  color: var(--ios-text);
  border-color: var(--ios-border);
  background: var(--ios-surface);
  box-shadow: var(--ios-shadow-sm);
}

.btn-primary {
  background: var(--ios-accent);
  border-color: var(--ios-accent);
  box-shadow: 0 10px 18px rgba(var(--brand-accent-rgb), 0.25);
}
.btn-outline-primary {
  border-color: var(--ios-accent);
  color: var(--ios-accent);
}
.btn-outline-primary:hover {
  background: var(--ios-accent);
  color: #fff;
}
.btn-success { background: var(--ios-success); border-color: var(--ios-success); }
.btn-warning { background: var(--ios-warning); border-color: var(--ios-warning); color: #1c1c1e; }
.btn-danger { background: var(--ios-danger); border-color: var(--ios-danger); }

.btn {
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}

.alert { border-radius: 16px; }
.badge {
  border-radius: 999px;
  padding: .3rem .6rem;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid var(--ios-border);
  background: #f0f0f5;
  color: var(--ios-text);
}
.badge.bg-success { background: rgba(52, 199, 89, 0.2) !important; color: #1f7a3a !important; border-color: rgba(52,199,89,0.35) !important; }
.badge.bg-warning { background: rgba(var(--brand-yellow-rgb), 0.22) !important; color: #6b5200 !important; border-color: rgba(var(--brand-yellow-rgb), 0.45) !important; }
.badge.bg-danger { background: rgba(255, 59, 48, 0.2) !important; color: #8a1b15 !important; border-color: rgba(255,59,48,0.35) !important; }
.badge.bg-info { background: rgba(90, 200, 250, 0.2) !important; color: #0b5e7a !important; border-color: rgba(90,200,250,0.35) !important; }
.badge.bg-secondary { background: rgba(142, 142, 147, 0.2) !important; color: #3a3a3c !important; border-color: rgba(142,142,147,0.35) !important; }

.status-pill {
  --status-bg: #f1f5f9;
  --status-border: #cbd5e1;
  --status-text: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .76rem;
  letter-spacing: .01em;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid var(--status-border);
  background: var(--status-bg);
  color: var(--status-text);
}
.status-pill::before {
  content: none;
}
.status-nowe,
.status-draft,
.status-new,
.status-unknown,
.status-inactive,
.status-off,
.status-suspended,
.status-wydane,
.status-released {
  --status-bg: #f1f5f9;
  --status-border: #cbd5e1;
  --status-text: #475569;
}
.status-wycenione,
.status-awaiting_quote,
.status-quoted,
.status-live,
.status-billing-in_progress {
  --status-bg: #f0f9ff;
  --status-border: #bae6fd;
  --status-text: #0369a1;
}
.status-zaakceptowane,
.status-accepted {
  --status-bg: #eff6ff;
  --status-border: #bfdbfe;
  --status-text: #1d4ed8;
}
.status-w_produkcji,
.status-in_production,
.status-on_hold,
.status-pending,
.status-billing-pending,
.status-billing-pending-prov,
.status-paused,
.status-trial,
.status-zaplacone,
.status-paid,
.status-warn {
  --status-bg: #fffbeb;
  --status-border: #fde68a;
  --status-text: #b45309;
}
.status-gotowe,
.status-ready,
.status-running,
.status-active,
.status-on,
.status-ok,
.status-billing-resolved,
.status-billing-provisioned {
  --status-bg: #ecfdf5;
  --status-border: #a7f3d0;
  --status-text: #047857;
}
.status-cancelled,
.status-expired,
.status-fail,
.status-failed,
.status-stopped,
.status-refunded,
.status-billing-rejected,
.status-billing-failed {
  --status-bg: #fff1f2;
  --status-border: #fecdd3;
  --status-text: #be123c;
}
.blocked-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .01em;
  border: 1px solid rgba(255, 149, 0, 0.35);
  background: rgba(255, 149, 0, 0.16);
  color: #7a4a00;
}
.blocked-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff9f0a;
  box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.18) inset;
}

.qr-block {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.qr-img {
  width: 128px;
  height: 128px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--ios-border);
  background: #fff;
  box-shadow: var(--ios-shadow-sm);
}
.qr-img-lg {
  width: 180px;
  height: 180px;
}

.flash-stack {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  z-index: 1055;
  pointer-events: none;
}
.flash-stack .alert {
  width: min(560px, 92vw);
  box-shadow: var(--ios-shadow);
  pointer-events: auto;
  margin: 0;
}

.login-body { background: var(--ios-bg); }
.login-card { border-radius: 26px; box-shadow: var(--ios-shadow); }
.login-title { color: var(--ios-text); }
.login-subtitle { color: var(--ios-muted); }
.form-control, .form-select {
  border-radius: 14px;
  border: 1px solid var(--ios-border);
  padding: .55rem .8rem;
}
.filter-card .form-label {
  text-transform: uppercase;
  font-size: .72rem;
  letter-spacing: .08em;
  color: var(--ios-muted);
}
.filter-card .btn {
  min-width: 110px;
}
/* === GALAXY FOLD 7 & FOLDING DEVICES (520px viewports) === */
@media (max-width: 520px) {
  /* Navbar compacting */
  .navbar-brand {
    gap: 0.5rem !important;
  }
  .app-logo {
    height: 24px;
  }
  .brand-title {
    font-size: 0.95rem;
  }
  
  /* Sidebar to horizontal nav */
  .app-shell {
    flex-direction: column;
  }
  .app-sidebar {
    width: 100%;
    height: auto;
    position: static;
    max-height: auto;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 0 0 auto;
  }
  .app-sidebar .list-group {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 0;
  }
  .app-sidebar .list-group-item {
    flex: 0 0 auto;
    min-width: 140px;
    white-space: nowrap;
    padding: 0.75rem 1rem;
    border-radius: 0;
  }
  .app-sidebar .nav-chevron {
    display: none;
  }
  
  /* Card adjustments */
  .card {
    border-radius: 12px;
    margin-bottom: 1rem;
  }
  .card-header {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }
  .card-body {
    padding: 1rem;
  }
  
  /* Form compacting */
  .row.g-2 {
    gap: 0.75rem !important;
  }
  .col-12, .col-6 {
    padding-left: 0.375rem !important;
    padding-right: 0.375rem !important;
  }
  
  .form-label {
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
  }
  .form-control, .form-select {
    font-size: 0.95rem;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
  }
  
  /* Buttons */
  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    border-radius: 8px;
    min-width: auto;
  }
  .btn-sm {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
  }
  .kiosk-actions .btn {
    min-width: 100%;
    padding: 14px 14px;
    font-size: 1rem;
    margin: 0.25rem 0;
  }
  
  /* Tables - stack on small */
  .table-responsive {
    border-radius: 8px;
  }
  .table {
    font-size: 0.85rem;
  }
  .table thead {
    display: none;
  }
  .table tbody tr {
    display: block;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    padding: 0.75rem 0;
  }
  .table tbody td {
    display: block;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border: none;
  }
  .table tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--bs-gray-700);
    display: inline-block;
    min-width: 100px;
    margin-right: 0.5rem;
  }
  
  /* Badges & status */
  .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
  .status-pill {
    padding: 3px 8px;
    font-size: 0.75rem;
  }
  
  /* Page title */
  .page-title {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem;
  }
  .page-title .fs-4 {
    font-size: 1.25rem !important;
  }
  
  /* Alert spacing */
  .alert {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
  }
  
  /* Modal adjustments */
  .modal-dialog {
    margin: 0.5rem;
  }
  .modal-header {
    padding: 1rem 1rem;
  }
  .modal-body {
    padding: 1rem;
  }
  .modal-footer {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
  
  /* Typography */
  body {
    font-size: 0.95rem;
  }
  
  /* Prevent horizontal scroll */
  body, html {
    overflow-x: hidden;
  }
  
  /* Flex wrapping for control panels */
  .d-flex.flex-wrap.gap-2 {
    gap: 0.5rem !important;
  }
}

/* Extra tight for foldable inner screen (~480px) */
@media (max-width: 480px) {
  .card-body {
    padding: 0.75rem;
  }
  .form-label {
    font-size: 0.8rem;
  }
  .table tbody tr {
    margin-bottom: 0.5rem;
  }
  .btn {
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
  }
  .navbar-brand span {
    display: none;
  }
}
/* Ensure full-width KPI cards and columns on small devices */
@media (max-width: 520px) {
  .col-6 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  .col-sm-6 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  .col-md-4 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  .col-md-3 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  .col-md-2 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
}

@media (max-width: 520px) {
  /* Make action buttons in stacked tables touch-friendly */
  .table tbody td .btn {
    display: block;
    width: 100%;
    margin-bottom: 0.5rem;
  }
  .table tbody td .btn + .btn {
    margin-top: 0.25rem;
  }
  .table tbody td .btn.btn-sm {
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
  }
}

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
.card-link:hover {
  color: inherit;
  text-decoration: none;
}

/* === Industrial light theme (navy + steel blue) === */
body.app-industrial {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f4f6fb;
  color: #0f172a;
}

.app-topbar {
  background: linear-gradient(135deg, #233b73 0%, #2c4d8f 55%, #355a9f 100%) !important;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}
.app-topbar .navbar-brand .brand-title {
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.95rem;
}

.app-shell {
  min-height: calc(100vh - 64px);
  padding-bottom: 32px;
}

.app-sidebar {
  background: #ffffff;
  border-right: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 8px 0 24px rgba(15, 23, 42, 0.06);
  padding: 18px 12px 28px;
  min-height: calc(100vh - 64px);
}
.app-sidebar .list-group-item {
  background: #f7f9fc;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  margin-bottom: 10px;
  color: #1f2937;
  transition: all 0.2s ease;
}
.app-sidebar .list-group-item .nav-label {
  font-weight: 600;
}
.app-sidebar .list-group-item .nav-chevron {
  color: rgba(100, 116, 139, 0.6);
}
.app-sidebar .list-group-item:hover {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.35);
}
.app-sidebar .list-group-item.active {
  background: linear-gradient(135deg, rgba(35, 59, 115, 0.16), rgba(44, 77, 143, 0.18));
  border-color: rgba(35, 59, 115, 0.55);
  color: #0f172a;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.app-content {
  padding: 22px 24px 32px;
}

.page-title {
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.card {
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}
.card-header {
  background: #f8fafc;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  font-weight: 600;
}
.card-body {
  background: #ffffff;
}

.btn-primary {
  background: linear-gradient(135deg, #2b4f93 0%, #3a6ac2 100%);
  border: none;
  box-shadow: 0 10px 18px rgba(43, 79, 147, 0.22);
}
.btn-primary:hover {
  filter: brightness(1.05);
}
.btn-outline-primary {
  color: #2b4f93;
  border-color: rgba(43, 79, 147, 0.55);
}
.btn-outline-primary:hover {
  background: rgba(43, 79, 147, 0.08);
  color: #23437e;
}
.btn-outline-secondary {
  border-color: rgba(100, 116, 139, 0.4);
}
.btn-outline-secondary:hover {
  background: rgba(100, 116, 139, 0.1);
}
.btn {
  border-radius: 12px;
}
.btn-sm {
  border-radius: 10px;
}

.form-control,
.form-select {
  border-radius: 12px;
  border-color: rgba(148, 163, 184, 0.4);
  background: #f8fafc;
}
.form-control:focus,
.form-select:focus {
  border-color: rgba(43, 79, 147, 0.6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: #ffffff;
}

.filter-card {
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 16px;
}

.list-group-item {
  border-radius: 12px;
}

.badge {
  border-radius: 999px;
  font-weight: 600;
}

.table thead th {
  background: #f1f5f9;
  color: #334155;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}
.table tbody tr {
  background: #ffffff;
}
.table tbody tr:nth-child(even) {
  background: rgba(241, 245, 249, 0.55);
}
.table tbody tr:hover {
  background: rgba(59, 130, 246, 0.08);
}

.status-pill {
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
}

.order-card {
  border-left: 6px solid rgba(43, 79, 147, 0.45);
}
.card-list .order-card {
  background: transparent;
}

@media (max-width: 992px) {
  .app-sidebar {
    min-height: auto;
  }
  .app-content {
    padding: 18px 16px 24px;
  }
}

/* Tablet override: force horizontal menu, avoid full-height sidebar */
@media (min-width: 700px) and (max-width: 1024px) {
  .app-shell { display: block !important; }
  .app-shell > .grid { display: block !important; }
  .app-sidebar {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    position: static !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 8px 8px 10px !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  .app-sidebar .list-group {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
  }
  .app-sidebar .list-group-item {
    flex: 0 0 auto !important;
    min-width: 160px !important;
    margin-bottom: 0 !important;
    white-space: nowrap !important;
  }
  .app-sidebar .nav-chevron { display: none !important; }
  .app-content {
    width: 100% !important;
    padding: 18px 16px 24px !important;
  }
  .erp-sidebar { min-height: 0 !important; height: auto !important; }
}

/* Mid phones / small tablets (fills the 521-699px gap) */
@media (min-width: 521px) and (max-width: 699px) {
  .app-shell { display: block !important; }
  .app-shell > .grid { display: block !important; }
  .app-sidebar {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    position: static !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 8px 8px 10px !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  .app-sidebar .list-group {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
  }
  .app-sidebar .list-group-item {
    flex: 0 0 auto !important;
    min-width: 160px !important;
    margin-bottom: 0 !important;
    white-space: nowrap !important;
  }
  .app-sidebar .nav-chevron { display: none !important; }
  .app-content {
    width: 100% !important;
    padding: 18px 14px 24px !important;
  }
  .erp-sidebar { min-height: 0 !important; height: auto !important; }
}

/* Prevent horizontal page overflow in desktop grid shell */
.app-shell > .grid {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.app-shell .app-sidebar,
.app-shell .app-content {
  min-width: 0;
}

@media (min-width: 1025px) {
  .app-shell .app-sidebar {
    width: 100%;
    max-width: 100%;
    flex: 0 0 auto;
  }
}

/* Hide open warning banners globally (non-critical warnings only). */
.app-content .alert.alert-warning,
.app-content div[class*="rounded-2xl"][class*="border"][class*="px-4"][class*="py-3"][class*="text-sm"][class*="border-amber-200"][class*="bg-amber-50"][class*="text-amber-700"],
.app-content div[class*="rounded-xl"][class*="border"][class*="px-4"][class*="py-3"][class*="text-sm"][class*="border-amber-200"][class*="bg-amber-50"][class*="text-amber-700"] {
  display: none !important;
}

/* Classic backoffice mode (tenant without premium portal):
   handlowiec/operator should keep pre-portal visual density. */
body.ui-classic-role {
  --ios-radius: 14px;
  --ios-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
  --ios-shadow-sm: 0 4px 10px rgba(15, 23, 42, 0.08);
  background: #f6f7fb;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
body.ui-classic-role::before {
  display: none;
}
body.ui-classic-role .app-topbar,
body.ui-classic-role .navbar {
  box-shadow: none;
}
body.ui-classic-role .erp-sidebar {
  border-radius: 14px;
  backdrop-filter: none;
}
body.ui-classic-role .page-title,
body.ui-classic-role .card,
body.ui-classic-role .kpi-card,
body.ui-classic-role .order-card,
body.ui-classic-role .rounded-3xl,
body.ui-classic-role .rounded-2xl {
  border-radius: 12px !important;
}
body.ui-classic-role .shadow-sm,
body.ui-classic-role .shadow-md,
body.ui-classic-role .shadow-lg {
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08) !important;
}
body.ui-classic-role .card:hover {
  transform: none;
}
body.ui-classic-role .app-content {
  padding: 16px 6px 24px 6px;
}
