:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #1f2a37;
    --muted: #5b6b7b;
    --primary: #1d3d5c;
    --primary-dark: #16214a;
    --danger-bg: #fdecea;
    --danger-text: #8a1f13;
    --border: #d8dee5;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.container {
    width: 100%;
    max-width: 420px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 6px 24px rgba(15, 30, 45, 0.08);
}

h1 {
    font-size: 1.25rem;
    margin: 0 0 1rem;
}

label {
    display: block;
    margin: 0.75rem 0 0.25rem;
    font-weight: 600;
}

input[type='text'],
input[type='password'] {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: #ffffff;
    color: var(--text);
}

input[type='text']:focus,
input[type='password']:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29, 92, 58, 0.15);
}

button {
    margin-top: 1.25rem;
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

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

button.secondary {
    background: #5b6b7b;
}

button.secondary:hover {
    background: #47545f;
}

.alert {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid #f0b4ac;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 1rem;
}

.alert p {
    margin: 0.15rem 0;
}

a {
    color: var(--primary);
}

@media (max-width: 480px) {
    body {
        padding: 0.75rem;
    }

    .card {
        padding: 1.15rem;
    }
}


/* Catalog servicii */

.container.wide {
    max-width: 960px;
}

.page-card {
    box-shadow: 0 2px 12px rgba(15, 30, 45, 0.06);
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.page-header h1 {
    margin: 0;
}

.btn-link {
    display: inline-block;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
}

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

.btn-link.secondary {
    background: #5b6b7b;
}

a.btn-small {
    display: inline-block;
    padding: 0.35rem 0.6rem;
    margin: 0.15rem 0.15rem 0.15rem 0;
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    background: #ffffff;
    cursor: pointer;
    white-space: nowrap;
}

a.btn-small:hover {
    background: #eaf3ee;
}

.inline-form {
    display: inline;
    margin: 0;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin: 0 0 1rem;
}

.filter-form .field {
    flex: 1 1 200px;
    min-width: 160px;
}

.filter-form .field label {
    margin-top: 0;
}

.filter-form button {
    margin-top: 0;
    width: auto;
    padding: 0.65rem 1rem;
}

select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: #ffffff;
    color: var(--text);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table.catalog {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

table.catalog th,
table.catalog td {
    text-align: left;
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.catalog th {
    background: #f0f3f6;
    font-size: 0.9rem;
}

table.catalog td.price,
table.catalog th.price {
    text-align: right;
    white-space: nowrap;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge.active {
    background: #e2f2e8;
    color: #1d5c3a;
}

.badge.inactive {
    background: #eceef1;
    color: #5b6b7b;
}

.catalog-form {
    border-top: 1px solid var(--border);
    margin-top: 1.5rem;
    padding-top: 1rem;
}

.catalog-form h2 {
    font-size: 1.1rem;
    margin: 0 0 0.5rem;
}

.alert.success {
    background: #e2f2e8;
    color: #1d5c3a;
    border-color: #b4ddc4;
}

.alert.error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: #f0b4ac;
}

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

@media (max-width: 600px) {
    .filter-form .field,
    .filter-form button {
        width: 100%;
        flex: 1 1 100%;
    }
}


/* Branduri și locații */

.entity-section {
    margin-top: 1rem;
}

.entity-section > h2 {
    border-bottom: 1px solid var(--border);
    font-size: 1.1rem;
    margin: 0 0 0.5rem;
    padding-bottom: 0.35rem;
}

.entity-section .catalog-form {
    margin-top: 1rem;
}


/* Lucrări */

textarea {
    width: 100%;
    min-height: 90px;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    background: #ffffff;
    color: var(--text);
    resize: vertical;
}

input[readonly] {
    background: #f0f3f6;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

table.catalog tfoot td {
    border-top: 2px solid var(--border);
    background: #f7f9fb;
}


.badge.cancelled {
    background: #fdecea;
    color: #8a1f13;
}

tr.cancelled td {
    color: var(--muted);
    text-decoration: line-through;
}

.reason-input {
    width: 100%;
    min-width: 160px;
    margin: 0.2rem 0;
}


.preview-sheet {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    background: #ffffff;
}

.preview-head p {
    margin: 0.15rem 0;
}

.preview-head hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.6rem 0;
}

.table-wrap input[type='checkbox'] {
    width: auto;
    margin: 0;
}


/* Form controls refresh */
:root {
    --control-h: 44px;
    --control-radius: 10px;
}

input[type='text'],
input[type='password'],
input[type='email'],
input[type='tel'],
input[type='url'],
input[type='search'],
input[type='number'],
input[type='date'],
input[type='datetime-local'],
input[type='time'],
select,
textarea {
    width: 100%;
    min-height: var(--control-h);
    padding: 0.6rem 0.8rem;
    font: inherit;
    font-size: 16px;
    line-height: 1.3;
    color: var(--text);
    background-color: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--control-radius);
    box-shadow: inset 0 1px 1px rgba(15, 30, 45, 0.03);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

select {
    padding-right: 2.4rem;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 20px) calc(50% - 3px),
        calc(100% - 14px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    cursor: pointer;
}

input[type='date'] {
    cursor: text;
    padding-right: 0.6rem;
}

input[type='date']::-webkit-calendar-picker-indicator {
    opacity: 0.55;
    cursor: pointer;
    padding: 0.15rem;
    border-radius: 6px;
}

input[type='date']:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type='number'] {
    -moz-appearance: textfield;
    appearance: textfield;
}


input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(29, 92, 58, 0.15);
}

input[readonly],
textarea[readonly] {
    background-color: #f0f3f6;
    color: var(--muted);
    box-shadow: none;
}

input[disabled],
select[disabled],
textarea[disabled] {
    background-color: #eef1f4;
    color: var(--muted);
    cursor: not-allowed;
}

input::placeholder,
textarea::placeholder {
    color: #9aa7b4;
}

label {
    font-size: 0.92rem;
    letter-spacing: 0.01em;
}

@media (max-width: 600px) {
    label {
        margin-top: 0.85rem;
    }

    select {
        background-position:
            calc(100% - 18px) calc(50% - 2px),
            calc(100% - 13px) calc(50% - 2px);
    }
}

@media (hover: hover) {
    input[type='text']:hover:not(:focus):not([readonly]),
    input[type='date']:hover:not(:focus),
    input[type='number']:hover:not(:focus),
    select:hover:not(:focus),
    textarea:hover:not(:focus) {
        border-color: #b9c4cf;
    }
}

@supports not ((-webkit-appearance: none) or (appearance: none)) {
    input[type='date'] {
        min-height: var(--control-h);
    }
}

input[type='checkbox'],
input[type='radio'] {
    width: 1.05rem;
    height: 1.05rem;
    min-height: 0;
    padding: 0;
    margin: 0 0.15rem 0 0;
    box-shadow: none;
    accent-color: var(--primary);
    vertical-align: middle;
}


/* Dashboard navigation buttons */
.dash-nav {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 0.5rem 0 1rem;
    width: 100%;
}

.dash-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
}

.dash-btn:hover {
    background: var(--primary-dark);
    color: #ffffff;
}

.dash-btn-primary {
    min-height: 64px;
    font-size: 1.05rem;
}


/* Pagina Lucrări */
.container.works-container { max-width: 1440px; }

.works-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.works-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0 0.85rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f7f9fb;
}

.works-summary-count { color: var(--muted); font-size: 0.92rem; }
.works-summary-total { font-weight: 700; color: var(--primary); }

.works-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.works-table th,
.works-table td {
    text-align: left;
    padding: 0.45rem 0.55rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    word-break: normal;
    overflow-wrap: break-word;
    font-size: 0.92rem;
}

.works-table th { background: #f0f3f6; font-size: 0.85rem; }

.works-table .c-date { width: 9%; }
.works-table .c-client { width: 15%; }
.works-table .c-loc { width: 15%; }
.works-table .c-work { width: 17%; }
.works-table .c-qty { width: 7%; text-align: center; }
.works-table .c-value { width: 15%; text-align: right; }
.works-table .c-state { width: 11%; }
.works-table .c-act { width: 11%; }

.nowrap { white-space: nowrap; }
.cell-strong { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 0.88rem; }
.cell-total { font-weight: 700; color: var(--primary); white-space: nowrap; }
.cell-link { font-size: 0.85rem; }
.works-row.is-cancelled td { color: var(--muted); }
.works-empty { color: var(--muted); }

.works-table .btn-small { margin-bottom: 0.2rem; }

.cancel-box { margin-top: 0.35rem; display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }

.works-cards { display: none; }

/* Filtre Lucrări */
.works-filter {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
    gap: 0.75rem;
    align-items: end;
    margin: 0 0 0.85rem;
}

.works-filter .field { min-width: 0; }

.works-filter button { margin-top: 0; width: 100%; }


@media (max-width: 1000px) {
    .works-table-wrap { display: none; }
    .works-cards { display: block; }

    .work-card {
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 0.75rem 0.85rem;
        margin-bottom: 0.75rem;
        background: #ffffff;
        box-shadow: 0 2px 8px rgba(15, 30, 45, 0.05);
    }

    .work-card.is-cancelled { opacity: 0.75; }

    .work-card-top {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        gap: 0.4rem;
        margin-bottom: 0.45rem;
    }

    .work-card-date { font-weight: 700; }
    .work-card-line { margin: 0.2rem 0; }
    .work-card-label { color: var(--muted); font-weight: 600; }
    .work-card-total {
        margin: 0.55rem 0 0.2rem;
        font-size: 1.08rem;
        font-weight: 700;
        color: var(--primary);
    }

    .work-card-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem;
        margin-top: 0.55rem;
    }

    .work-card .btn-small,
    .work-card .cancel-box .btn-small {
        padding: 0.5rem 0.75rem;
        font-size: 0.92rem;
    }

    .work-card .cancel-box {
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border);
    }

    .work-card .reason-input { width: 100%; }

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

    .works-filter .field-date { min-width: 0; }

    .works-filter .field-brand,
    .works-filter .field-beneficiary,
    .works-filter .field-status,
    .works-filter button {
        grid-column: 1 / -1;
    }
}

@media (max-width: 420px) {
    .works-summary {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Monedă inline */
.money-inline {
    color: var(--muted);
    font-size: 0.9em;
}

/* Appendix delete (danger) button */
button.btn-small {
    display: inline-block;
    width: auto;
    margin: 0.15rem 0.15rem 0.15rem 0;
    padding: 0.35rem 0.6rem;
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    background: var(--primary);
    color: #ffffff;
    border: none;
}

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

.btn-small.danger {
    display: inline-block;
    padding: 0.35rem 0.6rem;
    margin: 0.15rem 0.15rem 0.15rem 0;
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid #f0b4ac;
}

.btn-small.danger:hover {
    background: #f8d7d2;
}
