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

:root {
    --bg: #0f0f14;
    --card: #1a1a24;
    --card-hover: #22222e;
    --border: #2a2a3a;
    --text: #e8e8f0;
    --text-muted: #8888a0;
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --green: #00b894;
    --green-bg: rgba(0, 184, 148, 0.1);
    --red: #e17055;
    --red-bg: rgba(225, 112, 85, 0.1);
    --yellow: #fdcb6e;
    --yellow-bg: rgba(253, 203, 110, 0.12);
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

.view { display: block; }
.view[hidden] { display: none !important; }

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

.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h1 {
    font-size: 2rem;
    margin-bottom: 4px;
}

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

/* ========== TOPBAR ========== */
.app {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.topbar h1 {
    font-size: 1.3rem;
    font-weight: 700;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-badge {
    font-size: 0.78rem;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--accent);
    color: white;
    font-weight: 600;
}

.user-badge.cashier {
    background: var(--border);
    color: var(--text-muted);
}

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-icon:hover {
    border-color: var(--red);
    color: var(--red);
}

/* ========== INVENTORY BANNER ========== */
.inventory-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--yellow-bg);
    border: 1px solid rgba(253, 203, 110, 0.25);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 16px;
}

.inventory-banner[hidden] { display: none; }

.banner-content {
    flex: 1;
}

.banner-content strong {
    color: var(--yellow);
    display: block;
    font-size: 0.9rem;
}

.banner-content p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ========== TABS ========== */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.tab:hover { border-color: var(--text-muted); }

.tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.tab[hidden] { display: none; }

.tab-content { display: block; }
.tab-content[hidden] { display: none !important; }

/* ========== BALANCE CARD ========== */
.balance-card {
    background: linear-gradient(135deg, var(--accent), #4834d4);
    border-radius: var(--radius);
    padding: 28px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.balance-label {
    font-size: 0.82rem;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

.balance-amount {
    font-size: 2.4rem;
    font-weight: 800;
    margin: 8px 0 20px;
    letter-spacing: -1px;
}

.balance-row {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 16px;
    gap: 16px;
}

.balance-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.balance-item-label {
    font-size: 0.75rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.balance-item-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.balance-divider {
    width: 1px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
}

/* ========== FORMS ========== */
.form-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.form-card h2,
.section-header h2,
.admin-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

/* Big type toggle buttons */
.type-toggle-big {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.toggle-big {
    flex: 1;
    padding: 20px 10px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.toggle-big-icon {
    font-size: 1.6rem;
}

.toggle-big:hover { border-color: var(--text-muted); }

.toggle-big.active[data-type="prijem"] {
    border-color: var(--green);
    color: var(--green);
    background: var(--green-bg);
}

.toggle-big.active[data-type="vydej"] {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-bg);
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

.form-group select option {
    background: var(--card);
    color: var(--text);
}

.tf-person-custom {
    margin-top: 6px;
}

.tf-person-custom[hidden] { display: none; }

/* Amount input – bigger for mobile */
#tf-amount {
    font-size: 1.4rem;
    font-weight: 700;
    padding: 14px;
    text-align: center;
    letter-spacing: 1px;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 4px;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-submit {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
    color: white;
}

.btn-submit.prijem { background: var(--green); }
.btn-submit.vydej { background: var(--red); }
.btn-submit:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-submit:active { transform: translateY(0); }

.btn-secondary {
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-secondary:hover { border-color: var(--text-muted); }

.btn-small {
    padding: 6px 14px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-small:hover { opacity: 0.85; }

.error-msg {
    background: var(--red-bg);
    color: var(--red);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.error-msg[hidden] { display: none; }

.success-msg {
    background: var(--green-bg);
    color: var(--green);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.success-msg[hidden] { display: none; }

/* ========== HISTORY ========== */
.history-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-buttons {
    display: flex;
    gap: 4px;
}

.filter-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.filter-btn:hover { border-color: var(--text-muted); }

.filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.search-input {
    flex: 1;
    min-width: 120px;
    padding: 6px 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.85rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

/* ========== TRANSACTION LIST ========== */
.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.transaction-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    gap: 12px;
    transition: background 0.15s;
    animation: slideIn 0.2s ease-out;
}

.transaction-item:hover {
    background: var(--card-hover);
}

.transaction-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.transaction-icon.prijem {
    background: var(--green-bg);
    color: var(--green);
}

.transaction-icon.vydej {
    background: var(--red-bg);
    color: var(--red);
}

.transaction-info {
    flex: 1;
    min-width: 0;
}

.transaction-desc {
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transaction-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 1px;
}

.transaction-amount {
    font-size: 0.95rem;
    font-weight: 700;
    flex-shrink: 0;
}

.transaction-amount.prijem { color: var(--green); }
.transaction-amount.vydej { color: var(--red); }

.transaction-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 0.85rem;
    opacity: 0;
    transition: all 0.15s;
    flex-shrink: 0;
}

.transaction-item:hover .transaction-delete { opacity: 1; }
.transaction-delete:hover { color: var(--red); }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 16px;
    font-size: 0.9rem;
}

/* ========== ADMIN ========== */
.admin-section {
    margin-bottom: 24px;
}

.cashier-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cashier-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.cashier-item .name {
    font-weight: 500;
    font-size: 0.9rem;
}

.cashier-item .email {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.cashier-item .role-badge {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.role-badge.admin {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-light);
}

.role-badge.cashier {
    background: var(--border);
    color: var(--text-muted);
}

/* Cashier item actions */
.cashier-info {
    flex: 1;
    min-width: 0;
}

.cashier-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.btn-icon-sm {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-icon-sm:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-icon-sm.danger:hover {
    border-color: var(--red);
    color: var(--red);
}

/* ========== MODAL ========== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal[hidden] { display: none !important; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    max-width: 440px;
    width: 100%;
    box-shadow: var(--shadow);
}

.modal-content h2 {
    font-size: 1.15rem;
    margin-bottom: 12px;
}

.modal-content p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

.inv-diff {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.inv-diff[hidden] { display: none; }

.inv-diff.ok {
    background: var(--green-bg);
    color: var(--green);
}

.inv-diff.warn {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.inv-diff.danger {
    background: var(--red-bg);
    color: var(--red);
}

/* ========== QUICK ACTIONS ========== */
.quick-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.quick-btn {
    flex: 1;
    padding: 14px 10px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
}

.quick-btn.prijem { background: var(--green); }
.quick-btn.vydej { background: var(--red); }
.quick-btn.correction {
    background: transparent;
    border: 2px dashed var(--yellow);
    color: var(--yellow);
    flex: 0.8;
    font-size: 0.85rem;
}

.quick-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.quick-btn:active { transform: translateY(0); }
.quick-btn[hidden] { display: none; }
.admin-only[hidden] { display: none; }

/* ========== SORT SELECT ========== */
.sort-select {
    padding: 6px 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.8rem;
}

.sort-select option {
    background: var(--card);
    color: var(--text);
}

/* ========== ANIMATIONS ========== */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== NUMPAD ========== */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 8px;
}

.numpad-btn {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--text);
    font-size: 1.3rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.1s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.numpad-btn:active {
    background: var(--accent);
    color: white;
    transform: scale(0.95);
}

.numpad-clear {
    color: var(--red);
    border-color: var(--red);
}

.numpad-del {
    color: var(--yellow);
    border-color: var(--yellow);
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--green);
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ========== INVENTORY ITEMS (yellow) ========== */
.transaction-item.inventory-item {
    border-left: 3px solid var(--yellow);
    background: var(--yellow-bg);
}

.transaction-item.inventory-item.danger {
    border-left-color: var(--red);
    background: var(--red-bg);
}

.transaction-icon.inventory {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.inventory-amount.ok { color: var(--green); }
.inventory-amount.warn { color: var(--yellow); }
.inventory-amount.danger { color: var(--red); }

/* ========== CORRECTION ITEMS (yellow) ========== */
.transaction-item.correction {
    border-left: 3px solid var(--yellow);
}

.transaction-icon.correction {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.transaction-amount.correction {
    color: var(--yellow);
}

/* ========== CASHIER TAG ========== */
.cashier-tag {
    background: rgba(108, 92, 231, 0.12);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--accent-light);
    font-weight: 500;
}

/* ========== DATE FILTER ========== */
.date-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.date-filter label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.date-input {
    padding: 5px 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.82rem;
}

.date-input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-date-clear {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-date-clear:hover {
    border-color: var(--red);
    color: var(--red);
}

/* ========== SHOW MORE BUTTON ========== */
.btn-show-more {
    width: 100%;
    padding: 10px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--accent-light);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 4px;
}

.btn-show-more:hover {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.08);
}

/* ========== LIGHT THEME ========== */
[data-theme="light"] {
    --bg: #f5f5f8;
    --card: #ffffff;
    --card-hover: #f0f0f5;
    --border: #e0e0e8;
    --text: #1a1a2e;
    --text-muted: #6b6b80;
    --accent: #6c5ce7;
    --accent-light: #6c5ce7;
    --green: #00a67e;
    --green-bg: rgba(0, 166, 126, 0.1);
    --red: #d63031;
    --red-bg: rgba(214, 48, 49, 0.08);
    --yellow: #b87000;
    --yellow-bg: rgba(184, 112, 0, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .balance-card {
    color: white;
}

[data-theme="light"] .form-group select option {
    background: white;
    color: #1a1a2e;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 480px) {
    body { font-size: 15px; }
    .app { padding: 0 10px 30px; }
    .balance-amount { font-size: 1.8rem; }
    .balance-row { flex-direction: column; gap: 8px; }
    .balance-divider { width: 100%; height: 1px; }
    .topbar h1 { font-size: 1.1rem; }

    .toggle-big {
        padding: 24px 10px;
        font-size: 1.2rem;
    }

    .toggle-big-icon {
        font-size: 2rem;
    }

    #tf-amount {
        font-size: 2rem;
        padding: 18px;
    }

    .numpad-btn {
        padding: 18px;
        font-size: 1.5rem;
    }

    .quick-btn {
        padding: 16px 8px;
        font-size: 1.1rem;
    }

    .tabs {
        gap: 3px;
    }

    .tab {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .transaction-item {
        padding: 10px;
        gap: 8px;
    }

    .history-controls {
        flex-direction: column;
    }

    .filter-buttons {
        width: 100%;
    }

    .filter-btn {
        flex: 1;
        text-align: center;
    }

    .form-card {
        padding: 16px;
    }

    .modal-content {
        padding: 20px;
    }
}
