:root {
    --bg: #f6f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d8dee9;
    --primary: #116466;
    --primary-dark: #0b4e50;
    --accent: #f2b84b;
    --danger: #b42318;
    --danger-bg: #fff1f0;
    --shadow: 0 18px 45px rgba(23, 32, 51, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0;
}

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

.login-panel {
    width: min(420px, 100%);
    padding: 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-panel h1 {
    margin-bottom: 18px;
}

.login-panel .primary-btn {
    width: 100%;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.top-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.user-line {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 20px;
}

.filters,
.table-tools,
.table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.filters {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    padding: 16px;
    margin-bottom: 14px;
}

.search-field {
    grid-column: span 1;
}

label span {
    display: block;
    margin-bottom: 7px;
    color: #344054;
    font-size: 13px;
    font-weight: 700;
}

label b {
    color: var(--danger);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    outline: none;
}

input,
select {
    height: 40px;
    padding: 0 11px;
}

textarea {
    resize: vertical;
    padding: 10px 11px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(17, 100, 102, 0.15);
}

small {
    display: block;
    min-height: 17px;
    margin-top: 5px;
    color: var(--danger);
    font-size: 12px;
}

.field-error {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.filter-actions,
.export-actions,
.modal-actions,
.inline-field {
    display: flex;
    gap: 10px;
}

.filter-actions {
    align-items: end;
}

.table-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 14px;
}

#hourTotal {
    margin-left: 12px;
    color: var(--muted);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.icon-btn {
    min-height: 40px;
    border-radius: 6px;
    border: 1px solid transparent;
    padding: 0 14px;
    font-weight: 700;
}

.primary-btn {
    background: var(--primary);
    color: #fff;
}

.primary-btn:hover {
    background: var(--primary-dark);
}

.secondary-btn {
    background: #fff;
    border-color: var(--primary);
    color: var(--primary);
}

.ghost-btn {
    background: #fff;
    border-color: #cbd5e1;
    color: #344054;
}

.danger-btn {
    background: var(--danger);
    color: #fff;
}

.icon-btn {
    width: 40px;
    padding: 0;
    background: #fff;
    border-color: #cbd5e1;
    color: #344054;
}

.table-wrap {
    overflow: auto;
}

body[data-role="user"] .admin-only {
    display: none;
}

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

th,
td {
    border-bottom: 1px solid #e5e7eb;
    padding: 11px 12px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #eef3f7;
    color: #344054;
    font-size: 13px;
}

th button {
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    text-align: left;
    font-weight: 800;
}

.column-filters th {
    background: #fff;
}

.column-filters input {
    height: 34px;
    font-size: 13px;
}

td.description-cell {
    max-width: 460px;
    white-space: pre-wrap;
}

.row-actions {
    display: flex;
    gap: 8px;
}

.row-actions button {
    min-height: 34px;
    padding: 0 10px;
}

.empty-state {
    padding: 34px 12px;
    color: var(--muted);
    text-align: center;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.55);
    z-index: 20;
}

.modal.is-open {
    display: flex;
}

.modal-panel {
    width: min(620px, 100%);
    max-height: calc(100vh - 36px);
    overflow: auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.modal-panel.small {
    width: min(420px, 100%);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.modal-actions {
    justify-content: flex-end;
    margin-top: 14px;
}

.inline-field select {
    flex: 1;
}

.confirm-text {
    margin: 0;
    color: #344054;
}

.success-note {
    margin: 0 0 16px;
    padding: 10px 12px;
    border-radius: 6px;
    background: #e8f6f3;
    color: var(--primary-dark);
    font-weight: 700;
}

.user-form,
.master-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 16px;
}

.user-form .primary-btn,
.master-form .primary-btn,
.master-form .ghost-btn {
    align-self: end;
}

.user-list-wrap {
    overflow: auto;
}

.checkbox-list {
    display: grid;
    gap: 8px;
    max-height: 340px;
    overflow: auto;
    padding: 4px 2px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.checkbox-row input {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.checkbox-row span {
    margin: 0;
    font-size: 14px;
}

.toast-host {
    position: fixed;
    right: 18px;
    bottom: 18px;
    display: grid;
    gap: 10px;
    z-index: 40;
}

.toast {
    width: min(360px, calc(100vw - 36px));
    padding: 13px 15px;
    border-radius: 8px;
    background: #172033;
    color: #fff;
    box-shadow: var(--shadow);
}

.toast.success {
    background: var(--primary);
}

.toast.error {
    background: var(--danger);
}

@media (max-width: 900px) {
    .filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 640px) {
    .app-shell {
        width: min(100% - 20px, 1280px);
        padding: 18px 0;
    }

    .topbar,
    .table-tools {
        align-items: stretch;
        flex-direction: column;
    }

    .top-actions {
        justify-content: stretch;
    }

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

    .user-form,
    .master-form {
        grid-template-columns: 1fr;
    }

    .filter-actions,
    .export-actions {
        flex-wrap: wrap;
    }

    .primary-btn,
    .secondary-btn,
    .ghost-btn,
    .danger-btn {
        width: 100%;
    }

    .row-actions .secondary-btn,
    .row-actions .danger-btn,
    .inline-field .secondary-btn {
        width: auto;
    }
}
