:root {
    --primary: #ffffff;
    --primary-hover: #e2e8f0;
    --bg: #121212;
    --card-bg: #1e1e1e;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #333333;
    --white: #ffffff;
    --error: #ef4444;
    --input-bg: #1e1e1e;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text);
}

/* Login Styles */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: radial-gradient(circle at center, #1e1e1e 0%, #121212 100%);
}

.login-container {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border);
}

.login-container h1 {
    margin-bottom: 2rem;
    color: var(--white);
}

.login-container a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.login-container a:hover {
    text-decoration: none;
    color: var(--primary-hover);
}

.login-container input {
    width: 100%;
    padding: 0.875rem;
    margin-bottom: 1.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-sizing: border-box;
    color: var(--text);
    font-size: 1rem;
}

.login-container input::placeholder {
    color: var(--text-muted);
}

.login-container button {
    width: 100%;
    padding: 0.875rem;
    background: var(--primary);
    color: var(--bg);
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.login-container button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.error {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 1rem;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.5rem;
    border-radius: 0.4rem;
}

.success {
    color: #10b981;
    font-size: 0.875rem;
    margin-top: 1rem;
    background: rgba(16, 185, 129, 0.1);
    padding: 0.5rem;
    border-radius: 0.4rem;
}

.toggle-mode {
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.toggle-mode a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.toggle-mode a:hover {
    text-decoration: underline;
}

main {
    max-width: 1400px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.week-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 2rem;
}

#dateDisplay {
    font-weight: 600;
    color: var(--text);
    font-size: 1.1rem;
}

.table-container {
    background: var(--card-bg);
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow-x: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    -webkit-overflow-scrolling: touch;
    margin-top: 20vmax;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1120px;
}

th {
    background: #181818;
    text-align: center;
    padding: 0.5rem 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}

th:last-child {
    border-right: none;
}

th:nth-last-child(-n+5) {
    border-left: 2px solid var(--border);
}

th:first-child,
td:first-child {
    position: sticky;
    left: 0;
    background: #181818;
    z-index: 10;
    border-right: 2px solid var(--border);
    min-width: 79px;
    padding-right: 0.25rem;
}

td {
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

td:first-child {
    background: var(--card-bg);
}

td input {
    border: 1px solid transparent;
    background: transparent;
    font-family: inherit;
    font-size: 1rem;
    border-radius: 0.5rem;
    color: var(--text);
    transition: all 0.2s;
}

td input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--primary);
}

td input[type="time"] {
    min-width: 50px;
    max-width: 50px;
}

td input[type="time"]::-webkit-calendar-picker-indicator {
    display: none;
    width: 0%;
}

td input:hover {
    background: rgba(255, 255, 255, 0.03);
}

td input:focus {
    background: #2a2a2a;
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.calc-cell {
    background: rgba(255, 255, 255, 0.02);
    font-weight: 600;
    color: var(--primary);
    text-align: center;
    font-family: inherit;
    font-size: 0.9rem;
    border-left: 2px solid var(--border);
}

.summary-row td {
    background: #181818 !important;
    border-top: 2px solid var(--border) !important;
    border-bottom: none !important;
    min-width: 60px;
}

.summary-row td:first-child {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    text-align: center;
    border-right: 2px solid var(--border);
}

.total-val {
    color: var(--white) !important;
    font-size: 1rem !important;
    font-weight: 800 !important;
}

.day-label {
    font-weight: 600;
    color: var(--primary);
    padding-left: 0.5rem !important;
}

.day-label small {
    display: block;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 0.25rem;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.btn-user {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-user:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border);
}

.btn-user::after {
    content: "▼";
    font-size: 0.6rem;
    opacity: 0.5;
    transition: transform 0.3s ease;
    display: inline-block;
}

.btn-user.active::after {
    transform: rotate(180deg);
}

.dropdown-content {
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    min-width: 180px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    z-index: 10;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    margin-top: 0.5rem;
}

.dropdown-content::before {
    content: "";
    position: absolute;
    top: -0.5rem;
    left: 0;
    right: 0;
    height: 0.5rem;
}

.dropdown-content a {
    color: var(--text);
    padding: 0.875rem 1.25rem;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.dropdown-content a:hover {
    background-color: #333333;
    color: var(--white);
}

.dropdown-content a:first-child {
    border-radius: 0.5rem 0.5rem 0 0;
}

.dropdown-content a:last-child {
    border-radius: 0 0 0.5rem 0.5rem;
}

.dropdown-content.show {
    display: block;
}

/* Settings and Admin Cards */
.settings-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    margin: 0 auto 2rem;
    max-width: 600px;
}

.settings-card.admin-view {
    max-width: 800px;
}

.settings-card h2 {
    margin-top: 0;
}

.settings-card .back-link {
    margin-top: 2rem;
}

.settings-card .back-link a {
    color: var(--primary);
    text-decoration: none;
}

/* Setting Items and Forms */
.setting-item {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.setting-item.admin-config {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.setting-item h3 {
    margin: 0 0 1rem;
    font-size: 1rem;
}

.form-column {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-row {
    display: flex;
    gap: 0.75rem;
}

.form-row input {
    width: 50%;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.form-input {
    padding: 0.75rem;
    border-radius: 0.4rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
}

.form-button {
    background: var(--primary);
    color: black;
    border: none;
    padding: 0.75rem;
    border-radius: 0.4rem;
    cursor: pointer;
    font-weight: 600;
}

.form-button.full-width {
    width: 100%;
}

.form-button.span-2 {
    grid-column: span 2;
}

.form-button.small {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.form-button.danger {
    background: var(--danger);
    color: white;
}

.btn-danger-outline {
    width: 100%;
    background: transparent;
    color: #ef4444;
    border: 1px solid #ef4444;
    padding: 0.75rem;
    border-radius: 0.4rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Admin Table Management */
.admin-table-wrapper {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    min-width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
}

.admin-table thead tr {
    border-bottom: 2px solid var(--border);
}

.admin-table th,
.admin-table td {
    padding: 0.75rem;
    text-align: left;
}

.admin-table tbody tr {
    border-bottom: 1px solid var(--border);
}

.admin-table td.actions {
    text-align: right;
}

.btn-admin-action {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0.25rem 0.5rem;
    border-radius: 0.3rem;
    cursor: pointer;
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

.btn-admin-action.delete {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 1rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    border: 1px solid var(--border);
}

.qr-container {
    background: white;
    padding: 1rem;
    border-radius: 0.5rem;
    display: inline-block;
    margin-bottom: 1rem;
}

.totp-secret {
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-all;
    margin-bottom: 1.5rem;
}

.totp-secret strong {
    color: var(--primary);
    font-family: monospace;
    font-size: 1rem;
}

.totp-input {
    padding: 0.75rem;
    border-radius: 0.4rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.2rem;
    width: 100%;
    margin-bottom: 1.5rem;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
}

.modal-footer button {
    flex: 1;
}

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0.75rem;
    border-radius: 0.4rem;
    cursor: pointer;
    font-weight: 600;
}

/* Layout Compontents */
.footer-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer-nav {
    display: flex;
    align-items: center;
    gap: 4rem;
}

.btn-nav {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    line-height: 1;
}

.btn-nav:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border);
}

/* Utility Helpers */
.hidden {
    display: none !important;
}

.align-center {
    align-items: center;
}

.inline-form {
    display: inline;
}

.icon-muted {
    opacity: 0.8;
}

.success-text {
    color: var(--success);
    font-weight: 600;
    margin-bottom: 1rem;
}

.danger-text {
    color: var(--danger);
    font-size: 1rem;
    margin: 0 0 1rem;
}

.status-admin {
    color: var(--primary);
}

.dropdown-content.up {
    bottom: 100%;
    top: auto;
    margin-bottom: 0.5rem;
    margin-top: 0;
}

.dropdown-content a.active {
    background: #333;
    color: var(--white);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
}

.dropdown-submenu {
    position: relative;
}

.submenu-content {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    background: var(--card-bg);
    min-width: 180px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    z-index: 10;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.submenu-trigger::after {
    content: "\2192";
    float: right;
    font-size: 0.8rem;
    opacity: 0.5;
}

@media (min-width: 769px) {
    .dropdown-submenu:hover .submenu-content {
        display: block;
    }
}

.submenu-content.up {
    bottom: 0;
    top: auto;
}

@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .week-nav {
        justify-content: center;
    }

    .dropdown-content {
        min-width: 200px;
        z-index: 1000;
    }

    .footer-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(18, 18, 18, 0.85);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        padding: 1rem;
        margin-top: 0 !important;
        border-top: 1px solid var(--border);
        z-index: 100;
        box-shadow: 0 -10px 15px -3px rgba(0, 0, 0, 0.3);
    }

    .footer-nav {
        gap: 3rem;
    }

    main {
        padding-bottom: 5rem;
    }

    .submenu-content {
        position: static;
        display: none;
        background: rgba(255, 255, 255, 0.05);
        border: none;
        box-shadow: none;
        border-radius: 0;
        margin-left: 1rem;
    }

    .submenu-content.show {
        display: block;
    }

    .submenu-trigger::after {
        content: "\2193";
    }
}