
/* Allow text selection globally */
body {
    -webkit-user-select: auto;
    -moz-user-select: auto;
    -ms-user-select: auto;
    user-select: auto;
}
/* Extracted from index.html */

/* =========================================================================
   RAHUNOK DESIGN LANGUAGE
   Quiet Financial Interface: Calm, Precise, Immediate.
   ========================================================================= */
:root, [data-theme="dark"] {
    /* --- Background & Surfaces --- */
    --bg-page: #0d0e13;
    --bg-card: #16181f;          /* Solid surface, NO border */
    --surface-subtle: #1d2029;   /* For secondary blocks */
    --surface-hover: #242936;
    
    --bg-glass: rgba(22, 24, 31, 0.85); /* Only for modals/headers */
    --blur-glass: blur(40px);

    /* --- Typography & Text --- */
    --text-main: #f5f6f8;
    --text-muted: rgba(245, 246, 248, 0.55);
    --text-eyebrow: rgba(245, 246, 248, 0.35);

    /* --- Brand & Semantic Colors --- */
    /* Brand neutral */
    --brand-main: #ffffff;
    --brand-fg: #0d0e13;

    /* Semantic */
    --success: #30d158;
    --action: #0a84ff;
    --warning: #ff9f0a;
    --danger: #ff453a;

    --color-emerald-bg: rgba(48, 209, 88, 0.12);
    --color-emerald-text: #30d158;
    --color-sky-bg: rgba(10, 132, 255, 0.12);
    --color-sky-text: #0a84ff;
    --color-amber-bg: rgba(255, 159, 10, 0.12);
    --color-amber-text: #ff9f0a;
    --color-red-bg: rgba(255, 69, 58, 0.12);
    --color-red-text: #ff453a;

    /* --- Controls (Inputs, Active States) --- */
    --border-control: rgba(255, 255, 255, 0.12);
    --divider: rgba(255, 255, 255, 0.08);

    /* Buttons */
    --btn-primary-bg: #ffffff;
    --btn-primary-text: #0d0e13;

    /* --- Spatial System & Radii --- */
    /* 8-point system */
    --space-4: 4px;
    --space-8: 8px;
    --space-12: 12px;
    --space-16: 16px;
    --space-24: 24px;
    --space-32: 32px;
    --space-48: 48px;
    --space-64: 64px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* --- Legacy Aliases (Will be phased out) --- */
    --order-bg: var(--bg-page);
    --order-surface: var(--bg-card);
    --order-surface-2: var(--surface-subtle);
    --order-text: var(--text-main);
    --order-text-dim: var(--text-muted);
    --order-cta: var(--btn-primary-bg);
    --order-cta-text: var(--btn-primary-text);
    --card-border: transparent; /* NO borders on cards */
    --card-shadow: none;        /* NO shadows on flat UI */
    --card-bg: var(--bg-card);
    --accent: var(--action);

    --sidebar-w: 260px;
    --header-h: 64px;
    /* --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; */
    --font-stack: Manrope, Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif !important;
    --ease-apple: cubic-bezier(0.2, 0.8, 0.2, 1);
}

[data-theme="light"] {
    --bg-page: #f5f6f8;
    --bg-card: #ffffff;
    --surface-subtle: #eeeff3;
    --surface-hover: #e2e4ea;
    
    --bg-glass: rgba(255, 255, 255, 0.90);

    --text-main: #11141a;
    --text-muted: #64748b;
    --text-eyebrow: #94a3b8;

    --brand-main: #11141a;
    --brand-fg: #ffffff;

    --success: #10b981;
    --action: #007aff;
    --warning: #f59e0b;
    --danger: #ef4444;

    --color-emerald-bg: #ecfdf5;
    --color-emerald-text: #047857;
    --color-sky-bg: #f0f9ff;
    --color-sky-text: #0369a1;
    --color-amber-bg: #fffbeb;
    --color-amber-text: #b45309;
    --color-red-bg: #fef2f2;
    --color-red-text: #b91c1c;

    --border-control: rgba(0, 0, 0, 0.12);
    --divider: rgba(0, 0, 0, 0.08);

    --btn-primary-bg: #11141a;
    --btn-primary-text: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-stack);
    -webkit-tap-highlight-color: transparent;
}

input, textarea, select {
    user-select: text;
    -webkit-user-select: text;
}

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.app-layout {
    display: flex;
    width: 100vw;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--divider);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    padding: 20px 16px;
    transition: transform 0.3s var(--ease-apple), background 0.25s ease, border-color 0.25s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}
.sidebar.mobile-show {
    transform: translateX(0) !important;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 20px;
    border-bottom: 1px solid var(--divider);
    margin-bottom: 18px;
    text-decoration: none;
    color: var(--text-main);
}

.merchant-avatar-brand {
    width: 38px;
    height: 38px;
    border-radius: 19px;
    background: linear-gradient(135deg, #10B981, #047857);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 19px;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}

.brand-title-wrap { display: flex; flex-direction: column; }
.brand-title {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 6px;
}
.brand-sub { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
}

.nav-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-eyebrow);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 12px 10px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 14px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    transition: all 0.2s var(--ease-apple);
    cursor: pointer;
    border: 1px solid transparent;
}

.nav-item:hover { background: var(--surface-subtle); color: var(--text-main); }
.nav-item.active {
    background: var(--surface-subtle);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}
.nav-item.active .nav-icon-badge { background: var(--brand-main); color: var(--brand-fg); }
.nav-icon-badge {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: var(--surface-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--ease-apple);
}
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s var(--ease-apple);
}

.nav-badge-pill {
    margin-left: auto;
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    background: rgba(48, 209, 88, 0.15);
    color: var(--accent);
}

.sidebar-footer {
    padding-top: 14px;
    border-top: 1px solid var(--order-divider);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.role-pill-switch {
    display: flex;
    background: var(--order-surface-2);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 3px;
}

.role-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--order-text-dim);
    font-size: 12px;
    font-weight: 700;
    padding: 7px 8px;
    border-radius: 11px;
    cursor: pointer;
    transition: all 0.25s var(--ease-apple);
}

.role-btn.active {
    background: #ffffff;
    color: #000000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

.user-profile-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--order-surface-2);
    border-radius: 16px;
    border: 1px solid var(--card-border);
}

.user-name {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--order-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role-label {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
}

/* Main Area */
.main-wrapper {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s var(--ease-apple);
}

.main-wrapper.expanded {
    margin-left: 0;
}

.top-header {
    height: var(--header-h);
    border-bottom: 1px solid var(--order-divider);

    backdrop-filter: blur(30px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.pay-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    background: var(--order-surface-2);
    border-radius: 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--order-text);
    border: 1px solid var(--card-border);
}
.st-dot { width: 7px; height: 7px; border-radius: 4px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

.btn-cta {
    height: 44px;
    background: var(--order-cta);
    color: var(--order-cta-text);
    border: none;
    border-radius: 22px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.005em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 20px;
    transition: all 0.25s var(--ease-spring);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.14);
    text-decoration: none;
}
.btn-cta:active { transform: scale(0.97); }

.btn-sec {
    height: 40px;
    background: var(--order-surface-2);
    color: var(--order-text);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s var(--ease-apple);
    text-decoration: none;
}
.btn-sec:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.22); }
.btn-sec:active { transform: scale(0.97); }

.view-body {
    padding: 32px;
    flex: 1;
    max-width: 1240px;
    width: 100%;
    margin: 0 auto;
}

.order-card-box {
    background: var(--order-surface);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 24px;
    margin-bottom: 22px;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(20px);
}

.card-heading { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.card-subheading { font-size: 13px; color: var(--order-text-dim); margin-top: 3px; }

/* Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}

.metric-card-ios {
    background: var(--order-surface);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.25s var(--ease-apple);
}
.metric-card-ios:hover { border-color: rgba(255,255,255,0.25); transform: translateY(-2px); }

.metric-lbl { font-size: 12px; font-weight: 600; color: var(--order-text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.metric-num { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.metric-badge-pill { font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.metric-badge-pill.positive { color: var(--accent); }
.metric-badge-pill.blue { color: var(--as-action); }

/* Table */
.app-table-wrap {
    overflow-x: auto;
    border-radius: 18px;
    border: 1px solid var(--order-divider);
    background: var(--order-bg);
}
.app-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
.app-table th {
    background: var(--order-surface-2);
    color: var(--order-text-dim);
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 14px 18px;
    border-bottom: 1px solid var(--order-divider);
}
.app-table td { padding: 16px 18px; border-bottom: 1px solid var(--order-divider); color: var(--order-text); }
.app-table tr:hover td { background: var(--order-surface); cursor: pointer; }

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}
.badge-status.paid { background: rgba(48, 209, 88, 0.15); color: var(--accent); border: 1px solid rgba(48, 209, 88, 0.3); }
.badge-status.pending { background: rgba(255, 165, 2, 0.15); color: var(--warn); border: 1px solid rgba(255, 165, 2, 0.3); }

.badge-status.cancelled { background: rgba(255, 69, 58, 0.15); color: #ff453a; border: 1px solid rgba(255, 69, 58, 0.3); }
.badge-status.expired { background: rgba(142, 142, 147, 0.15); color: #8e8e93; border: 1px solid rgba(142, 142, 147, 0.3); }
.badge-status.ready { background: rgba(10, 132, 255, 0.15); color: var(--as-action); border: 1px solid rgba(10, 132, 255, 0.3); }

/* Forms */
.form-grp { margin-bottom: 18px; }
.form-lbl { display: block; font-size: 13px; font-weight: 700; color: var(--order-text-dim); margin-bottom: 8px; }
.form-inp, .form-sel, .form-txt {
    width: 100%;
    background: var(--order-surface-2);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 14px 16px;
    color: var(--order-text);
    font-size: 14.5px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-inp:focus, .form-sel:focus, .form-txt:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* =========================================================================
   WARM STONE GLASSMORPHISM COMPONENTS
   ========================================================================= */
.seller-glass-card {
    background: var(--bg-glass);
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.seller-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xl);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}
.seller-card.interactive {
    cursor: pointer;
}
.seller-card.interactive:hover {
    border-color: #D6D3D1;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.seller-segmented-wrapper {
    margin-top: 20px;
    padding: 6px;
    background: var(--surface-subtle);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.seller-segmented-btn {
    border: none;
    background: transparent;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-main);
}
.seller-segmented-btn.active {
    background: var(--color-dark);
    color: var(--bg-card);
    box-shadow: var(--shadow-md);
}
.seller-segmented-btn .btn-title {
    font-size: 13.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.seller-segmented-btn .btn-sub {
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--text-muted);
}
.seller-segmented-btn.active .btn-sub {
    color: var(--text-eyebrow);
}

.seller-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.4;
}
.seller-pill.ok {
    background: var(--color-emerald-bg);
    color: var(--color-emerald-text);
    border: 1px solid var(--color-emerald-border);
}
.seller-pill.ok .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-emerald-dot);
}
.seller-pill.sky {
    background: var(--color-sky-bg);
    color: var(--color-sky-text);
    border: 1px solid var(--color-sky-border);
}
.seller-pill.dark {
    background: var(--color-dark);
    color: var(--bg-card);
}

.seller-input-wrapper {
    position: relative;
    width: 100%;
}
.seller-input {
    height: 42px;
    width: 100%;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-card);
    background: var(--bg-card);
    padding: 0 16px 0 38px;
    font-size: 13.5px;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}
.seller-input:focus {
    border-color: var(--text-eyebrow);
    box-shadow: 0 0 0 4px var(--surface-subtle);
}

/* =========================================================================
   TOUCH NUMERIC KEYPAD DOCK (FOR INVOICE CREATOR & POS)
   ========================================================================= */
.creator-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 22px;
    align-items: start;
}
@media (max-width: 980px) {
    .creator-layout {
        grid-template-columns: 1fr;
    }
}

.touch-keypad-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xl);
    padding: 20px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 90px;
    transition: all 0.2s ease;
}

.keypad-display-box {
    background: var(--surface-subtle);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.keypad-eyebrow {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-eyebrow);
}
.keypad-amount-val {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
.keypad-currency-symbol {
    font-size: 18px;
    font-weight: 400;
    color: var(--text-eyebrow);
    margin-left: 2px;
}

.keypad-grid-3x4 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.keypad-btn {
    height: 50px;
    border-radius: var(--radius-md);
    background: var(--surface-subtle);
    border: 1px solid var(--border-card);
    color: var(--text-main);
    font-size: 19px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    
    font-variant-numeric: tabular-nums;
}
.keypad-btn:hover {
    background: var(--surface-hover);
    border-color: #D6D3D1;
    transform: translateY(-1px);
}
.keypad-btn:active {
    transform: scale(0.96);
}
.keypad-btn.action-btn {
    font-size: 14px;
    font-weight: 800;
}
.keypad-btn.clear-btn {
    color: var(--color-red-text);
    background: var(--color-red-bg);
    border-color: var(--color-red-border);
}
.keypad-btn.back-btn {
    color: var(--text-muted);
}
.keypad-btn.done-btn {
    grid-column: span 3;
    height: 44px;
    margin-top: 6px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    font-size: 13.5px;
    font-weight: 700;
    border-radius: var(--radius-md);
    border: none;
}

.theme-toggle-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    background: var(--surface-subtle);
    border: 1px solid var(--border-card);
    color: var(--text-main);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.theme-toggle-pill:hover {
    background: var(--surface-hover);
}
.theme-toggle-pill .theme-icon {
    display: inline-block;
}

/* =========================================================================
   SCENARIO CARDS GRID & SELECTOR (Compact iOS 27)
   ========================================================================= */
.scenario-selector-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
@media (max-width: 900px) {
    .scenario-selector-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 520px) {
    .scenario-selector-grid {
        grid-template-columns: 1fr;
    }
}

.sc-card-ios {
    background: var(--surface-subtle);
    border: 1px solid var(--border-card);
    border-radius: 14px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s var(--ease-apple);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sc-card-ios:hover {
    border-color: #D6D3D1;
    background: var(--surface-hover);
}
.sc-card-ios.active {
    border-color: var(--color-emerald-border);
    background: var(--color-emerald-bg);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.15);
}

.sc-icon-circle {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: all 0.2s var(--ease-apple);
}
.sc-card-ios.active .sc-icon-circle {
    background: var(--color-emerald-text);
    color: #FFFFFF;
    border-color: transparent;
}

.quick-amt-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.quick-amt-chip {
    padding: 5px 12px;
    background: var(--surface-subtle);
    border: 1px solid var(--border-card);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s var(--ease-apple);
}
.quick-amt-chip:hover {
    border-color: var(--accent);
    background: var(--color-emerald-bg);
}

/* POS Terminal with Math */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
}
.pos-keypad-box {
    background: var(--order-surface);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 24px;
    display: flex;
    flex-direction: column;
}
.pos-amount-display {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xl);
    padding: 24px 32px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    margin-bottom: 24px;
    width: 100%;
    box-sizing: border-box;
}
.pos-amount-main {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 12px;
}
.pos-amount-val {
    font-size: 72px;
    font-weight: 600;
    letter-spacing: -0.04em;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    outline: none;
    border-bottom: 2px dashed transparent;
    min-width: 50px;
    display: inline-block;
    cursor: text;
    transition: border-color 0.2s var(--ease-apple);
}
.pos-amount-val:focus {
    border-color: var(--brand-main);
}
.pos-currency-symbol {
    font-size: 36px;
    color: var(--text-muted);
    font-weight: 500;
}
.pos-formula-line {
    font-size: 14px;
    color: var(--order-text-dim);
    font-weight: 600;
    min-height: 20px;
    letter-spacing: 0.02em;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pos-amount-main {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
}
.pos-currency-symbol { font-size: 24px; color: var(--order-text-dim); font-weight: 700; margin-right: 6px; }
.pos-amount-val { font-size: 48px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

.pos-calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
.pos-key {
    background: var(--order-surface-2);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    height: 58px;
    font-size: 22px;
    font-weight: 700;
    color: var(--order-text);
    cursor: pointer;
    transition: all 0.15s var(--ease-apple);
    display: flex;
    align-items: center;
    justify-content: center;
}
.pos-key:active { background: rgba(255,255,255,0.12); transform: scale(0.96); }
.pos-key.op {
    background: rgba(255, 159, 10, 0.15);
    border-color: rgba(255, 159, 10, 0.35);
    color: var(--math-op);
    font-size: 24px;
}
.pos-key.op:active { background: rgba(255, 159, 10, 0.3); }
.pos-key.eq {
    background: var(--accent);
    border-color: var(--accent);
    color: #000000;
    font-weight: 800;
}

.quick-amount-chips { display: flex; gap: 8px; margin-bottom: 14px; }
.chip-btn {
    flex: 1;
    background: var(--order-surface-2);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 10px 6px;
    color: var(--order-text-dim);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s var(--ease-apple);
}
.chip-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Tree View Styles */
.tree-container { display: flex; flex-direction: column; gap: 24px; }
.tree-node-owner {
    background: var(--surface-subtle);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.tree-owner-info { display: flex; align-items: center; gap: 16px; }
.tree-owner-icon {
    width: 48px; height: 48px; border-radius: 24px;
    background: var(--action); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 800;
}
.tree-company-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg); padding: 24px; margin-left: 32px;
    position: relative;
}
.tree-company-card::before {
    content: ''; position: absolute; top: -20px; left: -16px;
    width: 16px; height: 44px;
    border-left: 2px solid var(--border-card);
    border-bottom: 2px solid var(--border-card);
    border-bottom-left-radius: 12px;
}
.tree-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.tree-entity-badge { padding: 4px 10px; border-radius: var(--radius-sm); background: var(--surface-subtle); font-weight: 800; font-size: 13px; color: var(--text-main); }
.tree-accounts-box { background: var(--surface-subtle); border: 1px solid var(--border-card); border-radius: var(--radius-md); padding: 16px; margin-bottom: 20px; }
.tree-iban-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.tree-terminals-title { font-size: 12px; font-weight: 700; color: var(--order-text-dim); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.tree-terminals-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.tree-terminal-chip { background: var(--order-surface-3); border: 1px solid var(--card-border); border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .main-wrapper { margin-left: 0; }
    .pos-container { grid-template-columns: 1fr; }
    .tree-company-card { margin-left: 10px; }
}
.responsive-grid-2 {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 380px;
    gap: 48px;
    align-items: start;
}
@media (max-width: 900px) {
    .responsive-grid-2 {
        grid-template-columns: 1fr;
        gap: 32px;
    }
}
        }

/* ===== Уніфіковані компоненти POS (єдина мова стилю) ===== */
            .hide-scrollbar {
               
                border-radius: 12px;
                padding-left: 10px !important;
                padding-right: 10px !important;
                scrollbar-width: none;
                -ms-overflow-style: none;
            }
            .hide-scrollbar::-webkit-scrollbar {
                display: none;
            }


            /* Головний перемикач вкладок: Довільна сума / Товари / Мітки */
            .pos-segmented {
                display: flex;
                background: var(--surface-subtle);
                border-radius: var(--radius-lg);
                padding: 4px;
                gap: 4px;
                width: 100%;
                margin-bottom: 24px;
                flex-shrink: 0;
            }
            .pos-segmented button {
                flex: 1;
                padding: 14px;
                border: none;
                border-radius: var(--radius-md);
                font-weight: 600;
                font-size: 15px;
                cursor: pointer;
                background: transparent;
                color: var(--text-muted);
                transition: background 0.2s, color 0.2s, box-shadow 0.2s;
            }
            .pos-segmented button.active {
                background: var(--bg-card);
                color: var(--text-main);
                box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            }

            /* Чіпи категорій товарів */
            .pos-chip {
                padding: 8px 16px;
                border: 1px solid var(--border-card);
                background: var(--bg-card);
                color: var(--text-main);
                border-radius: var(--radius-full);
                font-size: 14px;
                font-weight: 600;
                cursor: pointer;
                white-space: nowrap;
                transition: background 0.2s, color 0.2s, border-color 0.2s;
            }
            .pos-chip.active {
                background: var(--action);
                border-color: var(--action);
                color: #fff;
            }

            /* Швидкі суми (+50 / +100 / +200 / +500) */
            .pos-quick-chip {
                flex: 1;
                height: 40px;
                border-radius: var(--radius-sm);
                border: none;
                background: var(--surface-subtle);
                color: var(--text-main);
                font-size: 14px;
                font-weight: 600;
                cursor: pointer;
                transition: background 0.15s;
            }
            .pos-quick-chip:active { background: var(--border-card); }

            /* Клавіші калькулятора — той самий стиль, що і чіпи/switcher */
            .pos-key {
                border: none;
                height: 64px;
                border-radius: var(--radius-md);
                font-size: 24px;
                font-weight: 500;
                cursor: pointer;
                background: var(--surface-subtle);
                color: var(--text-main);
                display: flex;
                align-items: center;
                justify-content: center;
                transition: background 0.15s, transform 0.1s;
            }
            .pos-key:active { transform: scale(0.96); }
            .pos-key.op-accent { color: var(--action); font-weight: 600; }
            .pos-key.op-danger { color: var(--danger); font-weight: 600; }
            .pos-key.op-primary { background: var(--action); color: #fff; font-weight: 600; }

            /* Картки товарів у сітці */
            .pos-product-card {
                aspect-ratio: 1.1;
                border: 1px solid var(--border-card);
                background: var(--bg-card);
                border-radius: var(--radius-md);
                padding: 12px;
                text-align: left;
                display: flex;
                flex-direction: column;
                justify-content: space-between;
                cursor: pointer;
                transition: border-color 0.2s, transform 0.1s;
            }
            .pos-product-card:active { transform: scale(0.97); }

            /* +/- у кошику */
            .pos-qty-btn {
                width: 28px;
                height: 28px;
                border-radius: 50%;
                border: 1px solid var(--border-card);
                background: var(--bg-card);
                display: flex;
                align-items: center;
                justify-content: center;
                cursor: pointer;
                color: var(--text-main);
            }

            /* Картки міток/столів */
            .pos-tag-card {
                padding: 16px;
                border: 1px solid var(--border-card);
                background: var(--bg-card);
                border-radius: var(--radius-md);
                text-align: left;
                cursor: pointer;
                transition: border-color 0.2s;
            }
            .pos-tag-card.active { border-color: var(--action); border-width: 2px; }

            /* Пілюля "Додати мітку / стіл" */
            .pos-tag-pill {
                border: none;
                background: var(--bg-card);
                padding: 14px 28px;
                border-radius: var(--radius-full);
                color: var(--action);
                font-size: 16px;
                font-weight: 600;
                cursor: pointer;
                display: inline-flex;
                align-items: center;
                gap: 8px;
                box-shadow: 0 4px 12px rgba(0,0,0,0.05);
                transition: transform 0.2s;
            }
            .pos-tag-pill:active { transform: scale(0.97); }

            /* Основна CTA-кнопка (Оплатити / Додати мітку) */
            .pos-cta-btn {
                width: 100%;
                height: 56px;
                border-radius: var(--radius-md);
                background: var(--action);
                color: #fff;
                border: none;
                font-size: 16px;
                font-weight: 600;
                cursor: pointer;
                transition: transform 0.2s, opacity 0.2s;
            }
            .pos-cta-btn:active { transform: scale(0.98); }
            .pos-cta-btn:disabled { cursor: not-allowed; opacity: 0.5; }



.skeleton-box {
    border-radius: var(--radius-lg);
    background: var(--border-card); /* or surface-subtle */
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}


/* ======================================================== */
/* STRUCTURE & BUSINESS HIERARCHY MODALS & STYLING          */
/* ======================================================== */
.struct-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: structFadeIn 0.2s ease-out;
}
@keyframes structFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.struct-modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg, 20px);
    padding: 28px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    color: var(--text-main);
}
.struct-modal-title {
    font-size: 20px;
    font-weight: 800;
    margin: 0;
    color: var(--text-main);
}
.struct-field {
    margin-bottom: 16px;
}
.struct-field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.struct-field input, .struct-field select {
    width: 100%;
    padding: 12px 14px;
    background: var(--order-surface-2, rgba(255,255,255,0.05));
    border: 1px solid var(--card-border, rgba(255,255,255,0.1));
    border-radius: 12px;
    color: var(--text-main);
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}
.struct-field input:focus, .struct-field select:focus {
    outline: none;
    border-color: var(--accent, #00c853);
}
.struct-radio-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.struct-radio-btn {
    flex: 1;
    min-width: 160px;
    padding: 12px 14px;
    border: 1px solid var(--card-border, rgba(255,255,255,0.1));
    border-radius: 12px;
    background: var(--order-surface-2, rgba(255,255,255,0.05));
    color: var(--text-main);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s ease;
}
.struct-radio-btn.active {
    background: var(--action, #00c853);
    color: #fff;
    border-color: var(--action, #00c853);
}
.struct-segmented {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.struct-seg-btn {
    padding: 10px;
    border: 1px solid var(--card-border, rgba(255,255,255,0.1));
    border-radius: 12px;
    background: var(--order-surface-2, rgba(255,255,255,0.05));
    color: var(--text-main);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    transition: all 0.2s ease;
}
.struct-seg-btn.active {
    background: var(--action, #00c853);
    color: #fff;
    border-color: var(--action, #00c853);
}
.tree-action-btn {
    background: var(--surface-subtle, rgba(255,255,255,0.05));
    border: 1px solid var(--card-border, rgba(255,255,255,0.1));
    border-radius: 8px;
    padding: 5px 10px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}
.tree-action-btn:hover {
    border-color: var(--accent, #00c853);
    color: var(--accent, #00c853);
}
.tree-action-btn.danger {
    color: var(--warn, #ff453a);
}
.tree-action-btn.danger:hover {
    border-color: var(--warn, #ff453a);
    background: rgba(255, 69, 58, 0.15);
}
.tree-add-inline {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.tree-add-inline input {
    flex: 1;
    min-width: 180px;
    padding: 9px 12px;
    background: var(--order-surface-2, rgba(255,255,255,0.05));
    border: 1px solid var(--card-border, rgba(255,255,255,0.1));
    border-radius: 10px;
    color: var(--text-main);
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
}

.app-kbd {
    display: none;
    margin: 2px;
    margin-left: auto;
    background: var(--surface-subtle);
    padding: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border-card);
    align-items: center;
    justify-content: center;
    font-family: monospace;
    font-size: 11px;
    color: var(--text-muted);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    flex-shrink: 0;
}
@media (min-width: 640px) {
    .app-kbd { display: inline-flex; }
}
