/* ═══════════════════════════════════════════════════════════
   RC Dashboard — Responsive Style v3.0
   Breakpoints:
     Mobile:   < 600px
     Tablet:   600px – 1023px
     Desktop:  ≥ 1024px
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ─── CSS Variables (Light Mode) ──────────────────────────── */
:root {
    /* Content area — vibrant modern ambient mesh gradient */
    --bg-main:          #eaeff7;
    --bg-main-grad:     radial-gradient(at 10% 15%, rgba(59, 130, 246, 0.16) 0px, transparent 55%),
                        radial-gradient(at 90% 10%, rgba(99, 102, 241, 0.15) 0px, transparent 55%),
                        radial-gradient(at 50% 85%, rgba(14, 165, 233, 0.12) 0px, transparent 65%),
                        linear-gradient(135deg, #f3f7fe 0%, #e8f0fc 50%, #dfeaf7 100%);
    --bg-card:          rgba(255, 255, 255, 0.90);
    --bg-card-grad:     linear-gradient(145deg, rgba(255, 255, 255, 0.96) 0%, rgba(244, 248, 255, 0.88) 100%);
    --bg-card-hover:    linear-gradient(145deg, #ffffff 0%, rgba(238, 245, 255, 0.96) 100%);
    --bg-input:         rgba(235, 242, 253, 0.85);
    --border-color:     rgba(196, 212, 235, 0.65);
    --text-main:        #0f172a;
    --text-muted:       #475569;

    /* Sidebar — dark navy → indigo gradient in light mode */
    --sidebar-bg:       #0f172a;
    --sidebar-bg2:      #1e1b4b;
    --sidebar-bg3:      #312e81;
    --sidebar-text:     rgba(255,255,255,0.90);
    --sidebar-muted:    rgba(255,255,255,0.42);
    --sidebar-border:   rgba(255,255,255,0.09);
    --sidebar-hover:    rgba(255,255,255,0.09);
    --sidebar-active-bg:#3b82f6;
    --nav-active-text:  #ffffff;

    /* Accent */
    --primary:          #3b82f6;
    --primary-hover:    #2563eb;
    --success:          #10b981;
    --warning:          #f59e0b;
    --danger:           #ef4444;
    --danger-hover:     #dc2626;
    --offline:          #94a3b8;

    /* Shadows — glowing blue-tinted shadows for rich depth */
    --shadow-sm:  0 2px 10px rgba(30, 58, 138, 0.06), 0 1px 3px rgba(30, 58, 138, 0.04);
    --shadow-md:  0 12px 35px rgba(30, 58, 138, 0.12), 0 4px 14px rgba(30, 58, 138, 0.06);
    --shadow-lg:  0 25px 60px rgba(30, 58, 138, 0.16), 0 8px 25px rgba(30, 58, 138, 0.08);

    /* Layout */
    --sidebar-w:   248px;
    --topbar-h:    60px;
    --radius-sm:   10px;
    --radius-md:   14px;
    --radius-lg:   18px;

    /* Select arrow */
    --select-arrow: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* ─── Dark Mode Overrides ──────────────────────────────────── */
.theme-dark {
    /* Content area */
    --bg-main:      #0d1117;
    --bg-main-grad: radial-gradient(ellipse at 15% 0%, rgba(30, 58, 138, 0.25) 0%, transparent 50%),
                    radial-gradient(ellipse at 85% 100%, rgba(15, 23, 42, 0.7) 0%, transparent 55%),
                    linear-gradient(135deg, #090d16 0%, #111827 50%, #0c1322 100%);
    --bg-card:      #161b22;
    --bg-card-grad: linear-gradient(145deg, rgba(26, 34, 52, 0.88) 0%, rgba(18, 24, 38, 0.96) 100%);
    --bg-card-hover:linear-gradient(145deg, rgba(32, 42, 64, 0.92) 0%, rgba(22, 30, 46, 0.98) 100%);
    --bg-input:     #0d1117;
    --border-color: rgba(255,255,255,0.07);
    --text-main:    #e6edf3;
    --text-muted:   #7d8590;

    /* Sidebar — deep blue gradient in dark mode */
    --sidebar-bg:    #0c1a3e;
    --sidebar-bg2:   #0f2d6b;
    --sidebar-bg3:   #1e3a8a;
    --sidebar-text:  rgba(255,255,255,0.92);
    --sidebar-muted: rgba(255,255,255,0.48);
    --sidebar-border:rgba(255,255,255,0.10);
    --sidebar-hover: rgba(255,255,255,0.10);
    --sidebar-active-bg: #60a5fa;
    --nav-active-text: #ffffff;

    --shadow-sm:  0 1px 3px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.25);
    --shadow-md:  0 4px 20px rgba(0,0,0,0.5), 0 10px 40px rgba(0,0,0,0.3);
    --shadow-lg:  0 8px 30px rgba(0,0,0,0.6), 0 20px 60px rgba(0,0,0,0.4);

    --select-arrow: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8590' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

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

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-main-grad);
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow: hidden;
}

/* ─── App Shell ─────────────────────────────────────────────── */
.app-shell {
    display: flex;
    height: 100%;
    overflow: hidden;
}

/* ─── Sidebar Overlay (mobile backdrop) ─────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    backdrop-filter: blur(3px);
}
.sidebar-overlay.active { display: block; }

/* ════════════════════════════════════════════════════════════
   SIDEBAR — Rich gradient, both modes
   ════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(160deg,
        var(--sidebar-bg)  0%,
        var(--sidebar-bg2) 55%,
        var(--sidebar-bg3) 100%);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    transition: background 0.4s ease, transform 0.3s ease;
    position: relative;
}

/* Gradient separator on right edge */
.sidebar::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(255,255,255,0.15) 25%,
        rgba(255,255,255,0.20) 50%,
        rgba(255,255,255,0.15) 75%,
        transparent 100%
    );
    pointer-events: none;
}

/* ─── Clock Area ─────────────────────────────────────────────── */
.sidebar-clock {
    padding: 28px 20px 20px;
    text-align: center;
    border-bottom: 1px solid var(--sidebar-border);
}

#system-time {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
    font-variant-numeric: tabular-nums;
    color: var(--sidebar-text);
    line-height: 1;
}

.sidebar-clock-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--sidebar-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: 5px;
}


/* ─── Nav Buttons ───────────────────────────────────────────── */
nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 16px 12px;
    flex-grow: 1;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--sidebar-muted);
    text-align: left;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    font-family: inherit;
}

.nav-btn:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.nav-btn.active {
    background: linear-gradient(135deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.10) 100%);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18), 0 4px 16px rgba(0,0,0,0.25);
}

.nav-btn.active svg { stroke: #fff; }

/* ─── User Info Card ────────────────────────────────────────────── */
.sidebar-user {
    margin: 0 12px 6px;
    padding: 14px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 11px;
    backdrop-filter: blur(4px);
}

.sidebar-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

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

.sidebar-user-role {
    font-size: 11px;
    color: var(--sidebar-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Sidebar Actions (Theme + Logout) ─────────────────────── */
.sidebar-actions {
    padding: 10px 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid var(--sidebar-border);
    margin-top: 4px;
}

.sidebar-action-btn {
    background: transparent;
    border: none;
    color: var(--sidebar-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    transition: background 0.18s ease, color 0.18s ease;
    text-align: center;
}

.sidebar-action-btn:hover {
    background: rgba(255,255,255,0.10);
    color: rgba(255,255,255,0.95);
}

.theme-btn:hover { color: rgba(255,255,255,0.95); }

.logout-btn {
    color: rgba(252, 165, 165, 0.75);
}
.logout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

/* ─── Mobile Top Bar ────────────────────────────────────────── */
.topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--bg-card-grad);
    background-color: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 98;
    box-shadow: var(--shadow-sm);
}

.topbar-clock {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
}

.burger-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.burger-btn:hover { background: var(--bg-input); }

/* ─── Inspecting Shop Banner ────────────────────────────────── */
.inspect-banner {
    background: linear-gradient(135deg, #0284c7, #2563eb);
    color: #fff;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
    position: relative;
    z-index: 1;
}

/* ════════════════════════════════════════════════════════════
   MAIN CONTENT
   ════════════════════════════════════════════════════════════ */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
    background: var(--bg-main-grad);
    background-color: var(--bg-main);
}

header {
    padding: 28px 32px 12px;
}

#page-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-main) 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
    -webkit-text-fill-color: var(--text-muted);
}

.view-section        { display: none; padding: 20px 32px 40px; }
.view-section.active { display: block; }

/* ─── Dashboard Grid ────────────────────────────────────────── */
.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 50px;
    color: var(--text-muted);
}

/* ─── RC Cards ──────────────────────────────────────────────── */
.rc-card {
    background: var(--bg-card-grad);
    background-color: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.25s ease, transform 0.2s ease, background 0.25s ease;
    height: auto;
}
.rc-card:hover {
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-scroll-body {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px; /* space for scrollbar */
    margin-right: -8px; /* offset padding */
}

/* Fix for RC Card inner layout gap */
.rc-card .card-scroll-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Custom Scrollbar for Cards */
.card-scroll-body::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.card-scroll-body::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track {
    background: transparent;
}
.card-scroll-body::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}
.card-scroll-body::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.rc-title { font-size: 17px; font-weight: 800; }
.rc-mac   { font-size: 11px; color: var(--text-muted); font-family: monospace; margin-top: 2px; word-break: break-all; }

.status-badge        { padding: 4px 10px; border-radius: 8px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-offline      { background: rgba(100,116,139,0.12); color: var(--offline); }
.status-idle         { background: rgba(148,163,184,0.12); color: var(--text-muted); }
.status-online       { background: rgba(16,185,129,0.15);  color: var(--success); }
.status-stopped      { background: rgba(245,158,11,0.15);  color: var(--warning); }

.vbat-badge          { padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; white-space: nowrap; border: 1px solid transparent; }
.vbat-normal         { background: rgba(16,185,129,0.12); color: var(--success); border-color: rgba(16,185,129,0.25); }
.vbat-low            { background: rgba(239,68,68,0.15); color: var(--danger); border-color: rgba(239,68,68,0.4); animation: pulse-danger 1.5s infinite; }
.vbat-hidden         { display: none; }
@keyframes pulse-danger {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

.battery-section {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}
.battery-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.battery-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}
.battery-value {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.battery-pct {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.85;
    margin-left: 2px;
}
.battery-progress-bg {
    width: 100%;
    height: 6px;
    background: rgba(148,163,184,0.18);
    border-radius: 999px;
    overflow: hidden;
}
.battery-progress-bar {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease, background-color 0.4s ease;
}
.battery-good    { color: var(--success); }
.battery-progress-bar.battery-good { background-color: var(--success); }
.battery-warning { color: var(--warning); }
.battery-progress-bar.battery-warning { background-color: var(--warning); }
.battery-danger  { color: var(--danger); animation: pulse-danger 1.5s infinite; }
.battery-progress-bar.battery-danger { background-color: var(--danger); }
.battery-unknown { color: var(--text-muted); }
.battery-progress-bar.battery-unknown { background-color: var(--text-muted); }

.timer-display {
    text-align: center;
    padding: 14px 0;
    background: linear-gradient(135deg, var(--bg-input) 0%, rgba(59, 130, 246, 0.05) 100%);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}
.time-left { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ─── Selects ───────────────────────────────────────────────── */
select,
.package-select,
.filter-select {
    width: 100%;
    padding: 11px 40px 11px 14px;
    background-color: var(--bg-input);
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none;
    transition: border-color 0.2s;
}

select:focus,
.package-select:focus,
.filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.package-select:disabled { opacity: 0.45; cursor: not-allowed; }

.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
    padding: 11px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none !important;
    cursor: pointer;
    color: #fff;
    transition: opacity 0.15s, transform 0.1s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}
.btn:hover     { opacity: 0.88; }
.btn:active    { transform: translateY(1px); }
.btn:disabled  { opacity: 0.35; cursor: not-allowed; transform: none; }

.btn-primary   { background: linear-gradient(135deg, #3b82f6 0%, #4f46e5 100%); box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25); border: none; }
.btn-danger    { background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25); border: none; }
.btn-secondary { background: linear-gradient(135deg, #64748b 0%, #475569 100%); box-shadow: 0 4px 12px rgba(100, 116, 139, 0.25); color: #fff; border: none; }
.btn-warning   { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25); border: none; }
.btn-success   { background: linear-gradient(135deg, #10b981 0%, #059669 100%); box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25); border: none; }
.btn-info      { background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%); box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25); border: none; }
.btn-export    { background: linear-gradient(135deg, #10b981 0%, #0ea5e9 100%); box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25); border: none; }

.btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.btn-full      { width: 100%; }

/* Standardized small action buttons (overrides inline hacks) */
.btn-sm, .btn-xs, .btn-filter, a[title="Export CSV"], button[title="View Logs"] {
    padding: 8px 14px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
    height: 36px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* ─── Stats ─────────────────────────────────────────────────── */
.stats {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}
.stats strong { color: var(--text-main); }

.stats-today {
    display: flex;
    gap: 10px;
    flex-direction: column;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}
.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}
.stat-label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
}
.stat-item strong {
    font-weight: 700;
    color: var(--text-main);
    font-size: 14px;
}

/* ─── Income Filter ─────────────────────────────────────────── */
.income-filter-card { padding: 18px 24px; }
.income-filter-row {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 14px;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 150px;
}
.filter-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}
.filter-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.btn-filter {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    white-space: nowrap;
}

.income-period-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    background: rgba(59,130,246,0.1);
    border-radius: 6px;
    padding: 2px 10px;
    margin-left: 8px;
    vertical-align: middle;
}
.income-period-badge:empty { display: none; }

/* ─── Income RC Blocks ──────────────────────────────────────── */
.income-rc-block { margin-bottom: 28px; }
.income-rc-block:last-child { margin-bottom: 0; }
.income-rc-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
}
.income-rc-title { font-size: 16px; font-weight: 700; color: var(--text-main); }
.income-rc-mac   { font-size: 11px; color: var(--text-muted); font-family: monospace; }

/* ─── Tables ────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 10px;
    background: var(--bg-card-grad);
    background-color: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
}

.income-table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.income-table thead th,
.data-table thead th {
    padding: 13px 16px;
    text-align: left;
    white-space: nowrap;
    background: var(--bg-input);
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    position: sticky;
    top: 0;
    z-index: 1;
}

.income-table tbody td,
.data-table tbody td {
    padding: 12px 16px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 13px;
}

.income-table tbody tr:last-child td,
.data-table tbody tr:last-child td { border-bottom: none; }

.income-table tbody tr:hover td,
.data-table tbody tr:hover td {
    background: rgba(59,130,246,0.04);
}

.row-odd  { background: transparent; }
.row-even { background: rgba(0,0,0,0.018); }
.theme-dark .row-even { background: rgba(255,255,255,0.025); }

/* Package badges */
.pkg-badge { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.pkg-a { background: rgba(59,130,246,0.12);  color: #3b82f6; }
.pkg-b { background: rgba(16,185,129,0.12); color: #059669; }
.pkg-c { background: rgba(245,158,11,0.12); color: #d97706; }

/* ─── Pagination ─────────────────────────────────────────────── */
.pg-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 0 2px;
}
.pg-btn {
    padding: 7px 14px;
    min-width: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pg-info {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    text-align: center;
}

/* ─── Export Card ────────────────────────────────────────────── */
.export-card { padding: 18px; text-align: center; }
.export-card h4 { margin-bottom: 4px; font-size: 15px; }
.export-month-label { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; font-weight: 600; }
.export-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }

/* ─── Cards (Generic) ───────────────────────────────────────── */
.settings-card {
    background: var(--bg-card-grad);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 240px);
}
.settings-card:hover {
    box-shadow: var(--shadow-md);
    background: var(--bg-card-hover);
}
.settings-card-wide { grid-column: 1 / -1; }
.settings-card h3 {
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    flex-wrap: wrap;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

/* ─── Form Elements ─────────────────────────────────────────── */
.form-group        { margin-bottom: 18px; }
.form-group h4     { margin-bottom: 8px; font-size: 13px; color: var(--text-muted); }
.form-group label  { display: block; margin-bottom: 7px; font-size: 14px; font-weight: 600; color: var(--text-muted); }
.input-row         { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

input[type="number"],
input[type="datetime-local"],
input[type="text"],
input[type="password"],
.text-input {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s;
}
input:focus, .text-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 10px; line-height: 1.6; }

/* ─── Misc ──────────────────────────────────────────────────── */
.empty-msg {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 14px;
}
.loading-msg { font-style: italic; }

code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    color: var(--primary);
}

.version-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--success);
    background: rgba(16,185,129,0.12);
    padding: 3px 10px;
    border-radius: 6px;
    margin-left: auto;
}

.rc-shop-badge {
    font-size: 11px;
    background: var(--primary);
    color: #fff;
    padding: 2px 7px;
    border-radius: 6px;
    margin-left: 5px;
    vertical-align: middle;
}

/* ─── App Footer ────────────────────────────────────────────── */
.app-footer {
    text-align: center;
    padding: 24px 16px;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: auto;
}
.app-footer a { color: inherit; text-decoration: none; }
.app-footer a:hover { color: var(--primary); }
.app-footer strong { font-weight: 800; }

/* ─── RC Management List ────────────────────────────────────── */
.rc-manage-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}
.rc-manage-item:last-child { border-bottom: none; }
.rc-manage-info { flex: 1; min-width: 120px; }
.rc-manage-mac  { font-family: monospace; font-size: 12px; color: var(--text-muted); }
.rc-manage-unit { font-weight: 700; font-size: 14px; }
.rc-manage-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

/* ─── Upload / Progress ─────────────────────────────────────── */
.upload-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.upload-section { display: flex; flex-direction: column; gap: 10px; }
.upload-title  { font-size: 15px; font-weight: 700; color: var(--text-main); }
.upload-desc   { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.upload-desc code { background: rgba(59,130,246,0.08); color: var(--primary); padding: 1px 5px; border-radius: 4px; font-size: 11px; }

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    padding: 28px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
}
.drop-zone.drag-over { border-color: var(--primary); background: rgba(59,130,246,0.05); }

.upload-progress { display: flex; align-items: center; gap: 10px; }
.progress-bar    { flex: 1; height: 6px; background: var(--bg-input); border-radius: 4px; overflow: hidden; border: 1px solid var(--border-color); }
.progress-fill   { height: 100%; background: linear-gradient(90deg, var(--primary), #6366f1); border-radius: 4px; width: 0%; transition: width 0.3s; }
.progress-text   { font-size: 12px; font-weight: 700; color: var(--text-main); min-width: 36px; text-align: right; }

/* ─── Shops Table (Owner view) ──────────────────────────────── */
.shops-table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card-grad);
    background-color: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
}
.shops-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.shops-table thead th {
    padding: 13px 16px;
    text-align: left;
    background: var(--bg-input);
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
}
.shops-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 13px;
    vertical-align: middle;
}
.shops-table tbody tr:last-child td { border-bottom: none; }
.shops-table tbody tr:hover td { background: rgba(59,130,246,0.04); }

.shop-badge-active   { display:inline-flex; align-items:center; gap:5px; padding:3px 10px; background:rgba(16,185,129,0.12); color:#10b981; border-radius:20px; font-size:11px; font-weight:700; }
.shop-badge-inactive { display:inline-flex; align-items:center; gap:5px; padding:3px 10px; background:rgba(239,68,68,0.10); color:#ef4444; border-radius:20px; font-size:11px; font-weight:700; }
.shop-badge-dot      { width:6px; height:6px; border-radius:50%; display:inline-block; background:currentColor; }

.shop-actions { display:flex; gap:6px; flex-wrap:wrap; }
.span-2-desktop { grid-column: span 2; }

/* ─── Shop List (Responsive Card Layout) ────────────────────── */
.shop-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.shop-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    transition: background 0.15s;
}
.shop-item:first-child { padding-top: 4px; }
.shop-item:last-child  { border-bottom: none; padding-bottom: 4px; }
.shop-item:hover       { background: rgba(59,130,246,0.02); }

.shop-item-disabled { opacity: 0.65; }

.shop-item-main {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
}

.shop-item-id {
    flex-shrink: 0;
    width: 46px;
    text-align: center;
}

.shop-item-id code {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 4px 8px;
    border-radius: 6px;
}

.shop-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.shop-item-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shop-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-muted);
}

.shop-item-meta strong { color: var(--text-main); font-weight: 600; }

.shop-code-tag {
    background: rgba(59,130,246,0.1);
    color: var(--primary);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    font-family: monospace;
}

.shop-item-sep { color: var(--border-color); }

.shop-item-actions {
    display: flex;
    gap: 7px;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
}

/* ─── Operators Table ───────────────────────────────────────── */
.operators-table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 8px;
    background: var(--bg-card-grad);
    background-color: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
}
.operators-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.operators-table thead th {
    padding: 13px 16px;
    text-align: left;
    background: var(--bg-input);
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
}
.operators-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 13px;
    vertical-align: middle;
}
.operators-table tbody tr:last-child td { border-bottom: none; }
.operators-table tbody tr:hover td { background: rgba(59,130,246,0.04); }
.op-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet & Mobile
   ════════════════════════════════════════════════════════════ */

/* Tablet: 600px – 1023px */
@media (max-width: 1023px) {
    .topbar  { display: flex; }

    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }

    .main-content { padding-top: var(--topbar-h); }

    header        { padding: 18px 20px 8px; }
    .view-section { padding: 16px 20px 36px; }

    #page-title { font-size: 22px; }

    .grid-container { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    .settings-grid  { grid-template-columns: 1fr; }
    .span-2-desktop { grid-column: span 1 !important; }
    .upload-grid    { grid-template-columns: 1fr; }
    .input-row      { grid-template-columns: 1fr 1fr; }

    /* Shop list on tablet: stack actions below main */
    .shop-item          { gap: 12px; }
    .shop-item-actions  { width: 100%; justify-content: flex-end; padding-top: 4px; }
}

/* Mobile: < 600px */
@media (max-width: 599px) {
    :root { --sidebar-w: 260px; }

    .grid-container { grid-template-columns: 1fr; gap: 12px; }
    .settings-grid  { grid-template-columns: 1fr; }
    .upload-grid    { grid-template-columns: 1fr; }
    .input-row      { grid-template-columns: 1fr; gap: 10px; }

    header          { padding: 14px 14px 6px; }
    .view-section   { padding: 12px 14px 32px; }

    #page-title     { font-size: 20px; }
    .topbar         { padding: 0 14px; }
    .time-left      { font-size: 30px; }
    .rc-card        { padding: 16px; gap: 14px; }

    .income-filter-row { flex-direction: column; }
    .filter-group   { min-width: 100%; }
    .filter-actions { width: 100%; }
    .btn-filter     { flex: 1; justify-content: center; }

    .controls       { grid-template-columns: 1fr 1fr; }

    /* Shop list on mobile: full-width stacked card */
    .shop-item {
        padding: 14px 0;
        gap: 10px;
    }
    .shop-item-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        width: 100%;
    }
    .shop-item-id { width: auto; }
    .shop-item-name { font-size: 14px; white-space: normal; }
    .shop-item-actions {
        width: 100%;
        justify-content: flex-start;
        padding-top: 2px;
    }
    .shop-item-actions .btn { flex: 1; text-align: center; justify-content: center; }

    /* Income table on mobile — hide Cost column to fit screen */
    .income-table thead th:nth-child(4),
    .income-table tbody td:nth-child(4) { display: none; }

    /* Operators table on mobile: stacked card layout */
    .operators-table thead { display: none; }
    .operators-table tbody tr {
        display: flex;
        flex-direction: column;
        padding: 14px 16px;
        border-bottom: 1px solid var(--border-color);
        gap: 10px;
    }
    .operators-table tbody tr:last-child { border-bottom: none; }
    .operators-table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 !important;
        border: none !important;
        width: 100%;
        font-size: 13.5px;
    }
    .operators-table tbody td:first-child {
        font-size: 15px;
    }
    .operators-table tbody td:last-child {
        margin-top: 6px;
        display: block;
    }
    .op-actions {
        display: flex;
        gap: 8px;
        width: 100%;
    }
    .op-actions .btn {
        flex: 1;
        justify-content: center;
        text-align: center;
        padding: 9px 6px;
        font-size: 12.5px;
    }
}

/* Landscape phone */
@media (max-height: 500px) and (orientation: landscape) {
    .topbar        { height: 48px; }
    .main-content  { padding-top: 48px; }
    .view-section  { padding: 10px 16px 24px; }
    .timer-display { padding: 8px 0; }
    .time-left     { font-size: 26px; }
    .rc-card       { gap: 10px; padding: 12px; }
    header         { padding: 10px 16px 4px; }
}

/* ─── Custom Modal Window ────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.modal-overlay.active {
    display: flex !important;
    opacity: 1;
    pointer-events: auto;
}
.modal-window {
    background: var(--bg-card-grad);
    background-color: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 28px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255,255,255,0.03);
    transform: scale(0.92) translateY(16px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.modal-overlay.active .modal-window {
    transform: scale(1) translateY(0);
}
.modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
}
.modal-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.modal-icon.info    { background: rgba(59,130,246,0.12); color: #3b82f6; }
.modal-icon.warning { background: rgba(245,158,11,0.12); color: #f59e0b; }
.modal-icon.danger  { background: rgba(239,68,68,0.12);  color: #ef4444; }
.modal-icon.success { background: rgba(16,185,129,0.12); color: #10b981; }

.modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}
.modal-body {
    display: flex;
    flex-direction: column;
}
.modal-message {
    margin: 0;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-muted);
    white-space: pre-wrap;
}
.modal-input {
    margin-top: 14px;
    padding: 11px 14px;
    font-size: 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-main);
    font-family: inherit;
    width: 100%;
    transition: border-color 0.2s;
}
.modal-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 6px;
}
.modal-footer .btn {
    min-width: 100px;
    padding: 10px 22px;
    font-weight: 600;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
}