@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800&display=swap');

/* =====================================================================
   DESIGN TOKENS
   Stripe/Google aesthetic — clean, simple, professional
===================================================================== */
:root {
    /* Brand — one solid blue, no rainbow */
    --blue:         #2563eb;
    --blue-hover:   #1d4ed8;
    --blue-light:   #3b82f6;
    --blue-glow:    rgba(37, 99, 235, 0.22);
    --blue-tint:    rgba(37, 99, 235, 0.07);

    /* Semantic */
    --green:         #16a34a;
    --green-tint:    rgba(22, 163, 74, 0.08);
    --green-border:  rgba(22, 163, 74, 0.25);
    --red:           #dc2626;
    --red-tint:      rgba(220, 38, 38, 0.08);
    --amber:         #d97706;
    --amber-tint:    rgba(217, 119, 6, 0.08);
    --amber-border:  rgba(217, 119, 6, 0.25);
    --cyan:          #0891b2;
    --cyan-tint:     rgba(8, 145, 178, 0.08);

    /* Shape */
    --r-xs:  4px;
    --r-sm:  6px;
    --r-md:  10px;
    --r-lg:  14px;
    --r-xl:  20px;
    --r-pill: 999px;

    /* Motion */
    --ease:       cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out:   cubic-bezier(0, 0, 0.2, 1);
    --t-fast:     all 0.13s var(--ease);
    --t:          all 0.20s var(--ease);
    --t-slow:     all 0.35s var(--ease);
}

/* ── LIGHT ─────────────────────────────────────────────────────────── */
[data-theme="light"] {
    --bg:           #f7f8fc;
    --surface:      #ffffff;
    --surface-dim:  #f1f3f9;
    --surface-high: #ffffff;
    --border:       #e2e8f0;
    --border-soft:  rgba(15, 23, 42, 0.06);
    --text:         #0f172a;
    --text-2:       #475569;
    --text-3:       #94a3b8;
    --input-bg:     #ffffff;
    --input-border: #cbd5e1;

    --sh-xs:  0 1px 2px rgba(0,0,0,0.05);
    --sh-sm:  0 1px 4px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
    --sh:     0 4px 12px rgba(0,0,0,0.07), 0 2px 6px rgba(0,0,0,0.04);
    --sh-md:  0 8px 24px rgba(0,0,0,0.08), 0 3px 8px rgba(0,0,0,0.04);
    --sh-lg:  0 20px 48px rgba(0,0,0,0.10), 0 8px 18px rgba(0,0,0,0.06);
    --sh-overlay: 0 32px 72px rgba(0,0,0,0.14), 0 12px 28px rgba(0,0,0,0.08);

    --header-bg: rgba(247, 248, 252, 0.88);
    --blur:      blur(14px) saturate(160%);

    /* ── Legacy aliases (keep old var names resolving) ────────────────── */
    --primary:     var(--blue);
    --success:     var(--green);
    --error:       var(--red);
    --warning:     var(--amber);
    --info:        var(--cyan);
    --text-muted:  var(--text-2);
    --card:        var(--surface);
    --shadow:      var(--sh);
    --shadow-sm:   var(--sh-sm);
    --shadow-md:   var(--sh-md);
    --shadow-lg:   var(--sh-lg);
    --radius-md:   var(--r-md);
    --radius-sm:   var(--r-sm);
    --radius-lg:   var(--r-lg);
    --primary-glow: var(--blue-glow);
    --primary-light: var(--blue-tint);
}

/* ── DARK ──────────────────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg:           #0c0f18;
    --surface:      #131722;
    --surface-dim:  #0f1219;
    --surface-high: #1a1f2e;
    --border:       rgba(255, 255, 255, 0.07);
    --border-soft:  rgba(255, 255, 255, 0.04);
    --text:         #e8edf8;
    --text-2:       #8b9ab5;
    --text-3:       #4a566e;
    --input-bg:     rgba(255, 255, 255, 0.04);
    --input-border: rgba(255, 255, 255, 0.10);

    --sh-xs:  0 1px 2px rgba(0,0,0,0.3);
    --sh-sm:  0 1px 4px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.2);
    --sh:     0 4px 16px rgba(0,0,0,0.40), 0 2px 6px rgba(0,0,0,0.2);
    --sh-md:  0 8px 28px rgba(0,0,0,0.48), 0 3px 10px rgba(0,0,0,0.25);
    --sh-lg:  0 20px 52px rgba(0,0,0,0.55), 0 8px 22px rgba(0,0,0,0.3);
    --sh-overlay: 0 32px 80px rgba(0,0,0,0.65), 0 12px 32px rgba(0,0,0,0.4);

    --header-bg: rgba(12, 15, 24, 0.88);
    --blur:      blur(16px) saturate(180%);

    /* ── Legacy aliases ───────────────────────────────────────────────── */
    --primary:     var(--blue);
    --success:     var(--green);
    --error:       var(--red);
    --warning:     var(--amber);
    --info:        var(--cyan);
    --text-muted:  var(--text-2);
    --card:        var(--surface);
    --shadow:      var(--sh);
    --shadow-sm:   var(--sh-sm);
    --shadow-md:   var(--sh-md);
    --shadow-lg:   var(--sh-lg);
    --radius-md:   var(--r-md);
    --radius-sm:   var(--r-sm);
    --radius-lg:   var(--r-lg);
    --primary-glow: var(--blue-glow);
    --primary-light: var(--blue-tint);
}

/* =====================================================================
   RESET & BASE
===================================================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.6;
    font-size: 15px;
}

/* Subtle top gradient accent — thin, tasteful */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--blue), transparent);
    z-index: 1000;
    opacity: 0.6;
}

/* =====================================================================
   LAYOUT
===================================================================== */
.app-container {
    max-width: 840px;
    margin: 0 auto;
    padding: 0 20px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    position: relative;
}

/* =====================================================================
   HEADER — sticky, frosted
===================================================================== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    margin-bottom: 28px;
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--header-bg);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-bottom: 1px solid var(--border);
    /* Compensate for app-container padding */
    margin-left: -20px;
    margin-right: -20px;
    padding: 0 20px;
}

.logo-container img {
    height: 34px;
    width: auto;
    object-fit: contain;
    display: block;
}

/* =====================================================================
   SURFACE / CARD
   No blur on content cards — Stripe uses flat white cards
===================================================================== */
.glass {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.glass:hover {
    box-shadow: var(--sh);
    border-color: rgba(37, 99, 235, 0.18);
}

/* =====================================================================
   TYPOGRAPHY HELPERS
===================================================================== */
.label-upper {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 6px;
}

/* =====================================================================
   BUTTONS
===================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    min-height: 40px;
    border: none;
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: var(--t);
    white-space: nowrap;
    flex-shrink: 0;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
}

/* Primary — solid blue, Stripe-style */
.btn-primary {
    background: var(--blue);
    color: #ffffff;
    box-shadow: var(--sh-xs), inset 0 1px 0 rgba(255,255,255,0.12);
}
.btn-primary:hover {
    background: var(--blue-hover);
    box-shadow: var(--sh-sm), 0 0 0 3px var(--blue-glow);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--sh-xs);
}

/* Ghost — minimal, secondary action */
.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--surface-dim);
    color: var(--text);
    border-color: var(--input-border);
}
.btn-ghost:active { background: var(--surface-dim); }

/* Danger */
.btn-danger {
    background: var(--red);
    color: #ffffff;
    box-shadow: var(--sh-xs);
}
.btn-danger:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: var(--sh-sm);
}

.back-btn { margin-bottom: 20px; margin-top: 8px; }

/* Split item */
.btn-split-item {
    padding: 0 !important;
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    background: var(--blue-tint) !important;
    border: 1px solid rgba(37,99,235,0.18) !important;
    color: var(--blue) !important;
    margin-left: 4px;
    flex-shrink: 0;
}
.btn-split-item:hover {
    background: var(--blue) !important;
    color: #fff !important;
    border-color: var(--blue) !important;
    transform: scale(1.1) !important;
}
.btn-split-item svg { flex-shrink: 0; pointer-events: none; }

/* =====================================================================
   FORMS
===================================================================== */
.form-group { margin-bottom: 16px; }

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-2);
}

input, select, textarea {
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: var(--t);
    -webkit-appearance: none;
    appearance: none;
}

select {
    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='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    padding-right: 36px;
    cursor: pointer;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-glow);
}

input::placeholder, textarea::placeholder { color: var(--text-3); }

textarea { resize: vertical; min-height: 80px; line-height: 1.6; }

.divider-or {
    position: relative;
    text-align: center;
    margin: 20px 0;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-3);
}
.divider-or::before, .divider-or::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 24px);
    height: 1px;
    background: var(--border);
}
.divider-or::before { left: 0; }
.divider-or::after  { right: 0; }

/* =====================================================================
   DASHBOARD GRID
===================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-top: 8px;
}

.dash-card {
    padding: 22px 20px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-radius: var(--r-lg);
    transition: var(--t);
}
.dash-card:hover {
    box-shadow: var(--sh-md);
    border-color: rgba(37, 99, 235, 0.25);
    transform: translateY(-2px);
}
.dash-card:active { transform: translateY(0); box-shadow: var(--sh-sm); }

.dash-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-dim);
}

.dash-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
    margin: 0;
}
.dash-card p {
    font-size: 0.8rem;
    color: var(--text-2);
    line-height: 1.45;
    margin: 0;
}

/* =====================================================================
   LOGIN
===================================================================== */
.login-page-wrap {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
}

.login-card-wrap {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo {
    display: block;
    height: 64px;
    margin: 0 auto 28px;
    object-fit: contain;
}

.login-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--text-2);
    margin-bottom: 28px;
}

.login-card {
    text-align: left;
}

/* =====================================================================
   WIZARD
===================================================================== */
.wizard-header { margin-bottom: 24px; }

.wizard-steps {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-bottom: 12px;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 60px;
}

.step-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-3);
    transition: var(--t);
    flex-shrink: 0;
}
.step-item.active .step-circle {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
    box-shadow: 0 0 0 4px var(--blue-glow);
}
.step-item.completed .step-circle {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.step-label {
    font-size: 0.67rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: var(--t);
}
.step-item.active .step-label,
.step-item.completed .step-label { color: var(--text); }

.step-connector {
    flex: 1;
    height: 1.5px;
    background: var(--border);
    margin: 0 6px;
    margin-top: 17px;
    border-radius: 2px;
    transition: background 0.3s ease;
}
.step-connector.active   { background: var(--blue); }
.step-connector.completed { background: var(--green); }

.wizard-card {
    padding: 28px;
    margin-bottom: 14px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
    letter-spacing: -0.01em;
}
.section-title svg { opacity: 0.45; flex-shrink: 0; }

.customer-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 12px;
    border-radius: var(--r-pill);
    background: var(--blue-tint);
    border: 1px solid rgba(37,99,235,0.2);
    color: var(--blue);
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 10px;
}

.selected-customer-badge {
    padding: 11px 14px;
    border-radius: var(--r-md);
    background: var(--green-tint);
    border: 1px solid var(--green-border);
    color: var(--green);
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 9px;
}

/* =====================================================================
   ORDER ITEM CARDS
===================================================================== */
.order-item-card {
    background: var(--surface-dim);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 16px;
    margin-bottom: 10px;
    transition: var(--t-fast);
}
.order-item-card .item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 8px;
}

.item-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: var(--r-pill);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}
.badge-IDA             { background: var(--blue-tint);  color: var(--blue); }
.badge-Maska           { background: rgba(124, 58, 237, 0.08); color: #7c3aed; }
.badge-Tlačna          { background: var(--cyan-tint);  color: var(--cyan); }
.badge-Tlačna-posoda   { background: var(--cyan-tint);  color: var(--cyan); }
.badge-Pljučni-avtomat { background: var(--amber-tint); color: var(--amber); }

/* =====================================================================
   SERVICE CHECKBOXES
===================================================================== */
.services-label {
    font-size: 0.71rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 10px;
    margin-top: 14px;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 7px;
}

.service-checkbox-label {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: var(--t-fast);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    min-height: 42px;
    user-select: none;
}
.service-checkbox-label:hover {
    border-color: var(--blue);
    background: var(--blue-tint);
}
.service-checkbox-label.checked {
    background: var(--blue-tint);
    border-color: var(--blue);
}

/* Status variants */
.service-checkbox-label.service-status-pending {
    border: 1.5px solid var(--amber) !important;
    background: var(--amber-tint) !important;
}
.service-checkbox-label.service-status-pending .service-text {
    font-weight: 700;
    color: var(--amber);
}
.service-checkbox-label.service-status-done {
    border: 1.5px solid var(--green) !important;
    background: var(--green-tint) !important;
}
.service-checkbox-label.service-status-done .service-text {
    font-weight: 700;
    color: var(--green);
}
.service-checkbox-label.service-status-done .checkmark {
    background: var(--green);
    border-color: var(--green);
}
.service-checkbox-label.exclusive-disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.service-checkbox-label .checkmark {
    width: 17px;
    height: 17px;
    min-width: 17px;
    border: 1.5px solid var(--input-border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--t-fast);
    background: var(--input-bg);
    flex-shrink: 0;
}
.service-checkbox-label.checked .checkmark {
    background: var(--blue);
    border-color: var(--blue);
}
.service-checkbox-label.checked .checkmark::after {
    content: '✓';
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}
.service-checkbox-label input[type="checkbox"] { display: none; }

.service-text {
    font-size: 0.82rem;
    line-height: 1.3;
    font-weight: 500;
    color: var(--text);
}

.service-count {
    background: var(--surface-dim);
    border: 1px solid var(--border);
    padding: 1px 8px;
    border-radius: var(--r-pill);
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-3);
    transition: var(--t-fast);
    flex-shrink: 0;
    margin-left: auto;
}
.service-count.all-checked {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

/* =====================================================================
   SIGNATURE PAD
===================================================================== */
.sig-wrap { margin-top: 4px; }

.signature-container {
    background: #fff;
    border-radius: var(--r-sm);
    overflow: hidden;
    border: 1px solid var(--input-border);
    transition: border-color 0.2s ease;
}
.signature-container:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-glow);
}

canvas.signature-pad {
    width: 100%;
    height: 130px;
    cursor: crosshair;
    display: block;
    touch-action: none;
}

.sig-preview {
    width: 100%;
    height: 110px;
    object-fit: contain;
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: #fff;
}

.sig-redo-btn { font-size: 0.75rem; margin-top: 6px; }

/* =====================================================================
   SEARCH DROPDOWN
===================================================================== */
.search-dropdown { position: relative; }

.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 300;
    max-height: 240px;
    overflow-y: auto;
    padding: 4px;
    box-shadow: var(--sh-lg);
    border-radius: var(--r-md);
}

.search-item {
    padding: 10px 13px;
    cursor: pointer;
    border-radius: var(--r-sm);
    transition: var(--t-fast);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
}
.search-item:hover { background: var(--blue); color: #fff; }

/* =====================================================================
   LIST CARDS — nalog, prevzem, archive
===================================================================== */
.nalog-card {
    padding: 14px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    transition: var(--t);
    border-radius: var(--r-lg);
}
.nalog-card:hover {
    box-shadow: var(--sh-md);
    border-color: rgba(37,99,235,0.2);
    transform: translateX(2px);
}
.nalog-card:active { transform: translateX(0); }

.nalog-card-left h4 {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 2px;
    color: var(--text);
}
.nalog-card-left p {
    font-size: 0.78rem;
    color: var(--text-2);
    line-height: 1.4;
    margin: 0;
}

.nalog-badge {
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}
.badge-open     { background: var(--amber-tint);  color: var(--amber);  border: 1px solid var(--amber-border); }
.badge-finished { background: var(--green-tint);  color: var(--green);  border: 1px solid var(--green-border); }
.badge-prevzet  { background: var(--cyan-tint);   color: var(--cyan); }

/* =====================================================================
   AUTO-SAVE INDICATOR
===================================================================== */
.autosave-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 11px;
    border-radius: var(--r-pill);
    font-size: 0.74rem;
    font-weight: 600;
    background: var(--green-tint);
    color: var(--green);
    border: 1px solid var(--green-border);
    animation: fadeIn 0.25s ease;
}
.autosave-indicator.saving {
    background: var(--amber-tint);
    color: var(--amber);
    border-color: var(--amber-border);
}

/* =====================================================================
   ITEM DETAIL
===================================================================== */
.detail-item-card {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 16px;
    margin-bottom: 10px;
    background: var(--surface-dim);
    transition: var(--t-fast);
}
.detail-item-card:hover { border-color: rgba(37,99,235,0.2); }

.sub-sn-input { max-width: 160px; }

.detail-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

/* =====================================================================
   ADMIN TABS
===================================================================== */
.admin-tabs-bar {
    display: flex;
    overflow-x: auto;
    margin-bottom: 14px;
    padding: 4px;
    gap: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-radius: var(--r-lg);
    background: var(--surface-dim);
    border: 1px solid var(--border);
}
.admin-tabs-bar::-webkit-scrollbar { display: none; }

.admin-tab {
    flex: 1;
    min-width: 90px;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--text-2);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: var(--t-fast);
    border-radius: var(--r-md);
    white-space: nowrap;
    font-family: inherit;
}
@media (max-width: 640px) {
    .admin-tab { flex: 0 0 auto; min-width: 100px; font-size: 0.78rem; }
}
.admin-tab:hover { color: var(--text); background: var(--surface); }
.admin-tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--sh-xs);
}

.admin-panel { animation: fadeIn 0.25s ease; }

.admin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border-soft);
    transition: var(--t-fast);
    gap: 12px;
}
@media (max-width: 500px) {
    .admin-item { flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px 4px; }
    .admin-item > div:last-child { width: 100%; justify-content: flex-end; }
}
.admin-item:last-child { border-bottom: none; }
.admin-item:hover { background: var(--surface-dim); border-radius: var(--r-sm); padding: 12px 8px; margin: 0 -4px; }

/* =====================================================================
   CENIK TABLE
===================================================================== */
.cenik-table { width: 100%; border-collapse: collapse; }
.cenik-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 0.71rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    border-bottom: 1.5px solid var(--border);
}
.cenik-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 0.88rem;
    color: var(--text);
}
.cenik-table tr:last-child td { border-bottom: none; }
.cenik-group-header td {
    font-weight: 700;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-top: 14px;
    color: var(--blue);
    background: var(--blue-tint);
}

.price-input {
    width: 100px !important;
    text-align: right;
    padding: 6px 10px !important;
    font-weight: 600;
}

/* =====================================================================
   TOAST
===================================================================== */
#toast-container {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    right: 16px;
    z-index: 4000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
    max-width: calc(100vw - 32px);
}

.toast {
    pointer-events: auto;
    min-width: 260px;
    max-width: 360px;
    padding: 12px 16px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.865rem;
    font-weight: 500;
    animation: toastIn 0.32s var(--ease-out);
    box-shadow: var(--sh-overlay);
    background: var(--surface-high);
    border: 1px solid var(--border);
}
.toast.removing { animation: toastOut 0.24s ease forwards; }
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-info    { border-left: 3px solid var(--blue); }
.toast-warning { border-left: 3px solid var(--amber); }

@keyframes toastIn  { from { opacity:0; transform:translateY(12px) scale(0.97); } to { opacity:1; transform:translateY(0) scale(1); } }
@keyframes toastOut { to   { opacity:0; transform:translateY(6px)  scale(0.96); } }

/* =====================================================================
   LOADER
===================================================================== */
.animate-spin { animation: spin 0.85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   VIEWS
===================================================================== */
.view { display: none; }
.view.active {
    display: block;
    animation: fadeIn 0.28s var(--ease-out);
}

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

/* =====================================================================
   EMPTY STATE
===================================================================== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-3);
    font-size: 0.875rem;
}

/* =====================================================================
   SHIMMER
===================================================================== */
.shimmer {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
    background-size: 200% 100%;
    animation: shimmer 1.6s infinite;
    border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* =====================================================================
   UTILITY CLASSES — compatibility & helpers
===================================================================== */

/* Glass-styled textarea/input (used in side drawer) */
.glass-input {
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: var(--t);
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
    -webkit-appearance: none;
    appearance: none;
}
.glass-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-glow);
}

/* Glass-sub: lighter card inside a card (piece manager rows) */
.glass-sub {
    background: var(--surface-dim);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

/* Button size variants */
.btn-sm  { padding: 6px 12px; min-height: 32px; font-size: 0.8rem; }
.btn-xs  { padding: 4px 8px;  min-height: 28px; font-size: 0.75rem; border-radius: var(--r-xs); }

/* =====================================================================
   SCROLLBARS — invisible but functional
===================================================================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* =====================================================================
   PIECE MANAGER
===================================================================== */
.piece-manager-container { display: flex; flex-direction: column; gap: 12px; }

.bulk-actions-toolbar {
    padding: 12px 16px;
    background: var(--blue-tint);
    border: 1px solid rgba(37,99,235,0.18);
    border-radius: var(--r-md);
}

.piece-row {
    padding: 13px 15px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    transition: var(--t-fast);
    background: var(--surface-dim);
}
.piece-row:hover { border-color: var(--blue); }

.piece-row-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.piece-index {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue);
    color: #fff;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.piece-sn-input {
    flex: 1;
    background: transparent;
    border: 1px solid var(--input-border);
    border-radius: var(--r-xs);
    padding: 6px 10px;
    font-size: 0.875rem;
}

.piece-services { display: flex; flex-wrap: wrap; gap: 5px; }

.svc-mini-btn {
    padding: 4px 10px;
    border-radius: var(--r-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.73rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--t-fast);
    color: var(--text-2);
}
.svc-mini-btn.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}
.svc-mini-btn.locked {
    cursor: default;
    opacity: 0.7;
}
.svc-mini-btn.active.locked {
    background: var(--text-3);
    border-color: var(--text-3);
}

/* =====================================================================
   ITEM GROUP CARD
===================================================================== */
.item-group-card {
    padding: 16px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: var(--t);
    background: var(--surface-dim);
}
.item-group-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--sh-md);
    border-color: rgba(37,99,235,0.22);
}

.progress-pill {
    padding: 2px 10px;
    background: var(--blue-tint);
    color: var(--blue);
    border-radius: var(--r-pill);
    font-size: 0.67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid rgba(37,99,235,0.18);
}

.order-meta {
    padding: 12px 14px;
    border-radius: var(--r-md);
    margin-bottom: 18px;
    border: 1px solid var(--border);
    background: var(--surface-dim);
}
.order-meta span {
    font-size: 0.79rem;
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-2);
}

/* =====================================================================
   SUBITEMS TABLE
===================================================================== */
.subitems-service-col {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
}
.subitems-service-col .service-checkbox-label {
    width: auto;
    justify-content: flex-start;
    padding: 4px 10px;
    min-height: 34px;
    font-size: 0.75rem;
    margin: 0;
}

.subitems-table th {
    color: var(--text-3);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    padding: 7px 10px;
}
.subitems-table td {
    border-bottom: 1px solid var(--border-soft);
    padding: 7px 10px;
    font-size: 0.865rem;
}

.sub-sn-input {
    border: 1px solid var(--input-border);
    border-radius: var(--r-xs) !important;
    background: var(--input-bg);
    max-width: 160px;
}
.sub-sn-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px var(--blue-glow) !important;
}

/* =====================================================================
   MINI SVC ICONS
===================================================================== */
.mini-svc {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.63rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--t-fast);
    background: var(--input-bg);
    color: var(--text-3);
}
.mini-svc:hover { border-color: var(--blue); color: var(--blue); }
.mini-svc.active { background: var(--green); border-color: var(--green); color: #fff; }

/* =====================================================================
   SIDE DRAWER
===================================================================== */
.side-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--t-slow);
    display: flex;
    justify-content: flex-end;
}
.side-drawer-overlay.active { opacity: 1; visibility: visible; }

.side-drawer-content {
    width: 100%;
    max-width: 560px;
    height: 100%;
    background: var(--surface);
    box-shadow: var(--sh-overlay);
    transform: translateX(100%);
    transition: transform 0.3s var(--ease);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
}
.side-drawer-overlay.active .side-drawer-content { transform: translateX(0); }

.side-drawer-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.side-drawer-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.side-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 22px;
}
.side-drawer-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    background: var(--surface);
}

/* =====================================================================
   SAFE AREA
===================================================================== */
@supports (padding: max(0px)) {
    .app-container {
        padding-left:  max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
}

/* =====================================================================
   RESPONSIVE — TABLET ≤768px
===================================================================== */
@media (max-width: 768px) {
    .form-row-3 { grid-template-columns: 1fr 1fr; }
    .wizard-card { padding: 20px; }

    header {
        margin-left: -16px;
        margin-right: -16px;
        padding: 0 16px;
    }
    .app-container { padding-left: 16px; padding-right: 16px; }
}

/* =====================================================================
   RESPONSIVE — MOBILE ≤640px
===================================================================== */
@media (max-width: 640px) {
    body { font-size: 14px; }

    .app-container { padding-left: 12px; padding-right: 12px; }
    header { margin-left: -12px; margin-right: -12px; padding: 0 12px; height: 54px; }

    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .dashboard-grid .dash-card { grid-column: span 1 !important; }
    #admin-card              { grid-column: span 2 !important; }
    #pwa-install-container   { grid-column: span 2 !important; }

    .wizard-card { padding: 14px; }
    .step-label  { display: none; }
    .step-connector { margin-top: 16px; }
    .step-circle { width: 30px; height: 30px; font-size: 0.8rem; }

    .services-grid { grid-template-columns: 1fr 1fr; }
    canvas.signature-pad { height: 110px; }

    #toast-container { left: 10px; right: 10px; bottom: max(12px, env(safe-area-inset-bottom)); }
    .toast { min-width: auto; font-size: 0.82rem; }

    /* Prevent iOS font zoom on input focus */
    input, select, textarea { font-size: 16px; }

    .dash-card { padding: 16px 14px; }
    .dash-icon { width: 38px; height: 38px; }
    .dash-card h3 { font-size: 0.88rem; }
    .dash-card p  { font-size: 0.74rem; }
}

/* =====================================================================
   RESPONSIVE — SMALL MOBILE ≤400px
===================================================================== */
@media (max-width: 400px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-grid .dash-card { grid-column: span 1 !important; }
    #admin-card, #pwa-install-container { grid-column: span 1 !important; }
    .services-grid { grid-template-columns: 1fr; }
    .price-input { width: 80px !important; }
}

/* =====================================================================
   PRINT
===================================================================== */
@media print {
    header, .btn, #loader, #admin-modal, #toast-container { display: none !important; }
    body { background: #fff; color: #000; }
    .glass { border: 1px solid #ddd; box-shadow: none; backdrop-filter: none; }
}

/* =====================================================================
   SERVICE SELECTION UI (Pills/Toggles)
===================================================================== */
.services-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    margin-bottom: 10px;
}

.services-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.service-checkbox-label {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 8px 14px;
    background: var(--surface-dim);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-2);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.service-checkbox-label:hover {
    background: var(--surface-high);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.service-checkbox-label.checked {
    background: var(--blue-tint);
    border-color: var(--blue);
    color: var(--blue);
    box-shadow: 0 2px 4px rgba(37,99,235,0.1);
}

.service-checkbox-label input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Hide the old checkmark span if it exists in templates */
.service-checkbox-label .checkmark {
    display: none;
}

/* Service tag in cards */
.service-tag {
    font-size: 0.7rem;
    padding: 2px 8px;
    background: var(--surface-high);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-2);
    font-weight: 600;
}
