:root {
    --bg: #f3efe6;
    --bg-soft: #fbf8f2;
    --card: #fffdf9;
    --ink: #1f2a2c;
    --muted: #697376;
    --line: #d8cfbf;
    --accent: #1e6f5c;
    --accent-strong: #155345;
    --danger: #a63d40;
    --shadow: 0 20px 40px rgba(38, 47, 51, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top right, rgba(30, 111, 92, 0.12), transparent 22%),
        linear-gradient(180deg, #efe8dc 0%, #f6f2ea 45%, #f3efe6 100%);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: rgba(243, 239, 230, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(216, 207, 191, 0.8);
}

.brand {
    font-weight: 800;
    text-decoration: none;
    color: var(--ink);
}

.topbar-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.topbar-links a,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--ink);
    border: 1px solid var(--line);
    background: rgba(255, 253, 249, 0.7);
}

.topbar-links a.active,
.topbar-links a:hover,
.button-link:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.page {
    width: min(1280px, calc(100% - 32px));
    margin: 24px auto 48px;
}

.page.narrow {
    width: min(900px, calc(100% - 32px));
}

.page.workers-page {
    width: min(1000px, calc(100% - 32px));
}

.hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: end;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 8px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
}

h1, h2, h3, p {
    margin-top: 0;
}

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

.subtitle {
    max-width: 70ch;
    color: var(--muted);
}

.hero-note,
.card,
.flash {
    background: rgba(255, 253, 249, 0.9);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.hero-note {
    min-width: 220px;
    padding: 16px 18px;
    border-radius: 18px;
}

.hero-note span {
    display: block;
    margin-top: 6px;
    color: var(--muted);
}

.flash {
    padding: 14px 18px;
    margin-bottom: 20px;
    border-radius: 14px;
}

.flash-success {
    border-color: rgba(30, 111, 92, 0.35);
}

.flash-error {
    border-color: rgba(166, 61, 64, 0.35);
}

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

.section-head-wrap {
    align-items: start;
}

.section-action {
    width: auto;
    min-width: 180px;
    padding-inline: 18px;
}

.grid {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.subtle-card {
    border-radius: 16px;
    padding: 16px;
    background: rgba(251, 248, 242, 0.9);
    box-shadow: none;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 20px;
}

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

.summary-card {
    display: block;
    padding: 22px;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: rgba(255, 253, 249, 0.9);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--ink);
}

.summary-card strong,
.summary-card span {
    display: block;
}

.summary-card span {
    margin-top: 8px;
    color: var(--muted);
}

.flow-list {
    display: grid;
    gap: 10px;
}

.stack {
    display: grid;
    gap: 14px;
}

.compact {
    margin-bottom: 18px;
}

.inline {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.inline-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.line-items {
    display: grid;
    gap: 12px;
}

.line-item-row {
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) 140px 88px;
    align-items: end;
}

.line-field {
    display: grid;
    gap: 6px;
    align-self: end;
}

.line-field-label {
    display: block;
    margin-bottom: 0;
}

.concept-field input,
.line-hour-field input {
    width: 100%;
}

.line-hour-field input {
    text-align: right;
}

.line-item-actions {
    display: flex;
    gap: 8px;
    align-items: end;
    align-self: end;
}

.line-action {
    min-width: 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    font-size: 1.2rem;
    line-height: 1;
}

.hours-summary {
    display: grid;
    gap: 4px;
    align-content: end;
    padding: 0 4px 10px;
}

.hours-summary-label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0;
}

@media (max-width: 920px) {
    .line-item-row {
        grid-template-columns: minmax(0, 1fr) 110px 88px;
    }
}

label span {
    display: block;
    margin-bottom: 6px;
    font-size: 0.95rem;
    font-weight: 600;
}

input,
select,
button {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--line);
    padding: 11px 12px;
    font: inherit;
}

input,
select {
    background: var(--bg-soft);
}

button {
    background: var(--accent);
    color: white;
    border: 0;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
}

button:hover {
    background: var(--accent-strong);
    transform: translateY(-1px);
}

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

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.actions {
    width: 220px;
}

.inline-edit {
    display: contents;
}

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

.action-pair form {
    flex: 1;
}

.action-pair button {
    min-width: 96px;
}

.history-actions form {
    min-width: 120px;
}

.monthly-hours-inline-form {
    margin: 0;
}

.monthly-hours-input {
    max-width: 120px;
    text-align: right;
}

.monthly-hours-actions-cell {
    width: 132px;
}

.monthly-hours-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

.monthly-hours-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
}

.monthly-hours-action-icon {
    font-size: 0.95rem;
    line-height: 1;
}

.monthly-hours-action-edit {
    background: var(--accent);
}

.monthly-hours-action-save {
    background: #2b7a42;
}

.monthly-hours-action-cancel {
    background: var(--danger);
}

.dni-input {
    max-width: 220px;
}

.worker-dni-input {
    max-width: 160px;
}

.worker-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
}

.worker-actions form {
    width: auto;
}

.worker-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 12px;
}

.worker-action-icon {
    font-size: 1rem;
    line-height: 1;
}

.worker-action-save {
    background: var(--accent);
}

.worker-action-concepts {
    background: #8f6a2a;
}

.worker-action-delete {
    background: var(--danger);
}

.worker-concepts-dialog {
    width: min(640px, calc(100% - 32px));
}

.worker-concept-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.worker-concept-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.assignment-box {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--bg-soft);
}

.assignment-box + .assignment-box {
    margin-top: 14px;
}

.project-list {
    display: grid;
    gap: 16px;
}

.project-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.project-card-compact {
    padding: 18px 20px;
}

.project-card-body {
    min-width: 0;
}

.project-card-title {
    margin-bottom: 8px;
    font-size: clamp(1rem, 1.8vw, 1.5rem);
    line-height: 1.15;
}

.project-meta {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--muted);
}

.project-card-closed {
    background: rgba(244, 240, 234, 0.92);
}

.project-card-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.project-card-actions-wrap {
    flex-wrap: nowrap;
    justify-content: end;
    align-self: start;
}

.project-card-actions-wrap form,
.project-card-actions-wrap .button-link {
    width: auto;
}

.project-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    min-width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 14px;
}

.project-action-button.button-link {
    padding: 0;
}

.project-action-icon {
    font-size: 1.05rem;
    line-height: 1;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.checkbox-list {
    display: grid;
    gap: 8px;
    margin: 14px 0;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox input {
    width: auto;
}

.muted {
    color: var(--muted);
}

a {
    color: var(--accent-strong);
}

.import-dialog {
    width: min(560px, calc(100% - 32px));
    margin: auto;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(255, 253, 249, 0.99);
    box-shadow: 0 28px 60px rgba(31, 42, 44, 0.24);
}

.import-dialog::backdrop {
    background: rgba(31, 42, 44, 0.52);
    backdrop-filter: blur(4px);
}

.modal-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.modal-close {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
    font-size: 1.5rem;
    line-height: 1;
}

.modal-actions {
    display: flex;
    justify-content: end;
    gap: 10px;
    flex-wrap: wrap;
}

.modal-actions .button-link,
.modal-actions button {
    width: auto;
    min-width: 130px;
}

.modal-secondary {
    color: var(--ink);
    background: rgba(255, 253, 249, 0.7);
}

@media (max-width: 920px) {
    .grid-2,
    .summary-grid,
    .inline,
    .hero {
        grid-template-columns: 1fr;
        display: grid;
    }

    .section-head,
    .project-card,
    .topbar {
        display: grid;
    }

    .project-meta,
    .project-card-actions-wrap {
        display: grid;
    }

    .page {
        width: min(100% - 20px, 1280px);
    }

    .section-action,
    .project-card-actions-wrap form,
    .project-card-actions-wrap .button-link,
    .modal-actions .button-link,
    .modal-actions button {
        width: 100%;
    }

    .project-card-actions-wrap button {
        width: 48px;
    }
}
