:root {
    --bg: #0c0c0c;
    --header: #00281c;
    --surface: #161616;
    --surface2: #1e1e1e;
    --border: #2a2a2a;
    --accent: #00e5a0;
    --accent2: #0066ff;
    --text: #f0f0f0;
    --text-muted: #777;
    --logo: #e0e0e0;
    --danger: #ff4444;
    --warning: #ffaa00;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── HEADER ─── */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--header);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-family: 'Lexend Giga', monospace;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.15em;
    color: var(--logo);
    text-transform: uppercase;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;

    &.connected {
        background: var(--accent);
        box-shadow: 0 0 8px var(--accent);
    }
}

.user-info {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'Space Mono', monospace;
}

/* ─── BUTTONS ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 4px;
    border: none;
    font-size: 13px;
    font-family: 'Noto Sans JP', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-primary {
    background: var(--accent);
    color: #000;

    &:hover {
        background: #00ffb3;
        transform: translateY(-1px);
    }

    &:disabled {
        opacity: 0.4;
        cursor: not-allowed;
        transform: none;
    }
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);

    &:hover {
        border-color: var(--accent);
        color: var(--accent);
    }
}

.btn-danger {
    background: var(--surface2);
    border: 1px solid var(--danger);
    color: var(--danger);

    &:hover {
        background: var(--danger);
        color: #fff;
    }
}

/* ─── MAIN LAYOUT ─── */
main {
    flex: 1;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 24px;
}

/* ─── SETUP PANEL ─── */
.setup-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 32px;
    margin-bottom: 32px;
}

.panel-title {
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    font-family: 'Space Mono', monospace;
}

.field input,
.field select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    padding: 10px 12px;
    font-size: 13px;
    font-family: 'Noto Sans JP', sans-serif;
    transition: border-color 0.2s;
    width: 100%;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
}

.field input::placeholder {
    color: var(--text-muted);
}

.field-hint {
    font-size: 10px;
    color: #555;
    line-height: 1.5;
}

/* ─── AUTH SECTION ─── */
.auth-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 32px;
    margin-bottom: 32px;
    text-align: center;
}

.auth-title {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
}

.auth-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.7;
}

/* ─── ENTRY FORM ─── */
.entry-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 32px;
    margin-bottom: 32px;
}

.month-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.month-selector label {
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.month-selector select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    padding: 8px 12px;
    font-size: 14px;
    font-family: 'Space Mono', monospace;
    cursor: pointer;

    &:focus {
        outline: none;
        border-color: var(--accent);
    }
}

.entries-table-wrap {
    overflow-x: auto;
    margin-bottom: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead tr {
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}

th {
    padding: 10px 12px;
    text-align: left;
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 400;
}

td {
    padding: 4px 6px;
    border-bottom: 1px solid #1a1a1a;
}

tbody tr:hover td {
    background: #181818;
}

td input {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 13px;
    font-family: 'Noto Sans JP', sans-serif;
    width: 100%;
    padding: 6px 6px;
    border-radius: 3px;
    transition: background 0.15s;

    &:focus {
        outline: none;
        background: var(--surface2);
    }

    &[type="number"] {
        font-family: 'Space Mono', monospace;
    }
}

.delete-row-btn {
    background: none;
    border: none;
    color: #444;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 3px;
    transition: color 0.2s;
    display: flex;
    align-items: center;

    &:hover {
        color: var(--danger);
    }
}

.table-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.total-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    margin-bottom: 16px;
}

.total-label {
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.total-value {
    font-family: 'Space Mono', monospace;
    font-size: 20px;
    color: var(--accent);
    font-weight: 700;
}

/* ─── LOG ─── */
.log-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 24px;
}

.log-list {
    list-style: none;
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 140px;
    overflow-y: auto;

    & li {
        color: var(--text-muted);

        &.ok {
            color: var(--accent);
        }

        &.err {
            color: var(--danger);
        }

        &.warn {
            color: var(--warning);
        }
    }
}

/* ─── MODAL / OVERLAY ─── */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;

    &.show {
        display: flex;
    }
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 32px;
    max-width: 480px;
    width: 90%;

    & h2 {
        font-size: 16px;
        margin-bottom: 16px;
    }

    p {
        font-size: 13px;
        color: var(--text-muted);
        line-height: 1.7;
        margin-bottom: 20px;
    }
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ─── MISC ─── */
.divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}

.hidden {
    display: none !important;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #333;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-family: 'Space Mono', monospace;
    font-size: 10px;
}

.badge-month {
    background: rgba(0, 229, 160, 0.1);
    color: var(--accent);
    border: 1px solid rgba(0, 229, 160, 0.3);
}