:root {
    --bg-main: #0f172a;
    --bg-secondary: #1e293b;
    --bg-glass: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --success: #4ade80;
    --warning: #fb923c;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
}

.mobile-menu-toggle,
.mobile-header-menu,
.sidebar-overlay {
    display: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px 32px;
    color: var(--text-primary);
}

.sidebar-header i {
    font-size: 32px;
    color: var(--accent);
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.sidebar-header span {
    color: var(--accent);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: rgba(56, 189, 248, 0.1);
    color: var(--accent);
}

.nav-item i {
    font-size: 20px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
    min-width: 0;
}

.main-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 300px;
    background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.1), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 32px 40px;
    position: relative;
    z-index: 1;
}

.top-header h1 {
    font-size: 28px;
    font-weight: 600;
}

.user-profile .avatar {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s;
}

.user-profile .avatar:hover {
    transform: scale(1.05);
}

.view-section {
    padding: 0 40px 40px;
    position: relative;
    z-index: 1;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.stat-details h3 {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-details p {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Status overview */
.health-section { margin-bottom:40px; }
.health-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(180px, 1fr)); gap:10px; }
.health-card { display:flex; align-items:center; gap:10px; padding:13px 14px; border:1px solid var(--border-color); border-radius:10px; background:var(--bg-glass); }
.health-card > i { font-size:22px; }
.health-card div { display:flex; flex-direction:column; gap:3px; min-width:0; }
.health-card strong { font-size:13px; }
.health-card span { color:var(--text-secondary); font-size:11px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.health-ok { color:var(--success); }
.health-failed { color:var(--danger); }
.status-overview-section { margin-bottom: 40px; }
.section-heading-row { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:16px; }
.section-heading-row h2 { margin:0; }
.status-overview-total { color:var(--text-secondary); font-size:13px; }
.status-overview-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(170px, 1fr)); gap:12px; }
.status-overview-card { display:flex; align-items:center; gap:12px; padding:16px; border:1px solid var(--border-color); border-radius:12px; background:var(--bg-glass); }
.status-overview-card > i { font-size:24px; }
.status-overview-card div { display:flex; flex-direction:column; gap:3px; }
.status-overview-card strong { font-size:24px; color:var(--text-primary); }
.status-overview-card span { font-size:12px; color:var(--text-secondary); }
.status-overview-card.status-synced { color:var(--success); }
.status-overview-card.status-review { color:var(--danger); }
.status-overview-card.status-superseded { color:var(--text-secondary); }
.status-overview-card.status-pending { color:var(--warning); }
.status-overview-empty { color:var(--text-secondary); padding:16px 0; }

/* Completeness */
.completeness-section { margin-bottom:40px; }
.completeness-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(250px, 1fr)); gap:8px; }
.completeness-item { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 14px; border:1px solid var(--border-color); border-radius:10px; background:var(--bg-glass); }
.completeness-item > div { display:flex; flex-direction:column; gap:3px; min-width:0; }
.completeness-item strong { font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.completeness-item span:not(.status-badge) { color:var(--text-secondary); font-size:12px; }
.completeness-found { border-left:3px solid var(--success); }
.completeness-missing { border-left:3px solid var(--danger); }

/* Processing issues */
.processing-issues-section { margin-bottom: 40px; }
.processing-issues-container { display:flex; flex-direction:column; gap:8px; }
.processing-issue-row { display:grid; grid-template-columns:minmax(220px, 1.5fr) auto minmax(260px, 1fr); align-items:center; gap:16px; padding:14px 16px; border:1px solid var(--border-color); border-radius:12px; background:var(--bg-glass); }
.processing-issue-main { display:flex; flex-direction:column; gap:4px; min-width:0; }
.processing-issue-main strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.processing-issue-main span, .processing-issue-detail { color:var(--text-secondary); font-size:12px; }
.processing-issue-detail { display:flex; flex-direction:column; gap:4px; min-width:0; }
.processing-issue-detail small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
@media (max-width: 800px) { .processing-issue-row { grid-template-columns:1fr; gap:8px; } }

/* Tables */
.table-container {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.bills-table {
    width: 100%;
    border-collapse: collapse;
}

.bills-table th, .bills-table td {
    padding: 12px 10px; /* Reduced padding to save horizontal space */
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.bills-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: rgba(0,0,0,0.2);
}

.bills-table tr:last-child td {
    border-bottom: none;
}

.bills-table tbody tr {
    transition: background-color 0.2s;
}

.bills-table tbody tr:hover {
    background-color: rgba(255,255,255,0.02);
}

/* Badges */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-pending { background: rgba(251, 146, 60, 0.1); color: var(--warning); }
.status-synced { background: rgba(74, 222, 128, 0.1); color: var(--success); }
.status-review { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s;
}

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

.password-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrap .form-input {
    padding-right: 86px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    border: 0;
    background: transparent;
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px;
}

.password-toggle:hover {
    color: var(--accent-hover);
}
select.form-input option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: var(--accent-hover);
}

.settings-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}


/* Details / Summary components */
details.supplier-group {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
}

details.supplier-group > summary {
    padding: 20px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.2);
}

details.supplier-group > summary::-webkit-details-marker {
    display: none;
}

details.supplier-group > summary::after {
    content: '\25bc';
    font-size: 0.8rem;
    transition: transform 0.3s;
    color: var(--text-secondary);
}

details.supplier-group[open] > summary::after {
    transform: rotate(180deg);
}

details.supplier-group[open] > summary {
    border-bottom: 1px solid var(--border-color);
}

.supplier-content {
    padding: 24px;
}

details.object-group {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}

details.object-group:last-child {
    margin-bottom: 0;
}

details.object-group > summary {
    padding: 16px 20px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.02);
}

details.object-group > summary::-webkit-details-marker {
    display: none;
}

details.object-group > summary::after {
    content: '\25bc';
    font-size: 0.8rem;
    transition: transform 0.3s;
    color: var(--text-secondary);
}

details.object-group[open] > summary::after {
    transform: rotate(180deg);
}

details.object-group[open] > summary {
    border-bottom: 1px solid var(--border-color);
}

.object-content {
    padding: 0;
}

.consumption-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 28px 0 16px;
}

.consumption-history-header p {
    color: var(--text-secondary);
    margin-top: 6px;
    font-size: 0.88rem;
}

.history-period-control {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.history-period-control .form-input {
    width: auto;
    min-width: 130px;
}

.consumption-history-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.history-chart-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 18px;
    min-width: 0;
}

.history-chart-card h3 {
    font-size: 0.98rem;
    margin-bottom: 12px;
}

.history-chart-wrap {
    position: relative;
    height: 280px;
}

@media (max-width: 800px) {
    body.menu-open {
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(82vw, 300px);
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        box-shadow: 18px 0 40px rgba(0, 0, 0, 0.28);
        z-index: 1001;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(2, 8, 23, 0.68);
        z-index: 1000;
    }

    .sidebar-overlay.is-visible {
        display: block;
    }

    .mobile-menu-toggle,
    .mobile-header-menu {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        border: 1px solid var(--border-color);
        border-radius: 10px;
        background: var(--bg-glass);
        color: var(--text-primary);
        font-size: 22px;
        cursor: pointer;
    }

    .mobile-menu-toggle {
        position: fixed;
        top: 14px;
        left: 14px;
        z-index: 1002;
    }

    .mobile-header-menu {
        flex: 0 0 auto;
    }

    .main-content {
        width: 100%;
    }

    .top-header {
        gap: 10px;
        padding: 16px;
    }

    .top-header h1 {
        font-size: 1.25rem;
        margin-right: auto;
    }

    .user-profile {
        gap: 8px !important;
    }

    #btn-restart {
        padding: 7px 9px !important;
        font-size: 0 !important;
    }

    #btn-restart i {
        margin-right: 0 !important;
        font-size: 17px;
    }

    .view-section {
        padding: 16px;
    }

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

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 720px;
    }

    .chart-container {
        min-height: 240px;
    }

    .consumption-history-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .history-period-control {
        width: 100%;
        justify-content: space-between;
    }

    .consumption-history-grid {
        grid-template-columns: 1fr;
    }
}
