:root {
    --bg-1: #2c3e50;
    --bg-2: #4a6491;
    --primary: #3498db;
    --primary-dark: #2980b9;
    --success: #27ae60;
    --success-dark: #219955;
    --danger: #e74c3c;
    --danger-dark: #c0392b;
    --neutral: #95a5a6;
    --neutral-dark: #7f8c8d;
    --text-dark: #2c3e50;
    --text-muted: #666;
    --border: #ddd;
    --panel: #f8f9fa;
}

* {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    background: radial-gradient(circle at top, #E5F0FF 0%, #DDE7F5 60%, #D3D8E5 100%);
    margin: 0;
    color: #000000;
    -webkit-text-size-adjust: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.no-scroll {
    overflow: hidden;
}

.auth-container {
    max-width: 400px;
    width: 90%;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.auth-tabs {
    display: flex;
    margin-bottom: 30px;
    border-bottom: 2px solid #eee;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    font-size: 16px;
    font-weight: bold;
    color: #000000;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.auth-tab.active {
    color: #1A1A1A;
    border-bottom: 3px solid #3498db;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form h2 {
    text-align: center;
    color: #1A1A1A;
    margin-bottom: 25px;
}

.auth-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}

.auth-form button {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: #000000;
    border: 1px solid #acacac;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
}

.auth-form button:hover {
    background: var(--success-dark);
}

.error-message {
    color: var(--danger);
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
    display: none;
}

.poker-title {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 0 30px 0;
}

.logo-image {
    max-width: 240px;
    width: 100%;
    height: auto;
    display: block;
}

.container {
    max-width: 1000px;
    margin: 20px auto;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
    display: none;
    position: relative;
}

h1,
h2 {
    color: #000000;
    text-align: center;
    font-weight: 400;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.section {
    margin-bottom: 25px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fafafa;
}

.flex-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.flex-row > div {
    min-width: 180px;
}

.flex-row > div:not(.btn-cell) {
    flex-grow: 2;
}

.btn-cell {
    display: flex;
    align-items: stretch;
    flex: 0 0 auto;
    min-width: 180px;
}

.btn-cell button {
    width: auto;
    min-width: 180px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 400;
    color: #000000;
}

input,
select,
textarea {
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
    -webkit-appearance: none;
    min-height: 44px;
}

button {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.3s, box-shadow 0.3s;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
}

button:hover:not(:disabled),
button:active:not(:disabled) {
    background: #3498db;
}

button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.6;
}

button.red {
    background: #000000;
}

button.red:hover:not(:disabled),
button.red:active:not(:disabled) {
    background: var(--danger-dark);
}

button.green {
    background: #3498db;
}

button.green:hover:not(:disabled),
button.green:active:not(:disabled) {
    background: #f39c12;
}

button.neutral {
    background: transparent;
    color: #000000;
    font-weight: 500;
}

button.neutral:hover:not(:disabled),
button.neutral:active:not(:disabled) {
    background: #000000;
    color: #fbffff;
}

button.subtle {
    background: #ecf0f1;
    color: var(--neutral-dark);
    border: 1px solid #bdc3c7;
    font-weight: normal;
}

button.subtle:hover:not(:disabled),
button.subtle:active:not(:disabled) {
    background: #d5dbdb;
    color: var(--text-dark);
}

button.admin {
    background: transparent;
    color: #000000;
    font-weight: 500;
}

button.admin:hover {
    background: #3498db;
    color: #ffffff;
}

.icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    flex: 0 0 auto;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-lg {
    width: 20px;
    height: 20px;
}

.icon-sm {
    width: 14px;
    height: 14px;
}

.table-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    background: white;
    font-size: 14px;
}

th,
td {
    border: 1px solid var(--border);
    padding: 10px;
    text-align: left;
}

th {
    background: #ffffff;
    color: #000000;
    position: sticky;
    top: 0;
}

tr:nth-child(even) {
    background: #f9f9f9;
}

.total {
    font-weight: 500;
    color: #000000;
}

.balance-result {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.balance-correct {
    color: var(--success);
}

.balance-incorrect {
    color: var(--danger);
}

.controls {
    text-align: center;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.player-list {
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.status-playing {
    color: var(--success);
    font-weight: bold;
}

.status-finished {
    color: var(--danger);
    font-weight: bold;
}

.balance-positive {
    color: var(--success);
    font-weight: bold;
}

.balance-negative {
    color: var(--danger);
    font-weight: bold;
}

.balance-zero {
    color: var(--neutral-dark);
    font-weight: bold;
}

.chip-symbol {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    border-radius: 50%;
    margin-left: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.chip-symbol::before {
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.8) 2%, transparent 10%);
    border-radius: 50%;
}

.warning-message {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 0.9em;
    display: none;
    gap: 8px;
    align-items: center;
}

.warning-message.visible {
    display: flex;
}

.balance-check {
    background: var(--panel);
    border: 1px solid #dee2e6;
    padding: 10px;
    border-radius: 6px;
    margin-top: 15px;
    font-size: 0.95em;
    display: none;
}

.user-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    padding: 8px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
    flex-wrap: wrap;
    gap: 12px;
}

.user-info-left,
.user-info-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-email {
    color: #000000;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.user-panel button {
    padding: 2px 14px;
    font-size: 14px;
}

.subscription-badge {
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 500;
    color: #3498db;
    background: var(--neutral-dark);
    white-space: nowrap;
}

.subscription-badge.active {
    background: transparent;
}

.subscription-badge.paused {
    background: #f39c12;
}

.subscription-badge.expired {
    background: var(--danger);
}

.access-banner {
    display: none;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    background: #fdeaea;
    border: 1px solid #f5c6cb;
    color: var(--danger-dark);
    font-weight: bold;
    text-align: center;
}

.access-banner.visible {
    display: block;
}

.admin-panel {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 1000;
    padding: 24px;
    overflow: hidden;
}

.admin-panel.active {
    display: block;
}

.admin-content {
    max-width: 1200px;
    margin: 24px auto;
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--primary);
}

.admin-title {
    margin: 0;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-profile-card {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--panel);
    border-radius: 8px;
}

.admin-profile-title {
    margin: 0 0 10px 0;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #000000, #000000);
    color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.stat-card h3 {
    margin: 0 0 10px 0;
    font-size: 18px;
    opacity: 0.9;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: bold;
    margin: 5px 0;
}

.stat-card .stat-desc {
    font-size: 14px;
    opacity: 0.8;
}

.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    flex-wrap: wrap;
}

.admin-tab {
    padding: 8px 16px;
    background: #ecf0f1;
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-dark);
    transition: all 0.3s;
    font-size: 14px;
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.admin-scroll {
    max-height: 420px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #e6e9ee;
    border-radius: 8px;
    background: #fff;
}

.admin-table-controls select,
.admin-table-controls input {
    padding: 6px;
    font-size: 13px;
}

.player-phone-input {
    min-width: 160px;
}

.admin-table-controls button {
    padding: 6px 10px;
    font-size: 12px;
}

.admin-search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.admin-search-row input {
    flex: 1;
    min-width: 200px;
}

.history-game {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.history-game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
    gap: 12px;
    flex-wrap: wrap;
}

.history-meta {
    color: var(--text-muted);
    font-size: 0.9em;
}

.history-summary {
    text-align: right;
}

.history-details {
    font-size: 0.9em;
}

.history-expenses {
    margin-top: 5px;
}

.history-expenses-note {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: 3px;
}

.history-balance {
    margin-top: 5px;
}

.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.hint-text {
    color: var(--text-muted);
    font-size: 0.9em;
    margin-top: 10px;
}

.subscription-info {
    background: #fefefe;
}

.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.plan-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
}

.plan-card.plan-demo {
    background: #f5f9ff;
    border-color: #cfe3fb;
}

.plan-title {
    font-weight: 700;
    color: var(--text-dark);
}

.plan-desc {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.9em;
}

.payment-block {
    margin-top: 16px;
    padding: 12px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.payment-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.payment-label {
    font-weight: 600;
    color: var(--text-dark);
}

.payment-qr img {
    max-width: 180px;
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.hint-text.danger {
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: 6px;
}

.hint-warning {
    color: #856404;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-block {
    margin-bottom: 20px;
}

.data-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: monospace;
}

.expenses-container {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

.expense-item {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.expense-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.expense-total {
    font-weight: 500;
    color: #000000;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--primary);
}

.expense-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.balance-after-expenses {
    font-weight: bold;
    font-size: 1.3em;
    margin-top: 15px;
    padding: 10px;
    border-radius: 6px;
    background: #f8f9fa;
    text-align: center;
}

.balance-after-expenses.positive {
    color: var(--success);
    background: #eafaf1;
}

.balance-after-expenses.negative {
    color: var(--danger);
    background: #fdeaea;
}

.expense-chart {
    display: flex;
    height: 30px;
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chart-dealer {
    background: var(--primary);
}

.chart-tea {
    background: #9b59b6;
}

.chart-other {
    background: #e67e22;
}

.chart-legend {
    display: flex;
    justify-content: space-around;
    margin-top: 5px;
    font-size: 0.8em;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.chart-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dealer-color {
    background: var(--primary);
}

.tea-color {
    background: #9b59b6;
}

.other-color {
    background: #e67e22;
}

.empty-state {
    text-align: center;
    color: var(--neutral-dark);
    padding: 20px;
}

.is-hidden {
    display: none;
}

@media (max-width: 900px) {
    .admin-content {
        padding: 18px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 15px;
        margin: 10px;
    }

    .flex-row > div {
        min-width: 100%;
    }

    th,
    td {
        padding: 8px;
        font-size: 13px;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 18px;
    }

    .poker-title {
        font-size: 28px;
        margin-bottom: 20px;
    }

    .admin-stats-grid {
        grid-template-columns: 1fr;
    }

    .admin-tabs {
        gap: 8px;
    }

    .user-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .user-info-left,
    .user-info-right {
        width: 100%;
        justify-content: center;
    }

    .user-info-right {
        flex-direction: column;
        align-items: stretch;
    }

    .user-info-right button {
        width: 100%;
    }

    .user-email {
        max-width: 100%;
        text-align: center;
    }

    .chart-legend {
        flex-direction: column;
        gap: 5px;
    }

    .admin-search-row {
        flex-direction: column;
    }

    .admin-search-row button {
        width: 100%;
    }
}
