:root {
    --bg: #111111;
    --surface: #ffffff;
    --text: #1a1a1a;
    --muted: #5f6368;
    --accent: #0b6bcb;
    --accent-text: #ffffff;
    --danger: #b3261e;
    --border: #d0d4d9;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
    --radius: 14px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --surface: #1f2124;
        --text: #f1f3f4;
        --muted: #a8adb3;
        --border: #3c4043;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --surface: #1f2124;
    --text: #f1f3f4;
    --muted: #a8adb3;
    --border: #3c4043;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
    cursor: pointer;
    border: 0;
    border-radius: 10px;
    min-height: 48px;
    padding: 0 18px;
}

[hidden] {
    display: none !important;
}

/* ---- POS frame -------------------------------------------------------------------------------------- */

#pos-frame {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #ffffff;
}

/* ---- Floating dock ---------------------------------------------------------------------------------- */

.dock {
    position: fixed;
    right: calc(16px + var(--safe-right));
    bottom: calc(16px + var(--safe-bottom));
    display: flex;
    gap: 10px;
    z-index: 10;
}

.dock-btn {
    min-width: 56px;
    min-height: 56px;
    border-radius: 28px;
    box-shadow: var(--shadow);
    font-weight: 600;
}

.dock-scan {
    background: var(--accent);
    color: var(--accent-text);
    padding: 0 26px;
    font-size: 1.1rem;
}

.dock-settings {
    background: var(--surface);
    color: var(--text);
    font-size: 1.4rem;
    padding: 0;
    opacity: 0.85;
}

/* ---- Scanner sheet ---------------------------------------------------------------------------------- */

.scanner {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    height: min(46vh, 420px);
    background: #000000;
    z-index: 20;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.scanner-view {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.scanner-view video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.scanner-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.85);
    color: #ffffff;
}

.scanner-last {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.scanner-bar button {
    background: #ffffff;
    color: #000000;
    font-weight: 600;
}

/* ---- Settings dialog -------------------------------------------------------------------------------- */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 30;
}

.dialog {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 16px;
}

.dialog h2 {
    margin: 0;
    font-size: 1.3rem;
}

.dialog label {
    display: grid;
    gap: 6px;
    color: var(--muted);
}

.dialog input[type="url"] {
    font: inherit;
    font-size: 1rem;
    min-height: 48px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--text);
}

.dialog .check {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.dialog .check input {
    width: 22px;
    height: 22px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.primary {
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}

.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

/* ---- Status banner and toast ------------------------------------------------------------------------ */

.status {
    position: fixed;
    left: 16px;
    right: 16px;
    top: 16px;
    max-width: 640px;
    margin: 0 auto;
    background: var(--surface);
    color: var(--text);
    border-left: 4px solid var(--danger);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    z-index: 15;
}

.status p {
    margin: 0 0 12px;
    line-height: 1.4;
}

.status-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.status-actions button {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(88px + var(--safe-bottom));
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    background: #1a1a1a;
    color: #ffffff;
    padding: 12px 18px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    z-index: 40;
}

.toast.error {
    background: var(--danger);
}
