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

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --bg: #f0f2f8;
    --surface: #ffffff;
    --surface2: #f5f7ff;
    --border: #e2e6f0;
    --accent: #6c63ff;
    --accent2: #8b5cf6;
    --accent-glow: rgba(108, 99, 255, 0.12);
    --text: #1a1d2e;
    --text-muted: #6b7280;
    --green: #10b981;
    --red: #f43f5e;
    --radius: 14px;
    --transition: 0.22s ease;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
    display: flex;
    align-items: center;
    padding: 0 28px;
    height: 62px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 1px 8px rgba(108, 99, 255, 0.07);
}

.topbar button {
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
    padding: 6px 10px;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
}

.topbar button:hover {
    background: var(--surface2);
    color: var(--accent);
}

.logo {
    font-size: 18px;
    font-weight: 700;
    margin-left: 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
}

/* ── Layout ── */
.layout {
    display: flex;
    min-height: calc(100vh - 62px);
}

/* ── Sidebar ── */
.sidebar {
    width: 230px;
    background: var(--surface);
    padding: 28px 14px;
    border-right: 1px solid var(--border);
    transition: width var(--transition), padding var(--transition);
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar.hide {
    width: 0;
    padding: 0;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 4px;
    transition: var(--transition);
    white-space: nowrap;
}

.sidebar a:hover,
.sidebar a.active {
    background: var(--accent-glow);
    color: var(--accent);
}

.sidebar a.active {
    font-weight: 600;
}

/* ── Content ── */
.content {
    flex: 1;
    padding: 36px 40px;
    overflow-x: hidden;
}

/* ── Summary Cards ── */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 18px;
    margin-bottom: 36px;
}

.card {
    background: var(--surface);
    padding: 24px 22px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.06);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: var(--radius) var(--radius) 0 0;
    opacity: 0;
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 10px 28px rgba(108, 99, 255, 0.15);
}

.card:hover::before {
    opacity: 1;
}

.card h4 {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.card p {
    margin: 10px 0 0;
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.card-today {
    border: 2px solid #10b981;
    background: #ecfdf5;
}

.card-yesterday {
    border: 2px solid #3b82f6;
    background: #eff6ff;
}

.row-today {
    background: #ecfdf5 !important;
    font-weight: 600;
}

.row-yesterday {
    background: #eff6ff !important;
}

/* ── Sync Bar ── */
.sync-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    padding: 12px 18px;
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 22px;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.05);
}

.sync-online {
    color: var(--green);
    font-weight: 500;
}

.sync-offline {
    color: var(--red);
    font-weight: 500;
}

#lastSyncedText {
    color: var(--text-muted);
}

.sync-times {
    text-align: right;
    font-size: 12px;
    color: var(--text-muted);
}

.sync-times div {
    margin-bottom: 3px;
}

#connectionStatus {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--green);
    position: relative;
}

.sync-online .status-dot {
    background: var(--green);
    animation: pulse 1.5s infinite;
}

.sync-offline .status-dot {
    background: var(--red);
    animation: none;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
    }

    70% {
        box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.topbar {
    justify-content: space-between;
}

.topbar-sync {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 12px;
    color: var(--text-muted);
}

.topbar-times {
    display: flex;
    gap: 14px;
    align-items: center;
}

.topbar-sync #connectionStatus {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

/* ── Table Box ── */
.tableBox {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    overflow-x: auto;
    box-shadow: 0 2px 10px rgba(108, 99, 255, 0.07);
}

.tableBox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px 14px;
    border-bottom: 1px solid var(--border);
}

.tableBox-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

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

th,
td {
    padding: 12px 16px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

tbody tr:last-child td {
    border-bottom: none;
}

th {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-muted);
    background: var(--surface2);
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: rgba(108, 99, 255, 0.05);
}

td:first-child {
    color: var(--text-muted);
    font-size: 13px;
    text-align: left;
    padding-left: 24px;
}

th:first-child {
    text-align: left;
    padding-left: 24px;
}

td input {
    width: 100px;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 14px;
    text-align: center;
    transition: var(--transition);
}

td input:focus {
    outline: none;
    border-color: var(--accent);
    background: #ffffff;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

tfoot td {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
    background: var(--surface2);
    border-top: 2px solid var(--border);
}

/* ── Form Box ── */
.formBox {
    background: var(--surface);
    padding: 28px 30px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    max-width: 460px;
    box-shadow: 0 2px 10px rgba(108, 99, 255, 0.07);
}

.formBox h3 {
    margin-top: 0;
    margin-bottom: 22px;
    font-weight: 600;
    font-size: 18px;
    color: var(--text);
}

label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

input,
select {
    width: 100%;
    padding: 11px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-size: 14px;
    background: var(--surface2);
    color: var(--text);
    font-family: inherit;
    transition: var(--transition);
}

input::placeholder {
    color: #b0b8cc;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    background: #ffffff;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

select option {
    background: #ffffff;
    color: var(--text);
}

/* ── Buttons ── */
button {
    padding: 10px 20px;
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: white;
    border-radius: 9px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
    letter-spacing: 0.2px;
}

button:hover {
    opacity: 0.88;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

button:active {
    transform: translateY(0);
}

button.btn-secondary {
    background: var(--surface2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

button.btn-secondary:hover {
    background: var(--border);
    color: var(--text);
    box-shadow: none;
}

/* ── Login Page ── */
.centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    background-image: radial-gradient(ellipse at 60% 30%, rgba(108, 99, 255, 0.1) 0%, transparent 60%);
}

.loginBox {
    background: var(--surface);
    padding: 44px 40px;
    border-radius: 20px;
    border: 1px solid var(--border);
    width: 360px;
    box-shadow: 0 12px 40px rgba(108, 99, 255, 0.12);
}

.loginBox .login-logo {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loginBox .login-sub {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 28px;
}

.loginBox h2 {
    margin-top: 0;
    margin-bottom: 24px;
    font-weight: 700;
    font-size: 22px;
    text-align: center;
}

.loginBox input {
    margin-bottom: 14px;
}

#loginError {
    color: var(--red);
    font-size: 13px;
    margin-top: 10px;
    text-align: center;
    min-height: 18px;
}

.loginBox button {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    margin-top: 4px;
}

/* ── Section Title ── */
.section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title span.badge {
    font-size: 12px;
    font-weight: 500;
    background: var(--accent-glow);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid rgba(108, 99, 255, 0.2);
}

/* ── Profile / Settings page ── */
.page-header {
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px;
}

.page-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 20px;
    box-shadow: 0 4px 16px var(--accent-glow);
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        z-index: 1000;
        height: calc(100vh - 62px);
        top: 62px;
        left: 0;
        box-shadow: 4px 0 24px rgba(108, 99, 255, 0.1);
    }

    .content {
        padding: 24px 20px;
    }

    .cards {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .loginBox {
        width: 90%;
        padding: 36px 24px;
    }
}