/* FakePOS — "test bench" theme: blueprint backdrop, frosted cards, a dark glass top bar. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --ink: #0f1b33;
    --ink-soft: #2b3a55;
    --muted: #5a6a85;
    --line: #dfe6f1;
    --surface: rgba(255, 255, 255, 0.96);
    --surface-2: #f3f6fb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #e6eefe;
    --success: #16a34a;
    --success-soft: #dcfce7;
    --danger: #dc2626;
    --danger-soft: #fde2e2;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --navy: #121418;
    --board: #0c0d10;
    --graphite: rgba(18, 20, 24, 0.92);
    --radius: 12px;
    --radius-lg: 18px;
    --shadow: 0 12px 32px -14px rgba(6, 20, 52, 0.55), 0 2px 6px rgba(6, 20, 52, 0.12);
    --shadow-sm: 0 1px 2px rgba(6, 20, 52, 0.08);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Kept for older selectors */
    --primary-hover: var(--primary-dark);
    --gray-100: var(--surface-2);
    --gray-200: var(--line);
    --gray-500: #94a3b8;
    --gray-700: var(--muted);
    --gray-900: var(--ink);
}

/* The board colour sits on html (the canvas). If body had a background it would be painted
   over the drifting grid layer behind it. */
html {
    background-color: var(--board);
    background-image: radial-gradient(ellipse 90% 70% at 50% 25%, #1a1d23 0%, var(--board) 75%);
    background-attachment: fixed;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    color: var(--ink);
    min-height: 100dvh;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    background: transparent;
}

/* A drafting-board grid, drawn in CSS: grey lines and + marks. It drifts very slowly by exactly
   one grid cell per cycle (seamless), moved with transform so only the compositor works. */
.board {
    position: fixed;
    inset: -80px 0 0 -80px;
    z-index: -2;
    pointer-events: none;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cpath d='M40 36v8M36 40h8' stroke='%23a3abb8' stroke-opacity='0.45' stroke-width='1'/%3E%3C/svg%3E"),
        linear-gradient(rgba(255, 255, 255, 0.065) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.065) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 80px 80px, 80px 80px, 80px 80px, 16px 16px, 16px 16px;
    will-change: transform;
    animation: board-drift 120s linear infinite;
}

@keyframes board-drift {
    from { transform: translate3d(0, 0, 0); }
    to { transform: translate3d(80px, 80px, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .board { animation: none; }
}

/* The thin frame around the drawing area, as on a printed blueprint */
body::before {
    content: '';
    position: fixed;
    inset: 14px;
    z-index: -1;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    pointer-events: none;
}

h2, h3, h4 { letter-spacing: -0.01em; }

code { font-family: var(--mono); font-size: 0.85em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
/* Inside a code block the block sets the look; the inline-code chip must not apply per line. */
pre code { background: none; padding: 0; border-radius: 0; color: inherit; font-size: inherit; }

/* --- Top bar --- */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 20px;
    color: #fff;
    background: var(--graphite);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #60a5fa, #2563eb);
    box-shadow: 0 4px 14px -4px rgba(96, 165, 250, 0.8);
}

.brand-badge {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    padding: 3px 7px;
    border-radius: 6px;
    color: #1f1600;
    background: #facc15;
}

.nav-links { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }

.nav-link {
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    padding: 7px 13px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
}

.nav-link:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.nav-link.active { background: rgba(255, 255, 255, 0.95); color: var(--navy); }

/* Caution tape along the whole underside of the bar: this is a test bench */
.nav-hazard {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 8px;
    background: repeating-linear-gradient(-45deg, #facc15 0 11px, #15171a 11px 22px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

/* Caution strip under the bar (no longer used) */
.test-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 20px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #e9e3cf;
    background: rgba(18, 20, 24, 0.7);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.test-strip::before {
    content: '';
    flex: none;
    width: 46px;
    height: 10px;
    border-radius: 3px;
    background: repeating-linear-gradient(-45deg, #facc15 0 7px, #111827 7px 14px);
}

#app { padding: 32px 20px 48px; max-width: 1180px; margin: 0 auto; }

/* Page titles sit on the blueprint */
.page-title, .integrations-page > h2, .help-page > h2 {
    color: #fff;
    font-size: 1.6rem;
    margin-bottom: 4px;
    text-shadow: none;
}

.page-lead, .integrations-page > .status-line, .help-page > .lead {
    color: rgba(229, 231, 235, 0.75);
    margin-bottom: 18px;
    text-shadow: none;
}

/* --- Cards --- */
.card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 18px;
}

.card h3 { font-size: 1.05rem; margin-bottom: 10px; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 9px 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    font-size: 0.93rem;
    font-weight: 650;
    color: var(--ink);
    background: #fff;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.2s;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 16px -8px rgba(6, 20, 52, 0.45); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn-primary { color: #fff; border-color: transparent; background: linear-gradient(180deg, #3b82f6, var(--primary-dark)); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #2f74ec, #1a44c2); }
.btn-success { color: #fff; border-color: transparent; background: linear-gradient(180deg, #22c55e, #15803d); }
.btn-danger { color: #fff; border-color: transparent; background: linear-gradient(180deg, #ef4444, #b91c1c); }
.btn-sm { min-height: 34px; padding: 6px 13px; font-size: 0.86rem; border-radius: 9px; }
.btn-block { width: 100%; }

/* --- Forms --- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 650; margin-bottom: 5px; font-size: 0.86rem; color: var(--ink-soft); }

.form-control {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    font-size: 0.97rem;
    color: var(--ink);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea.form-control { min-height: auto; resize: vertical; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18); }
.form-control:disabled { background: var(--surface-2); color: var(--muted); }
select.form-control { appearance: auto; }

/* Keyboard focus must stay visible on every control. */
.btn:focus-visible, .nav-link:focus-visible, a:focus-visible, input[type="radio"]:focus-visible,
input[type="checkbox"]:focus-visible, input[type="range"]:focus-visible, summary:focus-visible {
    outline: 3px solid #93c5fd;
    outline-offset: 2px;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.badge-success { background: var(--success-soft); color: #166534; }
.badge-warning { background: var(--warning-soft); color: #92400e; }
.badge-danger { background: var(--danger-soft); color: #991b1b; }

/* --- Tables --- */
.product-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.9rem; }
.product-table th, .product-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.product-table thead th {
    position: sticky;
    top: 0;
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
}
.product-table thead th:first-child { border-top-left-radius: 10px; }
.product-table thead th:last-child { border-top-right-radius: 10px; }
.product-table tbody tr { transition: background 0.15s; }
.product-table tbody tr:hover { background: #f7f9fd; }

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    max-width: min(92vw, 560px);
    padding: 12px 20px;
    border-radius: 999px;
    color: #fff;
    font-weight: 600;
    background: rgba(24, 27, 32, 0.95);
    box-shadow: 0 14px 30px -10px rgba(4, 14, 40, 0.6);
    z-index: 1000;
    animation: toast-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.toast.success { background: rgba(21, 128, 61, 0.95); }
.toast.error { background: rgba(185, 28, 28, 0.95); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.96); }
    to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* Page content fades in on navigation */
#app > * { animation: page-in 0.32s ease both; }

@keyframes page-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    #app > *, .toast { animation: none; }
    .btn { transition: none; }
}

/* --- Utilities --- */
.hidden { display: none !important; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.text-muted { color: var(--muted); font-size: 0.86rem; }

/* --- Login --- */
.login-page .card { max-width: 400px; margin: 48px auto; padding: 28px; }
.login-page h2 { margin-bottom: 6px; }
.login-note {
    margin: 14px 0 18px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    color: #713f12;
    background: var(--warning-soft);
}

@media (max-width: 640px) {
    .nav { padding: 10px 12px; }
    .brand-badge { display: none; }
    #app { padding: 16px 12px 40px; }
    .card { padding: 16px; }
}

/* =====================================================================
   The top bar is the lane light.
   body[data-lane]: idle = calm green breathing, green = approved swell, red = intervention.
   Each layer fades as a whole when the state changes (transition on the layer), while the
   breathing runs on its ::before (animation). Keeping the two on separate elements is what
   stops the jumps/flicker you get when an animation and a transition share one property.
   Only opacity is animated, so the compositor does all the work.
   ===================================================================== */
.nav { isolation: isolate; }

.nav-light { position: absolute; inset: 0; z-index: -1; pointer-events: none; }

.nl-tint, .nl-edge, .nl-glow {
    position: absolute;
    opacity: 0;
    transition: opacity 1.4s ease;
    will-change: opacity;
    pointer-events: none;
}

.nl-tint::before, .nl-edge::before, .nl-glow::before {
    content: '';
    position: absolute;
    inset: 0;
    will-change: opacity;
}

.nl-tint { inset: 0; }
.nl-green::before { background: linear-gradient(90deg, rgba(21, 128, 61, 0.75), rgba(34, 197, 94, 0.5) 50%, rgba(21, 128, 61, 0.75)); }
.nl-red::before { background: linear-gradient(90deg, rgba(185, 28, 28, 0.97), rgba(248, 72, 72, 0.9) 50%, rgba(185, 28, 28, 0.97)); }

/* A bright line along the bottom edge, like the lit rim of a lamp */
.nl-edge { left: 0; right: 0; bottom: -1px; height: 2px; }
.nl-edge-green::before { background: linear-gradient(90deg, transparent, #4ade80 20%, #bbf7d0 50%, #4ade80 80%, transparent); box-shadow: 0 0 14px 2px rgba(74, 222, 128, 0.7); }
.nl-edge-red::before { background: linear-gradient(90deg, transparent, #f87171 20%, #fecaca 50%, #f87171 80%, transparent); box-shadow: 0 0 16px 3px rgba(248, 113, 113, 0.85); }

/* The light leaking out under the bar onto the board. It lives behind the page content
   (z-index -1 at body level), so it colours the background around the cards, not the cards. */
.page-glow { position: fixed; top: 0; left: 0; right: 0; height: 340px; z-index: -1; pointer-events: none; }
.nl-glow { left: 0; right: 0; top: 60px; height: 280px; }
.nl-glow-green::before {
    background:
        linear-gradient(180deg, rgba(74, 222, 128, 0.38) 0, rgba(74, 222, 128, 0) 46px),
        radial-gradient(ellipse 70% 100% at 50% 0%, rgba(74, 222, 128, 0.5), rgba(74, 222, 128, 0) 70%);
}
.nl-glow-red::before {
    background:
        linear-gradient(180deg, rgba(255, 82, 82, 0.6) 0, rgba(255, 82, 82, 0) 56px),
        radial-gradient(ellipse 80% 100% at 50% 0%, rgba(255, 70, 70, 0.72), rgba(255, 70, 70, 0) 72%);
}

/* State: which layers are on, and how strongly (fades over 1.4 s) */
body:not([data-lane]) .nl-green, body[data-lane="idle"] .nl-green { opacity: 0.75; }
body:not([data-lane]) .nl-edge-green, body[data-lane="idle"] .nl-edge-green { opacity: 0.7; }
body:not([data-lane]) .nl-glow-green, body[data-lane="idle"] .nl-glow-green { opacity: 0.45; }
body[data-lane="green"] .nl-green,
body[data-lane="green"] .nl-edge-green,
body[data-lane="green"] .nl-glow-green,
body[data-lane="red"] .nl-red,
body[data-lane="red"] .nl-edge-red,
body[data-lane="red"] .nl-glow-red { opacity: 1; }

/* Breathing: always running on the inner layer, so state changes never restart it abruptly */
.nl-green::before, .nl-edge-green::before, .nl-glow-green::before { animation: breathe-calm 6s ease-in-out infinite; }
.nl-red::before, .nl-edge-red::before { animation: breathe-alert 2.4s ease-in-out infinite; }
.nl-glow-red::before { animation: breathe-glow 2.4s ease-in-out infinite; }
/* Approved: extra steady, bright layers fade in on top of the calm green */
.nl-approve::before { background: linear-gradient(90deg, rgba(22, 163, 74, 0.85), rgba(74, 222, 128, 0.7) 50%, rgba(22, 163, 74, 0.85)); }
.nl-glow-approve::before {
    background:
        linear-gradient(180deg, rgba(110, 255, 160, 0.55) 0, rgba(110, 255, 160, 0) 56px),
        radial-gradient(ellipse 80% 100% at 50% 0%, rgba(74, 222, 128, 0.7), rgba(74, 222, 128, 0) 72%);
}
body[data-lane="green"] .nl-approve,
body[data-lane="green"] .nl-glow-approve { opacity: 1; }

@keyframes breathe-calm { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.85; } }
@keyframes breathe-alert { 0%, 100% { opacity: 0.8; } 50% { opacity: 1; } }
@keyframes breathe-glow { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .nl-tint::before, .nl-edge::before, .nl-glow::before { animation: none !important; opacity: 0.8; }
    .nl-tint, .nl-edge, .nl-glow { transition-duration: 0.3s; }
}

/* Till chip in the bar: which till the light follows, and its state */
.lane-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 340px;
    padding: 6px 12px;
    border-radius: 999px;
    color: #fff;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    transition: background 0.6s ease, border-color 0.6s ease;
}

.lane-chip:hover { background: rgba(255, 255, 255, 0.2); }
.lane-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lane-chip-dot {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 10px #4ade80;
    transition: background 0.6s ease, box-shadow 0.6s ease;
}

body[data-lane="red"] .lane-chip { background: rgba(127, 29, 29, 0.55); border-color: rgba(254, 202, 202, 0.6); }
body[data-lane="red"] .lane-chip-dot { background: #fecaca; box-shadow: 0 0 12px #f87171; animation: breathe-red 1.2s ease-in-out infinite; }

/* Nav link icons */
.nav-link { display: inline-flex; align-items: center; gap: 7px; }
.nav-icon { width: 17px; height: 17px; flex: none; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 1024px) {
    .nav-link span { display: none; }
    .nav-link { padding: 8px 10px; }
}

@media (max-width: 720px) {
    /* backdrop-filter would make the fixed tab bar position itself inside the bar */
    .nav { background: rgba(18, 20, 24, 0.96); padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
    .nav-brand { font-size: 1rem; }
    .brand-badge { display: none; }
    .lane-chip { max-width: 55vw; font-size: 0.8rem; padding: 5px 10px; }

    /* Bottom tab bar */
    .nav-links {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 150;
        display: flex;
        flex-wrap: nowrap;
        justify-content: space-around;
        gap: 0;
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        background: rgba(18, 20, 24, 0.97);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 -10px 30px -12px rgba(0, 0, 0, 0.6);
    }

    .nav-link {
        flex: 1;
        flex-direction: column;
        gap: 3px;
        min-height: 52px;
        padding: 6px 4px;
        border-radius: 12px;
        justify-content: center;
        font-size: 0.7rem;
    }

    .nav-link span { display: block; }
    .nav-icon { width: 22px; height: 22px; }
    .nav-link.active { background: rgba(255, 255, 255, 0.14); color: #fff; }

    .test-strip { font-size: 0.72rem; padding: 5px 14px; }
    #app { padding: 16px 12px calc(96px + env(safe-area-inset-bottom)); }
    .page-title, .integrations-page > h2, .help-page > h2 { font-size: 1.35rem; }
    .card { padding: 16px; border-radius: 16px; margin-bottom: 14px; }

    /* 16px inputs stop iOS from zooming in on focus; bigger touch targets */
    .form-control { font-size: 16px; min-height: 46px; }
    .btn { min-height: 44px; }
    .btn-sm { min-height: 40px; }

    .toast { bottom: calc(84px + env(safe-area-inset-bottom)); border-radius: 14px; }
}

/* Printed receipt (kassakvitto), js/kvitto.js: thermal paper, monospace, amounts right-aligned */
.kvitto {
    max-width: 340px;
    margin: 12px auto 0;
    padding: 18px 16px 14px;
    background: #fffef9;
    color: #1b1b1b;
    font-family: var(--mono);
    font-size: 0.8rem;
    line-height: 1.45;
    font-weight: 400;
    text-align: left;
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
    /* A torn edge at the bottom, like the end of a roll */
    -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat,
        conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 12px 8px repeat-x;
    mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat,
        conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 12px 8px repeat-x;
}
.kvitto hr { border: 0; border-top: 1px dashed #8a8a8a; margin: 8px 0; }
.kv-store { font-weight: 800; font-size: 1rem; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 2px; }
.kv-line { display: flex; justify-content: space-between; gap: 12px; }
.kv-line span:last-child { white-space: nowrap; }
.kv-sub { padding-left: 2.5em; }
.kv-total { font-weight: 800; font-size: 1rem; margin-bottom: 6px; }
.kv-vat { width: 100%; border-collapse: collapse; margin: 4px 0 8px; font-size: 0.75rem; }
.kv-vat th, .kv-vat td { text-align: right; padding: 0 0 0 6px; font-weight: 400; }
.kv-vat th:first-child, .kv-vat td:first-child { text-align: left; padding-left: 0; }
.kv-foot { text-align: center; font-size: 0.72rem; color: #555; }
