:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-muted: #eaf0f7;
    --text: #1f2937;
    --text-muted: #667085;
    --primary: #0b6e4f;
    --primary-hover: #0f8a63;
    --danger: #b42318;
    --danger-hover: #912018;
    --success-bg: #ecfdf3;
    --success-text: #027a48;
    --error-bg: #fef3f2;
    --error-text: #b42318;
    --border: #d0d8e3;
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.45;
    background:
        radial-gradient(circle at 15% 5%, rgba(11, 110, 79, 0.09), transparent 35%),
        radial-gradient(circle at 90% 0%, rgba(11, 110, 79, 0.07), transparent 32%),
        linear-gradient(180deg, #f7fafe 0%, var(--bg) 100%);
}

.container {
    width: min(1220px, 94vw);
    margin: 0 auto;
}

.site-header {
    background: linear-gradient(120deg, #123942 0%, #0b6e4f 100%);
    color: #fff;
    padding: 18px 0;
    box-shadow: 0 8px 20px rgba(8, 39, 61, 0.24);
}

.row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.app-title {
    margin: 0;
    font-size: 1.45rem;
}

.subtitle {
    margin: 4px 0 0;
    color: #dcfce7;
    font-size: 0.92rem;
}

.top-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.top-nav a {
    color: #fff;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.24);
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.top-nav a:hover {
    background: rgba(255, 255, 255, 0.24);
}

main.container {
    padding: 24px 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 6px 16px rgba(16, 24, 40, 0.06);
}

.cards-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    margin-bottom: 16px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.stat-card h3 {
    margin: 0 0 8px;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.stat-value {
    margin: 0;
    font-size: 1.7rem;
    font-weight: 700;
}

.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.page-actions h2 {
    margin: 0;
}

.admin-shortcuts-card {
    padding-top: 14px;
}

.admin-shortcuts-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.admin-shortcuts-head h3 {
    margin: 0;
    font-size: 1rem;
}

.admin-shortcuts-head .hint {
    margin: 4px 0 0;
    font-size: 0.84rem;
}

.admin-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-shortcut {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 170px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #dbe4ee;
    background: linear-gradient(180deg, #fbfdff 0%, #f2f7fc 100%);
    color: var(--text);
    text-decoration: none;
    box-shadow: 0 3px 8px rgba(16, 24, 40, 0.04);
}

.admin-shortcut:hover {
    border-color: #bfd0e2;
    background: linear-gradient(180deg, #ffffff 0%, #edf4fb 100%);
}

.admin-shortcut-title {
    font-size: 0.83rem;
    font-weight: 700;
    line-height: 1.2;
}

.admin-shortcut-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.2;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    padding: 8px 12px;
    font-size: 0.92rem;
    cursor: pointer;
    white-space: nowrap;
}

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

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

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

.btn-light {
    background: var(--surface-muted);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
    font-size: 0.92rem;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    width: 100%;
    padding: 9px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    font: inherit;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
    outline: 2px solid rgba(11, 110, 79, 0.25);
    border-color: #0b6e4f;
}

.full-width {
    grid-column: 1 / -1;
}

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

.dashboard-pwa-compact h3 {
    margin: 0 0 6px;
    font-size: 1rem;
}

.dashboard-pwa-compact .hint {
    margin: 4px 0;
    font-size: 0.86rem;
}

.dashboard-pwa-compact .inline-actions {
    margin-top: 6px;
}

.dashboard-pwa-compact .btn {
    padding: 6px 10px;
    font-size: 0.84rem;
}

.inline {
    display: inline-flex;
    margin: 0 4px 4px 0;
    gap: 6px;
}

.inline-actions {
    display: inline-flex;
    gap: 8px;
    align-items: flex-end;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

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

th {
    background: #f7fafc;
    font-size: 0.84rem;
    color: #334155;
}

.reset-password-form {
    align-items: center;
    gap: 6px;
}

.reset-password-form input {
    width: 138px;
}

.service-items-card {
    margin-top: 6px;
}

.service-items-card h3 {
    margin: 0;
    font-size: 1rem;
}

.service-history-card {
    padding-top: 12px;
}

.service-history-table {
    min-width: 1040px;
}

.service-history-table tbody tr:hover {
    background: #f7fbfa;
}

.service-history-table td {
    padding-top: 7px;
    padding-bottom: 7px;
}

.service-intervention-cell {
    min-width: 210px;
    max-width: 320px;
}

.service-col-actions {
    min-width: 84px;
    width: 84px;
}

.service-history-table th.service-col-date,
.service-history-table td.service-col-date {
    min-width: 96px;
    max-width: 96px;
    width: 96px;
    white-space: nowrap !important;
    font-size: 0.73rem;
}

.service-history-table th.service-col-vehicle,
.service-history-table td.service-col-vehicle {
    min-width: 210px;
    max-width: 210px;
    width: 210px;
    white-space: nowrap !important;
    font-size: 0.76rem;
}

.service-date-pill {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    background: #eaf6f2;
    color: #0f5132;
    font-weight: 700;
    letter-spacing: 0.1px;
    white-space: nowrap;
}

.service-vehicle-chip {
    display: inline-flex;
    align-items: center;
    max-width: 198px;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid #d9e3f0;
    background: #f9fbff;
}

.service-vehicle-text {
    display: inline-block;
    max-width: 186px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: top;
}

.service-intervention-title {
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.24;
}

.service-intervention-workshop {
    margin-top: 2px;
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.2;
}

.service-intervention-notes {
    margin-top: 3px;
    max-width: 240px;
    font-size: 0.63rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.service-actions-inline {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.icon-form {
    margin: 0;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
}

.icon-btn svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.icon-btn-light {
    background: var(--surface-muted);
    color: var(--text);
}

.icon-btn-light:hover {
    background: #dde8f2;
}

.icon-btn-danger {
    background: #fff4f3;
    color: var(--danger);
    border-color: #f3c7c2;
}

.icon-btn-danger:hover {
    background: #fde8e6;
}

.service-money-cell strong {
    display: block;
    font-size: 0.88rem;
}

.service-money-currency {
    display: inline-block;
    margin-top: 2px;
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.service-items-table th,
.service-items-table td {
    white-space: nowrap;
}

.service-items-table input {
    min-width: 110px;
}

.service-items-table input[name="item_part_name[]"] {
    min-width: 190px;
}

.service-items-table input[name="item_notes[]"] {
    min-width: 170px;
}

.flash {
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid transparent;
}

.flash-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #abefc6;
}

.flash-error {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: #fecdca;
}

.site-footer {
    margin: 8px auto 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.login-card {
    max-width: 460px;
    margin: 24px auto;
}

code {
    white-space: pre-wrap;
}

@media (max-width: 900px) {
    .row {
        flex-direction: column;
        align-items: flex-start;
    }

    .top-nav {
        justify-content: flex-start;
    }

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

    .admin-shortcuts {
        width: 100%;
        flex-direction: column;
    }

    .admin-shortcut {
        width: 100%;
        min-width: 0;
    }

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

    .btn,
    .btn-light,
    .btn-danger {
        width: 100%;
    }

    .inline,
    .inline-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .reset-password-form input {
        width: 100%;
    }

    table {
        min-width: 700px;
    }
}
