:root {
    --bg: #f2efe8;
    --surface: #fffdf8;
    --surface-alt: #f6f1e6;
    --text: #1d1a16;
    --muted: #685f55;
    --line: #d7ccbc;
    --accent: #9e4f2d;
    --accent-dark: #7e3f24;
    --success: #2d6a4f;
    --danger: #8f2d2d;
    --shadow: 0 18px 50px rgba(76, 53, 32, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(158, 79, 45, 0.18), transparent 30%),
        linear-gradient(180deg, #efe7da 0%, var(--bg) 42%, #ece6da 100%);
}

.page-shell {
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.panel {
    background: rgba(255, 253, 248, 0.92);
    border: 1px solid rgba(215, 204, 188, 0.9);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 24px;
}

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

.hero-panel h1,
.panel h2,
.panel h3 {
    margin: 0 0 10px;
    font-family: Georgia, "Times New Roman", serif;
}

.hero-badge {
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
    color: var(--accent-dark);
    font-weight: 700;
}

.eyebrow {
    margin: 0 0 8px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 12px;
    color: var(--muted);
}

.lead {
    max-width: 640px;
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.auth-panel {
    max-width: 520px;
}

.password-input-wrap {
    position: relative;
}

.password-input-wrap input {
    padding-right: 52px;
}

.password-toggle-button {
    position: absolute;
    top: 50%;
    right: 8px;
    z-index: 2;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: #fff;
    color: var(--muted);
    box-shadow: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.password-toggle-icon {
    width: 18px;
    height: 18px;
    color: currentColor;
}

.password-toggle-slash {
    color: currentColor;
}

.password-toggle-button:hover {
    background: #f7f2ea;
    color: var(--text);
    transform: translateY(-50%);
}

.password-toggle-button:focus {
    outline: none;
    box-shadow: inset 0 0 0 1px rgba(158, 79, 45, 0.18);
}

.stack-form {
    display: grid;
    gap: 16px;
}

.stack-form label {
    display: grid;
    gap: 8px;
}

.stack-form span {
    font-size: 14px;
    color: var(--muted);
}

.form-group-title {
    font-size: 14px;
    color: var(--muted);
}

input,
select,
button {
    font: inherit;
}

input,
select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
}

input:focus,
select:focus,
button:focus {
    outline: 2px solid rgba(158, 79, 45, 0.28);
    outline-offset: 2px;
}

button {
    border: 0;
    border-radius: 14px;
    padding: 14px 18px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

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

button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
}

.secondary-button {
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--line);
}

.user-menu {
    position: relative;
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    display: grid;
    gap: 8px;
    min-width: 220px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
    z-index: 10;
}

.user-menu-dropdown button {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font-weight: 500;
    box-shadow: none;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.user-menu-dropdown button:hover {
    background: #f4efe9;
    border-color: #e7ddd2;
    transform: none;
}

.user-menu-dropdown button:focus {
    outline: 2px solid rgba(158, 79, 45, 0.16);
    outline-offset: 2px;
}

.dashboard {
    display: grid;
    gap: 24px;
}

.dashboard-section {
    display: grid;
    gap: 24px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-switcher-panel {
    padding: 24px;
}

.section-switcher {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}

.client-section-switcher {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.section-toggle-button {
    min-height: 72px;
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 17px;
    border-radius: 16px;
    direction: ltr;
}

.section-toggle-button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

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

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

.inline-form {
    display: grid;
    grid-template-columns: 1.1fr 1.2fr auto;
    gap: 12px;
    margin-bottom: 12px;
}

.screen-topbar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 16px;
}

.logs-filter-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.analytics-filter-form {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.analytics-chart-card {
    display: grid;
    gap: 12px;
    margin: 12px 0 16px;
}

.analytics-chart-row {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fff;
}

.analytics-chart-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.analytics-chart-head span,
.analytics-chart-meta {
    color: var(--muted);
    font-size: 14px;
}

.analytics-chart-bar-track {
    height: 12px;
    border-radius: 999px;
    background: var(--surface-alt);
    overflow: hidden;
}

.analytics-chart-bar {
    height: 100%;
    border-radius: 999px;
    background: var(--success);
}

.analytics-chart-bar.warning {
    background: var(--danger);
}

.export-form {
    grid-template-columns: minmax(0, 1fr) auto;
}

.worker-form {
    grid-template-columns: 1fr 1fr 1fr auto;
}

.worker-hours-panel {
    display: grid;
    gap: 16px;
}

.worker-hours-row {
    padding-right: 48px;
}

.worker-hours-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 160px;
    gap: 16px;
    align-items: end;
}

.worker-hours-field {
    display: grid;
    gap: 8px;
}

.worker-hours-field span {
    font-size: 14px;
    color: var(--muted);
}

.form-actions {
    display: flex;
    justify-content: flex-start;
}

.detail-list,
.list-card {
    display: grid;
    gap: 12px;
}

.projects-flow {
    display: grid;
    gap: 16px;
}

.detail-item,
.list-item {
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
}

.deletable-card {
    position: relative;
    padding-bottom: 36px;
}

.selectable-card {
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.selectable-card:hover {
    border-color: rgba(158, 79, 45, 0.38);
}

.selectable-card.selected {
    background: #f4ece3;
    border-color: rgba(158, 79, 45, 0.55);
    box-shadow: inset 0 0 0 1px rgba(158, 79, 45, 0.12);
}

.card-delete-button {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--danger);
    font-size: 18px;
    line-height: 1;
}

.card-edit-button {
    position: absolute;
    right: 42px;
    bottom: 10px;
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--accent-dark);
    font-size: 14px;
    line-height: 1;
}

.card-edit-button:hover {
    background: #f7efe6;
}

.card-delete-button:hover {
    background: #fff3f0;
}

.detail-item strong,
.list-item strong {
    display: block;
    margin-bottom: 4px;
}

.detail-item span,
.list-item span {
    display: block;
    line-height: 1.45;
    color: var(--muted);
}

.compact-list .list-item {
    padding: 12px 14px;
}

.project-select-card {
    width: 100%;
    text-align: left;
    box-shadow: none;
    background: var(--surface-alt);
    color: var(--text);
}

.project-select-card:hover {
    transform: none;
}

.subpanel {
    display: grid;
    gap: 10px;
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 16px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
}

.price-mode-switcher {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.price-mode-switcher .secondary-button.active,
.price-mode-switcher .secondary-button:disabled {
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--line);
}

.price-mode-switcher .secondary-button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.price-material-placeholder {
    opacity: 0.8;
}

.price-row {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(180px, 0.8fr) auto;
    gap: 12px;
    align-items: center;
}

.price-row-delete-button {
    align-self: stretch;
}

.price-actions {
    justify-content: flex-start;
}

.price-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    gap: 24px;
}

.price-work-panel {
    gap: 16px;
}

.price-list-panel {
    align-content: start;
    gap: 16px;
}

.subtle-text {
    margin: 0;
    color: var(--muted);
}

.selected-chip {
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
    color: var(--accent-dark);
    font-size: 14px;
    font-weight: 600;
}

.empty-step-card {
    color: var(--muted);
}

.context-card {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.single-context-card {
    grid-template-columns: minmax(0, 1fr);
    margin-bottom: 12px;
}

.context-item {
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
}

.context-item span {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--muted);
}

.context-item strong {
    display: block;
}

.report-items {
    display: grid;
    gap: 14px;
}

.report-row {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-alt);
}

.report-row-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(120px, 0.7fr) minmax(140px, 0.8fr) minmax(180px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.unit-box {
    display: grid;
    gap: 8px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    min-height: 78px;
}

.unit-box span {
    font-size: 14px;
    color: var(--muted);
}

.unit-box strong {
    font-size: 18px;
}

.crew-picker-field {
    position: relative;
}

.report-worker-picker {
    position: relative;
    display: grid;
    gap: 10px;
}

.crew-picker-button {
    width: 100%;
}

.crew-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 32px;
}

.crew-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    box-shadow: none;
}

.crew-chip:hover {
    background: #f7efe6;
    transform: none;
}

.crew-chip span {
    color: var(--danger);
    font-size: 14px;
    line-height: 1;
}

.crew-empty {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.crew-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 20;
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.crew-dropdown-header {
    font-size: 14px;
    color: var(--muted);
    font-weight: 600;
}

.crew-options {
    display: grid;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
}

.crew-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
}

.crew-option input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.crew-option span {
    color: var(--text);
    font-size: 14px;
}

.report-remaining {
    color: var(--muted);
    font-size: 13px;
}

.report-history-items {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.report-history-item {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
}

.report-row-actions {
    display: flex;
    align-items: end;
}

.status {
    min-height: 24px;
    margin: 14px 0 0;
    color: var(--muted);
    line-height: 1.4;
}

.status.error {
    color: var(--danger);
}

.status.success {
    color: var(--success);
}

.hidden {
    display: none;
}

@media (max-width: 780px) {
    .page-shell {
        width: min(100% - 24px, 1080px);
        padding-top: 20px;
    }

    .hero-panel,
    .panel-header,
    .grid {
        grid-template-columns: 1fr;
        display: grid;
    }

    .user-menu-dropdown {
        left: 0;
        right: auto;
        min-width: 100%;
    }

    .inline-form {
        grid-template-columns: 1fr;
    }

    .client-section-switcher,
    .context-card,
    .report-row-grid,
    .worker-hours-main {
        grid-template-columns: 1fr;
    }
}
