:root{
  --bg:#f3f5f9;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --line:#e5e7eb;
  --brand:#1f3a8a;
  --brand2:#0ea5e9;
  --danger:#b91c1c;
  --ok:#15803d;
  --shadow:0 8px 30px rgba(15,23,42,.08);
  --radius:14px;
  --radius2:10px;
  --pad:18px;
  --pad2:12px;
  --font: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:var(--font);
  color:var(--text);
  background:var(--bg);
}
a{color:var(--brand); text-decoration:none}
a:hover{text-decoration:underline}

/* ===== TOPBAR ===== */
.topbar{
  background:linear-gradient(90deg, rgba(31,58,138,1), rgba(14,165,233,.65));
  color:#fff;
  position:sticky;
  top:0;
  z-index:10;
}
.topbar-inner{
  max-width:1100px;
  margin:0 auto;
  padding:14px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
}
.brand{display:flex; align-items:center; gap:10px; font-weight:700; letter-spacing:.2px}
.brand .dot{width:10px; height:10px; border-radius:999px; background:rgba(255,255,255,.9); display:inline-block}
.nav{display:flex; gap:14px; flex-wrap:nowrap}
.nav a{
  color:rgba(255,255,255,.95);
  padding:8px 10px;
  border-radius:10px;
}
.nav a:hover{background:rgba(255,255,255,.14); text-decoration:none}

/* ===== LAYOUT ===== */
.app-wrap{
  max-width:1100px;
  margin:18px auto;
  padding:0 18px;
}
.card{
  background:var(--card);
  border:1px solid rgba(15,23,42,.06);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:var(--pad);
}
.footer{
  max-width:1100px;
  margin:10px auto 24px;
  padding:0 18px;
  color:var(--muted);
  font-size:12px;
  text-align:center;
}

/* ===== TYPO ===== */
.page-title{margin:0 0 14px 0; font-size:26px; line-height:1.1}
.page-subtitle{margin:0 0 14px 0; color:var(--muted)}
.hr{border:0; border-top:1px solid var(--line); margin:16px 0}

/* ===== TOOLBAR / ROW ===== */
.form-row{
  display:flex;
  gap:12px;
  align-items:end;
  justify-content:space-between;
  flex-wrap:wrap;
  margin:0 0 14px 0;
}
.form-row-compact {
  margin: 0;
}

.form-row .right{
  display:flex;
  gap:10px;
  align-items:end;
  justify-content:flex-end;
  flex-wrap:wrap;
}

/* ===== FORMS ===== */
.form-grid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap:12px;
}
.field{grid-column: span 6}
.field.sm{grid-column: span 3}
.field.lg{grid-column: span 12}
label{display:block; font-size:12px; color:var(--muted); margin:0 0 6px 0}
input[type="text"], input[type="number"], input[type="date"], select, textarea{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#fff;
  color:var(--text);
  outline:none;
}
textarea{min-height:90px; resize:vertical}
input:focus, select:focus, textarea:focus{border-color:rgba(31,58,138,.45); box-shadow:0 0 0 3px rgba(31,58,138,.10)}

/* ===== ALERTS ===== */
.alert{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  margin:0 0 14px 0;
}

/* ===== BUTTONS ===== */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:600;
  text-decoration:none;
}
.btn:hover{background:#f8fafc; text-decoration:none}
.btn-primary{
  background:rgba(31,58,138,1);
  color:#fff;
  border-color:rgba(31,58,138,1);
}
.btn-primary:hover{background:rgba(31,58,138,.92)}
.btn-danger{background:#fff; border-color:rgba(185,28,28,.35); color:var(--danger)}
.btn-danger:hover{background:rgba(185,28,28,.06)}
.btn-ghost{background:transparent}

/* =========================================================
   ===== FORM ACTIONS (globalnie) — DWUKONTENEROWO =====
   Cel:
   - Komunikaty (np. .alert "zapisano") nie rozwalają układu
   - Przyciski zawsze po prawej
   - Preferowany układ:
       <div class="form-actions">
         <div class="form-actions__msg">...</div>
         <div class="form-actions__buttons">...btn...</div>
       </div>
   Ale działa też, jeśli wszystko jest w jednym kontenerze.
   ========================================================= */

/* Bazowy kontener akcji */
[data-form-actions],
.form-actions,
.field.actions{
  margin-top:16px;
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  width:100%;
}

/* Domyślnie: przyciski po prawej */
[data-form-actions],
.form-actions,
.field.actions{
  justify-content:flex-end;
}

/* Jeśli pojawi się alert/message/flash w tym samym kontenerze,
   to on ma "zająć lewą stronę", a przyciski mają zostać po prawej. */
[data-form-actions] .alert,
[data-form-actions] .message,
[data-form-actions] .flash,
.form-actions .alert,
.form-actions .message,
.form-actions .flash,
.field.actions .alert,
.field.actions .message,
.field.actions .flash{
  margin:0;              /* ważne: alert nie wnosi własnych marginesów w stopce */
  margin-right:auto;     /* wypycha resztę (przyciski) na prawo */
  flex:0 1 auto;
}

/* Wspieramy jawny "dwukontener" */
.form-actions__msg{
  margin-right:auto;
  flex:0 1 auto;
}
.form-actions__buttons{
  margin-left:auto;
  display:flex;
  gap:10px;
  justify-content:flex-end;
  align-items:center;
  flex-wrap:wrap;
}

/* Jeśli przyciski są w jakimś wrapperze typu .right/.buttons/.btn-group */
[data-form-actions] .right,
[data-form-actions] .buttons,
[data-form-actions] .btn-group,
.form-actions .right,
.form-actions .buttons,
.form-actions .btn-group,
.field.actions .right,
.field.actions .buttons,
.field.actions .btn-group{
  margin-left:auto;
  display:flex;
  gap:10px;
  justify-content:flex-end;
  align-items:center;
  flex-wrap:wrap;
}

/* Gdyby przyciski były bez wrappera, a alert pojawiał się jako pierwszy element,
   to dalej wszystko będzie po prawej, bo alert ma margin-right:auto. */

/* (Opcjonalnie) Jeśli chcesz, żeby stopka akcji była przyklejona do dołu ekranu,
   możesz to włączyć dodając klasę .sticky-actions na kontenerze.
   Nie wymuszam globalnie, bo to może być zbyt agresywne. */
.sticky-actions{
  position:sticky;
  bottom:0;
  padding:12px;
  z-index:20;
  background:var(--card);
  border-top:1px solid rgba(0,0,0,.08);
  border-radius:12px;
}

/* ===== TABLE WRAP ===== */
/* ===== TABLE WRAP (GLOBAL) ===== */
/* Ramka NIE może mieć overflow-x:auto, bo utnie dropdowny (autocomplete) */
.table-wrap{
  border:1px solid var(--line);
  border-radius:14px;
  overflow: visible;
  background:#fff;
}

/* Scroll poziomy jest w środku */
.table-scroll{
  overflow-x:auto;
  overflow-y:visible;
  border-radius:14px;
}

table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  min-width:720px;
  background:#fff;
}
th, td{padding:10px 12px; border-bottom:1px solid var(--line); text-align:left; white-space:nowrap}
th{
  position:sticky;
  top:0;
  background:#f8fafc;
  z-index:1;
  font-size:12px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.05em
}
tr:hover td{background:#fafafa}
td.num{text-align:right; font-variant-numeric: tabular-nums}

/* ===== AUTOCOMPLETE (GLOBAL) ===== */
.autocomplete{
  position:relative;
  overflow:visible;
}
.suggestion{
  padding:10px 12px;
  cursor:pointer;
  border-bottom:1px solid var(--line);
  color:var(--text);
  background:#fff;
}
.suggestion:last-child{border-bottom:0}
.suggestion:hover{background:#f8fafc}
.suggestion .muted{color:var(--muted); font-size:12px; margin-top:2px}
.hidden{display:none}
.suggestion.active{
  background:#1f3a8a;
  color:#fff;
}
.suggestion.active .muted{color:#e0e7ff}



/* =========================
   NAV – MOBILE TOGGLE (FINAL)
   ========================= */

/* Mobile/off-canvas pod topbarem */
@media (max-width: 860px){

  /* Hamburger widoczny na mobile */
  .nav-toggle{
    display:inline-flex;
    align-items:center;
    justify-content:center;
  }

  /* DOMYŚLNIE: menu schowane */
  .topbar .nav{
    display:none;
    position:absolute;
    left:0; right:0;
    top:100%;
    flex-direction:column;
    gap:0;
    padding:10px;
    background: rgba(255,255,255,0.96);
    border-radius:12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.18);
    z-index: 2000;
  }

  /* Po kliknięciu hamburgera */
  body.is-nav-open .topbar .nav{
    display:flex;
  }

  /* Linki jako “przyciski” */
  .topbar .nav a{
    display:block;
    padding:10px 12px;
    border-radius:10px;
    color:#111;
  }
  .topbar .nav a:hover{
    background: rgba(0,0,0,0.06);
  }

  /* dropdown Ustawienia w mobile ma się układać normalnie */
  .nav-dd{
    display:block;
  }
  .nav-dd-menu{
    position:static;
    box-shadow:none;
    border:0;
    margin-top:6px;
  }

  /* topbar-inner musi być pozycjonowalny dla absolutnego menu */
  .topbar .topbar-inner{
    position:relative;
  }
}



/* === AC DEBUG (tymczasowo) === */

/* ============================================================
   AUTOCOMPLETE — FINAL (jedyna definicja .suggestions)
   ============================================================ */
.autocomplete{ position:relative; overflow:visible; }

.suggestions{
  position: fixed;              /* nie ucina się w tabelach/overflow */
  z-index: 9999;
  background: #fff;
  border: 1px solid rgba(0,0,0,.14);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,.18);
  overflow: auto;
  max-height: 260px;
  padding: 6px;
}

.suggestions.hidden{ display:none; }

.suggestions .suggestion{
  padding: 10px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.suggestions .suggestion:hover,
.suggestions .suggestion.active{
  background: rgba(0,0,0,.06);
}
.status-published { color: #1f8b3b; font-weight: 600; }
.status-muted { color: #7b8794; }

/* Forms list statuses */
.status-published { color: #1f8b3b; font-weight: 600; }
.status-muted { color: #7b8794; }


/* ============================================================
   Form grid (12 columns) - used by FormEngine container sections
   ============================================================ */
.fg { display: grid; gap: 10px; }
.fg-row { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px; }
.fg-col { min-width: 0; }

.fg-col[data-span="1"]  { grid-column: span 1; }
.fg-col[data-span="2"]  { grid-column: span 2; }
.fg-col[data-span="3"]  { grid-column: span 3; }
.fg-col[data-span="4"]  { grid-column: span 4; }
.fg-col[data-span="5"]  { grid-column: span 5; }
.fg-col[data-span="6"]  { grid-column: span 6; }
.fg-col[data-span="7"]  { grid-column: span 7; }
.fg-col[data-span="8"]  { grid-column: span 8; }
.fg-col[data-span="9"]  { grid-column: span 9; }
.fg-col[data-span="10"] { grid-column: span 10; }
.fg-col[data-span="11"] { grid-column: span 11; }
.fg-col[data-span="12"] { grid-column: span 12; }

/* Mobile: 1 kolumna (pomiarzyści będą wdzięczni) */
@media (max-width: 900px) {
  .fg-row { grid-template-columns: 1fr; }
  .fg-col { grid-column: span 1 !important; }
}

/* readonly field look */
.input.readonly { padding: 10px; border: 1px solid #ddd; border-radius: 10px; background: #f7f7f7; }

.ac-list{
  display:none;
  border:1px solid #ddd;
  border-radius:8px;
  padding:6px;
  margin-top:6px;
  background:#fff;
  max-height:260px;
  overflow:auto;
}
.ac-item{
  display:block;
  width:100%;
  text-align:left;
  padding:8px 10px;
  border:0;
  background:transparent;
  cursor:pointer;
}
.ac-item:hover{
  background:rgba(0,0,0,0.06);
}
.flash {
  outline: 2px solid var(--brand);
  outline-offset: 4px;
}
.app-modal { display:none; position:fixed; inset:0; z-index:9999; }
.app-modal.is-open { display:block; }
.app-modal-backdrop { position:absolute; inset:0; background:rgba(0,0,0,.35); }
.app-modal-panel { position:relative; max-width:720px; margin:6vh auto; background:#fff; border-radius:12px; overflow:hidden; }
.app-modal-content { padding:16px; }
.slot-list { display:flex; flex-wrap:wrap; gap:8px; }
.modal-actions { margin-top:12px; display:flex; justify-content:flex-end; gap:8px; }

.calendar-dialog {
    border: 1px solid #ccc;
    padding: 12px;
    margin-top: 12px;
    background: #fff;
}

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

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    padding: 8px;
    text-align: center;
    border: 1px solid #ddd;
    cursor: pointer;
}

.calendar-day.is-available {
    background: #e6f6ea;
    border-color: #2ecc71;
}

.calendar-day.is-disabled {
    background: #f5f5f5;
    color: #aaa;
    cursor: default;
}

.calendar-slots {
    margin-top: 10px;
}

/* =========================
   NAV dropdown (mobile)
   ========================= */

.nav-dd { position: relative; display: inline-block; }

.nav-dd-btn{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: #fff;              /* tekst w topbarze */
}

.nav-dd-btn:hover{ background: rgba(255,255,255,0.12); }

.nav-dd-caret{ opacity: .9; font-size: 12px; }

.nav-dd-menu{
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  padding: 6px;
  display: none;
  z-index: 10000;
}

.nav-dd.is-open .nav-dd-menu{ display: block; }

.nav-dd-item{
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: #111;              /* TEKST w dropdownie (żeby nie był biały) */
  line-height: 1.2;
}

.nav-dd-item:hover{ background: rgba(0,0,0,0.06); }

/* =========================
   Mobile: zwijane menu topbar
   ========================= */
.nav-toggle{
  display:none;
  appearance:none;
  border:0;
  background:transparent;
  color:inherit;
  font-size:22px;
  line-height:1;
  padding:8px 10px;
  border-radius:10px;
  cursor:pointer;
}

@media (max-width: 860px){
  .nav-toggle{ display:inline-flex; align-items:center; justify-content:center; }

  .topbar .nav{
    display:none;                 /* domyślnie schowane */
    position:absolute;
    left:12px;
    right:12px;
    top:56px;                     /* jak nie trafi, skorygujemy */
    background:#fff;
    color:#111;
    border:1px solid rgba(0,0,0,.12);
    border-radius:14px;
    padding:8px;
    box-shadow:0 10px 30px rgba(0,0,0,.18);
    flex-direction:column;
    gap:6px;
    z-index:10000;
  }

  body.is-nav-open .topbar .nav{ display:flex; }

  .topbar .nav a{
    color:#111;
    padding:10px 12px;
    border-radius:10px;
    text-decoration:none;
  }
  .topbar .nav a:hover{ background:rgba(0,0,0,.06); }

  /* ważne: topbar-inner musi być "pozycjonowalny" dla absolutnego menu */
  .topbar .topbar-inner{ position:relative; }
}

/* =========================
   NAV – BUTTON RESET + DROPDOWN VISIBILITY (FIX)
   ========================= */

/* 1) Button "Ustawienia" ma wyglądać jak link w topbarze (desktop) */
.nav-dd-btn{
  appearance:none;
  -webkit-appearance:none;
  border:0;
  background:transparent;
  color:#fff;
  font:inherit;
  line-height:1;
  padding:10px 12px;
  border-radius:10px;
  cursor:pointer;
}
.nav-dd-btn:hover{
  background: rgba(255,255,255,0.12);
}
.nav-dd.is-open .nav-dd-btn{
  background: rgba(255,255,255,0.14);
}

/* 2) Dropdown: czarny tekst na białym tle (desktop) */
.nav-dd-menu{
  background:#fff;
}
.nav-dd-item{
  color:#111;
}
.nav-dd-item:hover{
  color:#111;
}

/* 3) Mobile: w białym panelu menu przycisk ma mieć czarny tekst i pełną szerokość */
@media (max-width: 860px){
  .topbar .nav .nav-dd-btn{
    width:100%;
    text-align:left;
    color:#111;
  }
  .topbar .nav .nav-dd-btn:hover{
    background: rgba(0,0,0,0.06);
  }
}


/* =========================
   NAV – DROPDOWN FINAL FIX (DESKTOP + MOBILE)
   ========================= */

/* DESKTOP: wymuś czarny tekst w dropdown (przebij .nav a{color:#fff}) */
.topbar .nav .nav-dd-menu .nav-dd-item{
  color:#111 !important;
}
.topbar .nav .nav-dd-menu .nav-dd-item:hover{
  color:#111 !important;
}

/* MOBILE: dropdown ma być "inline" w białym panelu i widoczny po is-open */
@media (max-width: 860px){
  .topbar .nav .nav-dd-menu{
    position:static;
    display:none;
    margin-top:6px;
    background:transparent;
    box-shadow:none;
    border:0;
    padding:0;
  }
  .topbar .nav .nav-dd.is-open .nav-dd-menu{
    display:block;
  }

  .topbar .nav .nav-dd-menu .nav-dd-item{
    display:block;
    padding:10px 12px;
    border-radius:10px;
    color:#111 !important;
  }
  .topbar .nav .nav-dd-menu .nav-dd-item:hover{
    background: rgba(0,0,0,0.06);
  }
}


/* =========================
   NAV – DESKTOP HOVER TUNE
   ========================= */

.topbar .nav .nav-dd-menu .nav-dd-item:hover{
  background: rgba(0,0,0,0.05); /* delikatnie jaśniejsze */
  color:#111 !important;
}


/* =========================
   NAV – GENERIC SUBMENU LOOK (FUTURE-PROOF)
   ========================= */

/* Desktop: submenu wygląda jak “zagnieżdżone” */
.topbar .nav .nav-dd-menu{
  margin-top:8px;
  padding:8px 10px;
  border-radius:12px;

  /* wcięcie + delikatna lewa prowadnica */
  margin-left:10px;
  border-left: 3px solid rgba(0,0,0,0.10);
}

/* Elementy submenu: trochę mniejsze i “ciasne” */
.topbar .nav .nav-dd-menu .nav-dd-item{
  font-size: 14px;
  padding:9px 12px;
  border-radius:10px;
}

/* Separator między pozycjami submenu */
.topbar .nav .nav-dd-menu .nav-dd-item + .nav-dd-item{
  border-top: 1px solid rgba(0,0,0,0.08);
}

/* Mobile: submenu jeszcze bardziej “w środku” */
@media (max-width: 860px){
  .topbar .nav .nav-dd-menu{
    margin-left:12px;
    padding-left:10px;
    border-left: 3px solid rgba(0,0,0,0.10);
  }
}


/* ================================
   LEADS LIST (mobile + desktop)
================================ */

.leads-list{
display:flex;
flex-direction:column;
gap:8px;
}

.lead-row{
background:#fff;
border:1px solid #ddd;
border-radius:8px;
padding:10px;
cursor:pointer;
}

.lead-row:hover{
background:#f7f7f7;
}

.lead-line1{
display:flex;
gap:8px;
align-items:center;
font-weight:600;
}

.lead-line2{
display:flex;
gap:10px;
font-size:13px;
color:#666;
margin-top:4px;
}

.badge{
background:#eee;
padding:2px 6px;
border-radius:4px;
font-size:11px;
}

.lead-modal{
display:none;
position:fixed;
left:0;
top:0;
right:0;
bottom:0;
background:rgba(0,0,0,0.4);
align-items:center;
justify-content:center;
z-index:1000;
}

.lead-modal-inner{
background:#fff;
padding:16px;
border-radius:8px;
max-width:420px;
width:90%;
}

.lead-modal-header{
font-weight:700;
margin-bottom:10px;
}

/* === mobile safe area for bottom navigation / logout === */
@media (max-width: 768px) {
  .nav {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  }

  .topbar,
  .topbar-inner,
  .nav {
    box-sizing: border-box;
  }
}

@media (max-width: 860px){
  .topbar .nav{
    max-height: calc(100vh - 72px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}


/* === ROOM SEPARATOR: FINAL CLEAN LINE === */
.order-room-separator {
  display: flex;
  align-items: center;
  margin: 16px 0 10px;
  font-size: 14px;
  font-weight: 500;
  color: #555;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.order-room-separator::before,
.order-room-separator::after {
  content: "";
  flex: 1 1 auto;
  height: 2px;
  background: #cfcfcf;
}

.order-room-separator::before {
  margin-right: 10px;
}

.order-room-separator::after {
  margin-left: 10px;
}


/* Orders list status badges */
.order-status-badge {
  display: inline-block;
  min-width: 64px;
  padding: 3px 6px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #374151;
}

.order-status-draft {
  background: #f3f4f6;
  color: #374151;
  border-color: #d1d5db;
}

.order-status-ready {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}

.order-status-sent {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.order-status-confirmed {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.order-status-archived {
  background: #f8fafc;
  color: #64748b;
  border-color: #cbd5e1;
}

.order-status-unknown {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

/* Orders list status badges */
.order-status-badge {
  display: inline-block;
  min-width: 64px;
  padding: 3px 6px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #374151;
}

.order-status-draft {
  background: #f3f4f6;
  color: #374151;
  border-color: #d1d5db;
}

.order-status-ready {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}

.order-status-sent {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.order-status-confirmed {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.order-status-archived {
  background: #f8fafc;
  color: #64748b;
  border-color: #cbd5e1;
}

.order-status-unknown {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

/* === B2B client panel === */
.nav-form {
  display: inline;
}

.nav-logout {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.b2b-orders-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.b2b-orders-head h1 {
  margin-bottom: 4px;
}

.b2b-orders-list {
  display: grid;
  gap: 12px;
}

.b2b-order-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

.b2b-order-main {
  min-width: 0;
}

.b2b-order-number {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  word-break: break-word;
}

.b2b-order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: #fff;
}

@media (max-width: 640px) {
  .b2b-orders-head {
    display: grid;
  }

  .b2b-orders-head .btn {
    width: 100%;
    justify-content: center;
  }

  .b2b-order-card {
    align-items: stretch;
    flex-direction: column;
  }

  .b2b-order-card .btn {
    width: 100%;
    justify-content: center;
  }

  .b2b-order-number {
    font-size: 17px;
  }
}

/* === B2B client panel === */
.nav-form {
  display: inline;
}

.nav-logout {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.b2b-orders-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.b2b-orders-head h1 {
  margin-bottom: 4px;
}

.b2b-orders-list {
  display: grid;
  gap: 12px;
}

.b2b-order-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

.b2b-order-main {
  min-width: 0;
}

.b2b-order-number {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  word-break: break-word;
}

.b2b-order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: #fff;
}

@media (max-width: 640px) {
  .b2b-orders-head {
    display: grid;
  }

  .b2b-orders-head .btn {
    width: 100%;
    justify-content: center;
  }

  .b2b-order-card {
    align-items: stretch;
    flex-direction: column;
  }

  .b2b-order-card .btn {
    width: 100%;
    justify-content: center;
  }

  .b2b-order-number {
    font-size: 17px;
  }
}

.b2b-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.b2b-order-values {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 7px;
  color: var(--text);
  font-size: 14px;
}

@media (max-width: 640px) {
  .b2b-filters .btn {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }

  .b2b-order-values {
    display: grid;
    gap: 4px;
  }
}

.b2b-back-link {
  margin-bottom: 12px;
}

.b2b-back-link .btn {
  display: inline-flex;
}

@media (max-width: 640px) {
  .b2b-back-link .btn {
    width: 100%;
    justify-content: center;
  }
}

.b2b-back-link-bottom {
  margin-top: 14px;
}

/* === Production orders queue: mobile readability === */
.production-orders-table {
  table-layout: auto;
}

.production-orders-table th,
.production-orders-table td {
  vertical-align: top;
}

.production-orders-table__requester {
  max-width: 180px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.production-orders-table__assortment {
  max-width: 320px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.production-orders-table__systems {
  max-width: 220px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

@media (max-width: 720px) {
  .production-orders-table {
    min-width: 860px;
    font-size: 13px;
  }

  .production-orders-table th,
  .production-orders-table td {
    padding: 8px 6px;
  }

  .production-orders-table__systems {
    display: table-cell;
  }

  .production-orders-table th.production-orders-table__systems {
    display: table-cell;
  }

  .production-orders-table__requester {
    max-width: 120px;
  }

  .production-orders-table__assortment {
    max-width: 180px;
  }
}

/* === Production orders: system qty mini table === */
.production-systems-mini {
  display: grid;
  gap: 3px;
  min-width: 180px;
}

.production-systems-mini__row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  line-height: 1.25;
}

.production-systems-mini__row span {
  overflow-wrap: anywhere;
}

.production-systems-mini__row strong {
  text-align: right;
  white-space: nowrap;
}

/* === Production queue: compact family summary === */
.production-systems-mini {
  min-width: 120px;
  max-width: 150px;
}

.production-systems-mini__row {
  grid-template-columns: minmax(76px, 1fr) auto;
  gap: 6px;
}

.production-systems-mini__row span {
  white-space: nowrap;
}

/* === Production queue: rows must grow with system list === */
.production-orders-table tr,
.production-orders-table td {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
}

.production-orders-table td {
  vertical-align: top !important;
  white-space: normal !important;
  overflow: visible !important;
}

.production-orders-table__systems {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  white-space: normal !important;
  overflow: visible !important;
}

.production-systems-mini {
  display: grid;
  gap: 4px;
  min-width: 120px;
  max-width: 170px;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

.production-systems-mini__row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) auto;
  gap: 8px;
  align-items: start;
  line-height: 1.25;
  min-height: 18px;
}

.production-systems-mini__row span {
  white-space: normal !important;
  overflow-wrap: anywhere;
}

.production-systems-mini__row strong {
  white-space: nowrap;
  text-align: right;
}

/* === Table sort links === */
.table-sort-link {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

.table-sort-link:hover {
  text-decoration: underline;
}

/* === Fix: content bleeding under sticky topbar/header === */
.app-topbar,
.topbar,
.b2b-topbar,
.erp-topbar,
.layout-topbar,
.main-topbar,
.header,
.site-header {
  z-index: 1000;
  background: linear-gradient(90deg, #1f4fb8 0%, #57c7e8 100%);
  opacity: 1;
  backdrop-filter: none;
}

.app-shell,
.page,
.b2b-page,
.main-content,
.content {
  position: relative;
  z-index: 1;
}

/* Module dashboards */
.module-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.stat-label {
  font-size: 13px;
  opacity: .75;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
}

.module-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.module-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--border, #d8dde6);
  border-radius: 12px;
  background: var(--surface, #fff);
  color: inherit;
  text-decoration: none;
}

.module-tile:hover {
  border-color: var(--primary, #2563eb);
  transform: translateY(-1px);
}

.module-tile-icon {
  font-size: 24px;
  line-height: 1;
}

.module-tile-title {
  font-size: 16px;
  font-weight: 700;
}

.module-tile-desc {
  font-size: 13px;
  line-height: 1.35;
  opacity: .78;
}

/* Real dashboard tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 18px 0 26px;
}

.tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 150px;
  padding: 18px;
  border: 1px solid #d8dde6;
  border-radius: 18px;
  background: #ffffff;
  color: #0f172a;
  text-decoration: none;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.tile:hover {
  border-color: #2563eb;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.10);
  transform: translateY(-1px);
}

.tile-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 10px;
}

.tile-meta {
  font-size: 14px;
  line-height: 1.35;
  color: #64748b;
}

@media (max-width: 640px) {
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .tile {
    min-height: 132px;
    padding: 14px;
    border-radius: 16px;
  }

  .tile-title {
    font-size: 16px;
  }

  .tile-meta {
    font-size: 12px;
  }
}

/* Tasks / Organizer */
.task-quick-form {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.task-quick-form textarea {
    min-height: 54px;
    resize: vertical;
}

.task-quick-form .btn {
    min-width: 64px;
}

.task-filter-form {
    display: flex;
    gap: 12px;
    align-items: end;
}

.task-filter-form .form-control {
    max-width: 260px;
}

.task-card-list {
    display: grid;
    gap: 12px;
}

.task-card {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 16px;
    background: #fff;
}

.task-card-main {
    min-width: 0;
    flex: 1;
}

.task-card-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #111827;
}

.task-card-body {
    margin-top: 6px;
    color: #4b5563;
    white-space: pre-wrap;
}

.task-card-meta {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    color: #6b7280;
    font-size: 0.92rem;
}

.task-card-customer {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: #374151;
    font-size: 0.95rem;
}

.task-card-date {
    margin-top: 8px;
    color: #92400e;
    font-size: 0.92rem;
}

.task-card-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.task-status-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.task-status-form select {
    min-width: 170px;
}

@media (max-width: 700px) {
    .task-quick-form {
        gap: 8px;
    }

    .task-filter-form {
        align-items: stretch;
        flex-direction: column;
    }

    .task-filter-form .form-control {
        max-width: none;
    }

    .task-card {
        flex-direction: column;
    }

    .task-card-actions {
        align-items: stretch;
    }

    .task-status-form {
        align-items: stretch;
    }

    .task-status-form select {
        min-width: 0;
        width: 100%;
    }
}

.task-filter-field {
    min-width: 180px;
}

.task-filter-search {
    flex: 1;
}

.task-filter-clear {
    display: flex;
    align-items: end;
}

@media (max-width: 700px) {
    .task-filter-clear {
        align-items: stretch;
    }
}


/* ===== ORDER SNAPSHOT MOBILE CARDS ===== */
@media screen and (max-width: 760px) {
  .order-snapshot-room {
    margin-bottom: 14px !important;
    border-radius: 12px !important;
    overflow: hidden !important;
  }

  .order-snapshot-room-title {
    font-size: 16px !important;
    line-height: 1.25 !important;
  }

  .order-snapshot-scroll {
    overflow-x: visible !important;
  }

  .order-snapshot-table {
    min-width: 0 !important;
    width: 100% !important;
  }

  .order-snapshot-grid-header {
    display: none !important;
  }

  .order-snapshot-row {
    display: block !important;
    border-bottom: 1px solid #e5e7eb !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
    background: #fff !important;
  }

  .order-snapshot-row:last-child {
    border-bottom: 0 !important;
  }

  .order-snapshot-cell {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding: 5px 0 !important;
    border-right: 0 !important;
    text-align: right !important;
    min-width: 0 !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    line-height: 1.35 !important;
  }

  .order-snapshot-cell::before {
    content: attr(data-label);
    flex: 0 0 88px;
    max-width: 88px;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
  }

  .order-snapshot-cell-display_name {
    display: block !important;
    text-align: left !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    padding: 0 0 8px 0 !important;
    margin: 0 0 6px 0 !important;
    border-bottom: 1px solid #f1f5f9 !important;
  }

  .order-snapshot-cell-display_name::before {
    content: none !important;
    display: none !important;
  }

  .order-snapshot-cell-size {
    justify-content: flex-start !important;
    text-align: left !important;
  }

  .order-snapshot-cell-size div {
    display: inline !important;
  }

  .order-snapshot-cell-size div + div {
    margin-left: 4px !important;
  }

  .order-snapshot-cell-note {
    display: block !important;
    text-align: left !important;
  }

  .order-snapshot-cell-note::before {
    display: block !important;
    max-width: none !important;
    margin-bottom: 3px !important;
  }

  .order-snapshot-cell:has(> span:first-child:last-child) {
    display: none !important;
  }
}

/* ============================================================
 * Finance: sales summary report
 * ============================================================ */
.finance-sales-summary {
  max-width: 1280px;
}

.finance-sales-summary .finance-report-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  align-items: end;
}

.finance-sales-summary .finance-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
}

.finance-sales-summary .finance-kpi {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.finance-sales-summary .finance-kpi-label {
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}

.finance-sales-summary .finance-kpi-value {
  font-size: 18px;
  font-weight: 800;
  color: #111827;
}

.finance-sales-summary .finance-section-title {
  margin-top: 0;
  margin-bottom: 12px;
}

.finance-sales-summary .finance-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.finance-sales-summary .finance-table {
  width: 100%;
  min-width: 760px;
}

.finance-sales-summary .finance-table th,
.finance-sales-summary .finance-table td {
  white-space: nowrap;
}

.finance-sales-summary .finance-num {
  text-align: right;
}

@media (max-width: 720px) {
  .finance-sales-summary {
    padding: 8px;
  }

  .finance-sales-summary h1 {
    font-size: 22px;
    line-height: 1.15;
  }

  .finance-sales-summary .card {
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 14px;
  }

  .finance-sales-summary .finance-report-filters {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .finance-sales-summary .finance-report-filters .finance-filter-submit {
    grid-column: 1 / -1;
  }

  .finance-sales-summary .finance-report-filters button {
    width: 100%;
  }

  .finance-sales-summary .finance-kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .finance-sales-summary .finance-kpi {
    padding: 10px;
  }

  .finance-sales-summary .finance-kpi-label {
    font-size: 10px;
  }

  .finance-sales-summary .finance-kpi-value {
    font-size: 15px;
  }

  .finance-sales-summary .finance-mobile-cards {
    overflow: visible;
  }

  .finance-sales-summary .finance-mobile-cards table,
  .finance-sales-summary .finance-mobile-cards thead,
  .finance-sales-summary .finance-mobile-cards tbody,
  .finance-sales-summary .finance-mobile-cards tr,
  .finance-sales-summary .finance-mobile-cards th,
  .finance-sales-summary .finance-mobile-cards td {
    display: block;
    width: 100%;
  }

  .finance-sales-summary .finance-mobile-cards table {
    min-width: 0;
  }

  .finance-sales-summary .finance-mobile-cards thead {
    display: none;
  }

  .finance-sales-summary .finance-mobile-cards tr {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 9px 10px;
    margin-bottom: 10px;
    background: #fff;
  }

  .finance-sales-summary .finance-mobile-cards td {
    border: 0;
    padding: 5px 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    text-align: right !important;
    white-space: normal;
  }

  .finance-sales-summary .finance-mobile-cards td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #6b7280;
    text-align: left;
    flex: 0 0 42%;
  }

  .finance-sales-summary .finance-mobile-cards td[data-label="Klient"],
  .finance-sales-summary .finance-mobile-cards td[data-label="Grupa"] {
    display: block;
    text-align: left !important;
  }

  .finance-sales-summary .finance-mobile-cards td[data-label="Klient"]::before,
  .finance-sales-summary .finance-mobile-cards td[data-label="Grupa"]::before {
    display: block;
    margin-bottom: 3px;
  }
}


/* Production: station technology card links */
.production-technology-card-links {
  margin-bottom: 16px;
}

.production-technology-card-links__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
}

.production-technology-card-links__grid .btn {
  justify-content: center;
  text-align: center;
}

@media (max-width: 720px) {
  .production-technology-card-links__grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .production-technology-card-links__grid .btn {
    width: 100%;
  }
}
