:root {
    --bg: #f4f7fb;
    --panel: #12263a;
    --panel-accent: #1f6feb;
    --surface: #ffffff;
    --surface-soft: #eaf1fb;
    --text: #102033;
    --muted: #5b6b7d;
    --border: #d7e0eb;
    --shadow: 0 20px 45px rgba(16, 32, 51, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #eef4fb 0%, #f7f9fc 100%);
    color: var(--text);
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-shell {
    width: min(100%, 460px);
}

.login-panel {
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 28px;
    box-shadow: 0 24px 60px rgba(8, 22, 37, 0.12);
}

.login-kicker {
    margin: 0 0 12px;
    color: var(--panel-accent);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.login-form {
    margin-top: 20px;
    display: grid;
    gap: 18px;
}

.login-help {
    margin-top: 20px;
    padding: 16px;
    border-radius: 16px;
    background: #f5f8fd;
    border: 1px solid var(--border);
}

.login-help p {
    margin: 0 0 6px;
    color: var(--muted);
}

.login-links {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.login-links a {
    color: var(--panel-accent);
    font-weight: 600;
}

.login-links a:hover {
    text-decoration: underline;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 24px;
    padding: 18px;
    align-items: start;
}

.sidebar {
    background: linear-gradient(180deg, var(--panel) 0%, #183b5b 100%);
    color: #f8fbff;
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.drawer {
    min-height: calc(100vh - 36px);
    border-radius: 28px;
    box-shadow: 0 24px 60px rgba(8, 22, 37, 0.24);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.16);
    font-weight: 700;
    letter-spacing: 0.08em;
}

.brand-text {
    font-size: 1rem;
    font-weight: 600;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.nav-group {
    display: grid;
    gap: 8px;
}

.nav-group-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 14px;
    color: rgba(248, 251, 255, 0.78);
    cursor: pointer;
    list-style: none;
    font-weight: 600;
}

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

.nav-group-summary::after {
    content: "▾";
    font-size: 0.9rem;
    transition: transform 0.2s ease;
}

.nav-group[open] .nav-group-summary {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

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

.nav-group-links {
    display: grid;
    gap: 8px;
    padding-left: 12px;
}

.nav-group-empty {
    padding-left: 18px;
}

.nav-group-placeholder {
    color: rgba(248, 251, 255, 0.58);
    font-size: 0.9rem;
    padding: 4px 0 6px;
}

.sidebar-user {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.sidebar-user-name,
.sidebar-user-role {
    margin: 0;
}

.sidebar-user-name {
    font-weight: 600;
}

.sidebar-user-role {
    margin-top: 4px;
    color: rgba(248, 251, 255, 0.7);
    font-size: 0.9rem;
}

.sidebar-logout {
    width: 100%;
    margin-top: 14px;
    background: rgba(255, 255, 255, 0.14);
}

.nav-link {
    padding: 12px 14px;
    border-radius: 14px;
    color: rgba(248, 251, 255, 0.78);
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    transform: translateX(4px);
}

.nav-sublink {
    padding-left: 18px;
    font-size: 0.96rem;
}

.main-content {
    padding: 18px 18px 18px 0;
    min-width: 0;
}

.hero-card,
.info-card,
.table-card,
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.hero-card {
    padding: 32px;
    background:
        radial-gradient(circle at top right, rgba(31, 111, 235, 0.14), transparent 32%),
        var(--surface);
}

.hero-card.compact {
    max-width: 760px;
}

.dashboard-title {
    max-width: 880px;
    min-height: 180px;
    display: flex;
    align-items: center;
}

.eyebrow {
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.78rem;
    color: var(--panel-accent);
    font-weight: 700;
}

h1,
h2 {
    margin-top: 0;
}

h1 {
    margin-bottom: 12px;
    font-size: clamp(2rem, 4vw, 3.4rem);
}

.description {
    margin: 0;
    max-width: 62ch;
    color: var(--muted);
    line-height: 1.6;
}

.info-grid {
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.metrics-grid {
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
}

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

.metric-card {
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.metric-card.accent {
    background:
        linear-gradient(135deg, rgba(31, 111, 235, 0.08), rgba(18, 38, 58, 0.02)),
        var(--surface);
}

.metric-label {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.metric-card h2 {
    margin: 0;
    font-size: 2rem;
}

.metric-detail {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.action-grid {
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.action-bar {
    margin-top: 24px;
    display: flex;
}

.report-controls {
    margin-top: 24px;
    display: flex;
    gap: 16px;
    align-items: end;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.month-form {
    display: flex;
    flex: 0 1 260px;
}

.report-action-form {
    display: inline-flex;
    margin: 0;
}

.report-controls .button-link,
.report-controls button {
    margin-top: 0;
    min-height: 48px;
    line-height: 1.2;
}

.report-controls .button-link {
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    padding: 11px 16px;
    white-space: nowrap;
}

.refresh-card {
    margin-top: 18px;
    padding: 18px 20px;
    border-radius: 18px;
    background: linear-gradient(135deg, #f7faff 0%, #edf4ff 100%);
    border: 1px solid #d9e6fb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.refresh-card-label {
    margin: 0 0 6px;
    color: var(--panel-accent);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.refresh-card h2 {
    margin: 0 0 6px;
    font-size: 1.05rem;
}

.refresh-card-text {
    margin: 0;
    color: var(--muted);
    max-width: 560px;
}

.refresh-card .button-link {
    margin-top: 0;
    white-space: nowrap;
}

.field-inline {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
}

.field-inline span {
    font-weight: 600;
}

.info-card {
    padding: 24px;
}

.info-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.button-link,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    border-radius: 12px;
    border: none;
    background: var(--panel-accent);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    margin-top: 16px;
    text-align: center;
}

.button-link.secondary {
    background: #e4ebf5;
    color: var(--text);
}

.inline-form {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fbfdff;
    color: var(--text);
}

textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fbfdff;
    color: var(--text);
    font: inherit;
    resize: vertical;
}

select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fbfdff;
    color: var(--text);
}

.inline-form input {
    flex: 1 1 220px;
}

.inline-cost-form {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 180px;
}

.inline-cost-form input {
    min-width: 100px;
    padding: 9px 10px;
}

.employee-month-input {
    width: 100%;
    min-width: 100px;
    padding: 9px 10px;
}

.stacked-form {
    display: grid;
    gap: 18px;
}

.form-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-grid label {
    display: grid;
    gap: 8px;
    color: var(--text);
    font-weight: 700;
}

.form-grid label span {
    color: var(--muted);
    font-size: 0.85rem;
}

.form-grid-wide {
    grid-column: 1 / -1;
}

.flash-stack {
    margin-top: 20px;
    display: grid;
    gap: 10px;
}

.flash-message {
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--surface-soft);
    border: 1px solid #c8daf7;
    color: #0f3d78;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.flash-message-hidden {
    opacity: 0;
    transform: translateY(-8px);
}

.table-card,
.form-card {
    margin-top: 24px;
    padding: 24px;
}

.report-section {
    margin-top: 24px;
}

.report-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.report-summary::-webkit-details-marker {
    display: none;
}

.report-download {
    margin-top: 0;
    font-size: 0.95rem;
}

.report-card {
    margin-top: 12px;
}

.table-toolbar h2 {
    margin-bottom: 8px;
}

.table-toolbar p {
    margin: 0;
    color: var(--muted);
}

.table-wrapper {
    margin-top: 18px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.report-table {
    min-width: 1500px;
}

.project-table {
    min-width: 760px;
}

.report-table-title {
    text-align: center;
    font-weight: 700;
    background: #ffffff;
}

.col-name {
    width: 220px;
}

.col-title {
    width: 260px;
}

.col-cost {
    width: 130px;
}

.col-time {
    width: 120px;
}

.col-effort {
    width: 110px;
}

.col-small {
    width: 120px;
}

.col-slim {
    width: 92px;
}

th,
td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    background: #f8fbff;
    font-size: 0.95rem;
}

.report-table thead tr:first-child th {
    text-align: center;
    background: #eef4fb;
}

.group-header {
    font-size: 0.88rem;
    white-space: nowrap;
}

.project-col-name {
    width: 420px;
}

.project-col-time {
    width: 170px;
}

.project-col-cost {
    width: 150px;
}

.project-col-rate {
    width: 150px;
}

.project-label {
    white-space: pre-wrap;
}

.mini-button {
    margin-top: 0;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.85rem;
}

.mini-button.danger {
    background: #d94c4c;
}

.action-cell {
    display: flex;
    gap: 8px;
    align-items: center;
}

.employee-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.sql-template-form {
    display: grid;
    gap: 18px;
}

.sql-template-list {
    display: grid;
    gap: 18px;
    margin-top: 18px;
}

.sql-template-item {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fbfdff;
    overflow: hidden;
}

.sql-template-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    cursor: pointer;
    list-style: none;
}

.sql-template-summary::-webkit-details-marker {
    display: none;
}

.sql-template-summary::after {
    content: "▾";
    font-size: 0.9rem;
    transition: transform 0.2s ease;
}

.sql-template-item[open] .sql-template-summary::after {
    transform: rotate(180deg);
}

.sql-template-title {
    font-weight: 700;
}

.sql-template-summary-meta {
    color: var(--muted);
    font-size: 0.92rem;
}

.sql-template-content {
    padding: 0 18px 18px;
}

.sql-template-meta p {
    margin: 0 0 14px;
    color: var(--muted);
}

.sql-template-code {
    margin: 0;
    padding: 14px;
    border-radius: 14px;
    background: #12263a;
    color: #f8fbff;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.sql-template-code-wrap {
    position: relative;
}

.sql-copy-button {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
    margin-top: 0;
    padding: 7px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.22);
}

.sql-copy-button:hover {
    background: rgba(255, 255, 255, 0.22);
}

.sql-template-actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.template-preview-name {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #f5f8fd;
    font-weight: 600;
}

.settings-form {
    display: grid;
    gap: 18px;
}

.settings-table {
    min-width: 760px;
}

.settings-user-col {
    width: 280px;
}

.settings-role-col {
    width: 120px;
}

.settings-page-col {
    width: 180px;
    text-align: center;
}

.settings-actions-col {
    width: 110px;
    text-align: center;
}

.settings-user-email {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.92rem;
}

.settings-check-cell {
    text-align: center;
    vertical-align: middle;
}

.settings-check-cell input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--panel-accent);
}

.settings-role-select {
    min-width: 100px;
}

.settings-admin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    border-radius: 999px;
    background: #eaf1fb;
    color: #0f3d78;
    font-size: 0.84rem;
    font-weight: 700;
    white-space: nowrap;
}

.permission-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fbfdff;
}

.permission-row span {
    display: grid;
    gap: 6px;
}

.permission-row small {
    color: var(--muted);
    line-height: 1.5;
}

.permission-row input[type="checkbox"] {
    width: 22px;
    height: 22px;
    margin: 0;
    accent-color: var(--panel-accent);
    flex: 0 0 auto;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field span {
    font-weight: 600;
}

.field-help {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.4;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 860px) {
    .app-shell {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 16px;
    }

    .sidebar {
        gap: 20px;
        min-height: auto;
        padding: 20px 16px;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .nav-group {
        flex: 1 1 220px;
    }

    .nav-link {
        flex: 1 1 180px;
        justify-content: center;
    }

    .nav-group-links {
        padding-left: 0;
    }

    .nav-group-empty {
        padding-left: 0;
    }

    .nav-group-summary {
        justify-content: center;
    }

    .nav-sublink {
        padding-left: 14px;
    }

    .main-content {
        padding: 0;
    }

    .hero-card,
    .table-card,
    .form-card {
        padding: 20px;
    }

    .report-controls {
        align-items: stretch;
        flex-direction: column;
    }

    .month-form,
    .field-inline,
    .report-controls .button-link {
        width: 100%;
    }

    .report-summary {
        align-items: stretch;
        flex-direction: column;
    }

    .report-download {
        width: 100%;
    }

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

    .action-cell,
    .form-actions,
    .permission-row,
    .sql-template-summary,
    .sql-template-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .action-cell form,
    .action-cell a,
    .form-actions a,
    .form-actions button,
    .inline-cost-form button,
    .sql-template-actions a,
    .sql-template-actions button {
        width: 100%;
    }

    .inline-cost-form {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 560px) {
    .app-shell {
        padding: 8px;
    }

    .sidebar {
        border-radius: 20px;
    }

    .brand {
        align-items: flex-start;
        flex-direction: column;
    }

    .brand-text {
        font-size: 0.95rem;
        line-height: 1.4;
    }

    .hero-card,
    .table-card,
    .form-card,
    .report-summary {
        border-radius: 18px;
    }

    .hero-card {
        padding: 18px;
    }

    .login-panel {
        padding: 22px;
        border-radius: 20px;
    }

    h1 {
        font-size: clamp(1.7rem, 7vw, 2.4rem);
    }

    th,
    td {
        padding: 10px 8px;
        font-size: 0.9rem;
    }

    .report-table {
        min-width: 1180px;
    }

    .project-table {
        min-width: 620px;
    }
}
