:root {
    --bg-page: #f4f6f8;
    --bg-card: #ffffff;
    --bg-topbar: #2d3e50;
    --text-primary: #1a1a1a;
    --text-secondary: #444444;
    --text-muted: #777777;
    --topbar-text: #dce6f0;
    --border-color: #ccd3d9;
    --table-border: #eceff1;
    --table-header-bg: #f0f3f6;
    --accent: #2d78e0;
    --accent-hover: #245fb3;
    --error: #c0392b;
    --flash-success-bg: #e3f6e8; --flash-success-text: #1e7d34;
    --flash-error-bg: #fbe4e2; --flash-error-text: #a3271b;
    --flash-info-bg: #e5f0fb; --flash-info-text: #1c5a91;
}

[data-theme="dark"] {
    --bg-page: #1a1d21;
    --bg-card: #24282e;
    --bg-topbar: #14161a;
    --text-primary: #e8eaed;
    --text-secondary: #b8bcc2;
    --text-muted: #8a8f98;
    --topbar-text: #c8d0da;
    --border-color: #3a3f47;
    --table-border: #33383f;
    --table-header-bg: #2b3036;
    --accent: #4a8fe8;
    --accent-hover: #6ba3ec;
    --error: #e57373;
    --flash-success-bg: #1e3a26; --flash-success-text: #7fd99a;
    --flash-error-bg: #3d2320; --flash-error-text: #f0a29c;
    --flash-info-bg: #1e2f42; --flash-info-text: #8fc1ef;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    margin: 0;
    background: var(--bg-page);
    color: var(--text-primary);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-topbar);
    color: white;
    padding: 14px 24px;
    flex-wrap: wrap;
    gap: 8px;
}

.topbar .brand { font-weight: 600; font-size: 1.1rem; }

.topbar nav a, .topbar .whoami {
    color: var(--topbar-text);
    margin-left: 16px;
    text-decoration: none;
    font-size: 0.9rem;
}

.topbar nav a:hover { text-decoration: underline; }

.theme-toggle-btn {
    background: none;
    border: 1px solid var(--topbar-text);
    color: var(--topbar-text);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.85rem;
    cursor: pointer;
    margin-left: 16px;
}

.container {
    max-width: 1300px;
    margin: 40px auto;
    padding: 0 20px;
}

.auth-card {
    background: var(--bg-card);
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    max-width: 420px;
    margin: 0 auto;
}

h1 { font-size: 1.4rem; margin-bottom: 20px; }

.field { margin-bottom: 16px; display: flex; flex-direction: column; }
.field label { font-size: 0.85rem; margin-bottom: 4px; color: var(--text-secondary); }
.field input, .field select, .field textarea {
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
    background: var(--bg-card);
    color: var(--text-primary);
}

.error { color: var(--error); font-size: 0.8rem; margin-top: 4px; }

input[type=submit], .btn-primary {
    display: inline-block;
    background: var(--accent);
    color: white;
    border: none;
    padding: 9px 18px;
    border-radius: 4px;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
}
input[type=submit]:hover, .btn-primary:hover { background: var(--accent-hover); }

.btn-danger-link {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9rem;
    padding: 0;
}

.flash-messages { margin-bottom: 20px; }
.flash {
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}
.flash-success { background: var(--flash-success-bg); color: var(--flash-success-text); }
.flash-error { background: var(--flash-error-bg); color: var(--flash-error-text); }
.flash-info { background: var(--flash-info-bg); color: var(--flash-info-text); }

.data-table {
    min-width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 6px;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--table-border);
    font-size: 0.9rem;
}
.data-table th { background: var(--table-header-bg); }
.data-table a { color: var(--accent); margin-right: 10px; }

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9rem;
    padding: 0;
}

@media print {
    .topbar, .btn-primary, .btn-danger-link, .btn-link, form, .flash-messages, .no-print {
        display: none !important;
    }
    body { background: white; color: black; }
    .container { max-width: 100%; margin: 0; }
    .data-table { box-shadow: none; }
    .data-table th { background: #eee !important; -webkit-print-color-adjust: exact; }
    a { color: black !important; text-decoration: none !important; }
}

/* ---------------------------------------------------------------------
   Mobile responsiveness
   --------------------------------------------------------------------- */

.topbar-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-toggle-btn {
    display: none; /* only shown on small screens, see media query below */
    background: none;
    border: 1px solid var(--topbar-text);
    color: var(--topbar-text);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 1.1rem;
    cursor: pointer;
}

/* Wrap any <table> in <div class="table-responsive"> so wide tables
   scroll horizontally on narrow screens instead of overflowing/breaking
   the page layout. */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .topbar { padding: 10px 16px; }
    .nav-toggle-btn { display: inline-block; }

    /* Nav becomes a hidden vertical dropdown, toggled by the hamburger button */
    #mainNav {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        margin-top: 10px;
        gap: 4px;
    }
    #mainNav.nav-open {
        display: flex;
    }
    #mainNav a, #mainNav .whoami {
        margin-left: 0;
        padding: 8px 4px;
        width: 100%;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }
    #mainNav .theme-toggle-btn {
        margin-left: 0;
        margin-top: 6px;
    }

    .container {
        margin: 16px auto;
        padding: 0 12px;
    }

    .auth-card {
        padding: 20px;
        max-width: 100%;
    }

    h1 { font-size: 1.2rem; }

    /* Prevent iOS Safari's auto-zoom-on-focus, which happens whenever an
       input's font-size is under 16px - this is a real, easy-to-miss trap. */
    .field input, .field select, .field textarea,
    input[type=text], input[type=date], input[type=time], input[type=email], input[type=password] {
        font-size: 16px;
    }

    /* Bigger touch targets (44px is the generally recommended minimum) */
    .btn-primary, input[type=submit], button[type=submit] {
        min-height: 44px;
        padding: 10px 16px;
    }

    .data-table th, .data-table td {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    /* Deadlines Calendar: 7 columns is tight on small phones - shrink further */
    .calendar-cell { height: 50px !important; font-size: 0.7rem; }
}

/* ---------------------------------------------------------------------
   Dashboard "launcher" look, matching the desktop app's home window.
   Scoped entirely under .launcher so it cannot affect any other page.
   --------------------------------------------------------------------- */
.launcher {
    background: #141414;
    border-radius: 8px;
    padding: 20px;
    color: #e8e8e8;
}

.launcher-welcome {
    font-size: 0.95rem;
    color: #c8c8c8;
    margin: 0 0 16px 4px;
}

.launcher-section { margin-bottom: 18px; }

.launcher-section-title {
    background: #000;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.launcher-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.launcher-btn {
    display: inline-block;
    color: #fff;
    text-decoration: none;
    text-align: center;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    flex: 1 1 180px;
    min-height: 44px;
    transition: filter 0.15s;
}
.launcher-btn:hover { filter: brightness(1.12); }

.launcher-btn-wide { flex: 1 1 100%; }

@media (max-width: 480px) {
    .launcher-btn { flex: 1 1 100%; }
}

.date-format-hint {
    display: inline-block;
    margin-left: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}
