:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #eef3f1;
    --text: #20252b;
    --muted: #69727d;
    --line: #dce2e8;
    --primary: #176b5b;
    --primary-strong: #0d4f43;
    --accent: #b45f2a;
    --danger: #b42318;
    --warn: #936100;
    --good: #137333;
    --radius: 8px;
    --shadow: 0 8px 22px rgba(24, 36, 48, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 64px;
    padding: 0 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}

.brand {
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
}

.nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
}

.nav a {
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.account {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    color: var(--muted);
}

.link-button {
    border: 0;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 48px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.page-header h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.15;
}

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

.actions,
.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.button:hover {
    text-decoration: none;
    border-color: var(--primary);
}

.button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

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

.full-width {
    width: 100%;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

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

.metric,
.summary-band,
.panel,
.form-panel,
.auth-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.metric {
    padding: 18px;
}

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

.module-card {
    display: grid;
    gap: 6px;
    min-height: 132px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
}

.module-card:hover {
    border-color: var(--primary);
    text-decoration: none;
}

.module-card span,
.module-card small {
    color: var(--muted);
    font-weight: 700;
}

.module-card strong {
    font-size: 24px;
}

.metric span,
.summary-band span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.metric strong {
    display: block;
    margin-top: 6px;
    font-size: 24px;
}

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

.summary-band div {
    padding: 16px 18px;
    background: var(--surface-2);
}

.summary-band strong {
    display: block;
    margin-top: 4px;
    font-size: 20px;
}

.dashboard-year-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-year-filter select {
    min-height: 38px;
    min-width: 96px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 8px 10px;
    color: var(--text);
    font: inherit;
    font-weight: 700;
}

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

.period-summary {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.period-summary-head {
    padding: 16px 18px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}

.period-summary-head span,
.period-summary dt {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.period-summary-head strong {
    display: block;
    margin-top: 4px;
    font-size: 22px;
}

.period-summary-head small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.period-summary dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    margin: 0;
    background: var(--line);
}

.period-summary dl div {
    min-width: 0;
    padding: 12px 14px;
    background: var(--surface);
}

.period-summary dd {
    margin: 2px 0 0;
    font-weight: 700;
}

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

.dashboard-chart-panel {
    min-height: 330px;
}

.chart-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.chart-legend i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.legend-income,
.income-bar {
    background: var(--primary);
}

.legend-expense,
.expense-bar {
    background: var(--accent);
}

.legend-cash-in,
.cash-in-bar {
    background: #2b6cb0;
}

.legend-cash-out,
.cash-out-bar {
    background: var(--danger);
}

.month-chart {
    display: grid;
    grid-template-columns: repeat(12, minmax(34px, 1fr));
    align-items: end;
    gap: 8px;
    height: 250px;
    padding: 22px 18px 16px;
    border-top: 1px solid rgba(220, 226, 232, 0.55);
    background:
        linear-gradient(to top, rgba(220, 226, 232, 0.9) 1px, transparent 1px) 0 0 / 100% 25%,
        var(--surface);
}

.month-chart-item {
    display: grid;
    grid-template-rows: 1fr auto;
    gap: 8px;
    min-width: 0;
    height: 100%;
}

.month-chart-bars {
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 4px;
    min-height: 0;
}

.chart-bar {
    width: min(16px, 42%);
    min-height: 0;
    border-radius: 4px 4px 0 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.month-chart-label {
    display: block;
    min-height: 16px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.rank-list {
    display: grid;
}

.rank-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--line);
    color: var(--text);
}

.rank-row:hover {
    background: #f8faf9;
    text-decoration: none;
}

.rank-row:last-child {
    border-bottom: 0;
}

.rank-name {
    min-width: 0;
    overflow: hidden;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-row strong {
    white-space: nowrap;
}

.rank-row small {
    grid-column: 1 / -1;
    color: var(--muted);
}

.rank-meter {
    grid-column: 1 / -1;
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #edf0f2;
}

.rank-meter i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.rank-meter.profit i {
    background: #2b6cb0;
}

.dashboard-empty {
    padding: 24px 18px;
}

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

.company-summary-layout {
    margin-bottom: 18px;
}

.cari-summary-panel {
    margin-bottom: 18px;
}

.cari-summary-scroll {
    overflow-x: auto;
}

.cari-summary-table {
    width: 100%;
    min-width: 1180px;
    border-collapse: collapse;
}

.cari-summary-table th,
.cari-summary-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.cari-summary-table thead th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    background: var(--surface);
}

.cari-summary-table tbody th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-align: left;
    text-transform: uppercase;
}

.cari-summary-table tbody td {
    font-size: 15px;
    font-weight: 700;
}

.cari-summary-table .summary-total-col {
    background: #eef4f8;
    font-weight: 900;
}

.cari-summary-table .summary-balance-row th,
.cari-summary-table .summary-balance-row td {
    border-bottom: 0;
}

.price-matrix-panel {
    overflow-x: auto;
}

.price-summary-matrix {
    display: grid;
    grid-template-columns: 92px repeat(3, minmax(130px, 1fr)) minmax(150px, 1.12fr);
    gap: 1px;
    min-width: 700px;
    background: var(--line);
}

.price-summary-matrix > div {
    min-height: 58px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    background: var(--surface-2);
    font-size: 17px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.price-summary-matrix .price-summary-heading,
.price-summary-matrix .price-summary-label {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0;
    text-transform: uppercase;
}

.price-summary-matrix .price-summary-heading {
    justify-content: center;
    min-height: 42px;
    background: var(--surface);
}

.price-summary-matrix .price-summary-label {
    justify-content: flex-start;
}

.price-summary-matrix .price-summary-corner {
    min-height: 42px;
    background: var(--surface);
}

.price-summary-matrix .price-summary-total {
    background: #eef4f8;
}

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

.hour-summary-values div {
    padding: 16px 18px;
    background: var(--surface-2);
}

.hour-summary-values span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.hour-summary-values strong {
    display: block;
    margin-top: 4px;
    font-size: 18px;
}

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

.stacked-section {
    margin-top: 18px;
}

.panel {
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.panel-header h2 {
    margin: 0;
    font-size: 18px;
}

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

.wide-table {
    min-width: 980px;
}

.company-list-table {
    min-width: 1320px;
}

.vehicle-list-table {
    min-width: 1180px;
}

.professional-list-table {
    min-width: 1320px;
}

.professional-expense-table {
    min-width: 1100px;
}

.expense-section-table {
    min-width: 1040px;
}

.profit-loss-table {
    min-width: 1120px;
}

.invoice-list-table {
    min-width: 1120px;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    font-weight: 700;
    white-space: nowrap;
}

.sort-link.active {
    color: var(--primary);
}

tbody tr:last-child td {
    border-bottom: 0;
}

.row-title-link {
    font-weight: 700;
}

.inline-separator {
    color: var(--muted);
    margin: 0 4px;
}

.muted-small {
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}

.price-breakdown {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.price-breakdown div {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-2);
}

.price-breakdown span,
.price-lines span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.price-breakdown strong {
    display: block;
    margin-top: 2px;
    font-size: 14px;
}

.price-lines {
    display: grid;
    gap: 2px;
    margin-top: 6px;
}

.category-summary-list {
    display: grid;
    gap: 1px;
}

.category-summary-list div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
}

.category-summary-list div:last-child {
    border-bottom: 0;
}

.category-summary-list span {
    color: var(--muted);
    font-weight: 700;
}

.price-lines.compact {
    margin-top: 5px;
}

.assignment-line + .assignment-line {
    margin-top: 4px;
}

.assignment-line strong {
    white-space: nowrap;
}

.empty {
    color: var(--muted);
    text-align: center;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #edf0f2;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.badge.good,
.status-paid {
    background: #e6f4ea;
    color: var(--good);
}

.badge.warn,
.status-unpaid,
.status-planned {
    background: #fff4d8;
    color: var(--warn);
}

.status-overdue,
.message.error {
    background: #fde8e7;
    color: var(--danger);
}

.status-cancelled,
.status-draft,
.status-paused,
.status-ended,
.badge.muted {
    background: #edf0f2;
    color: var(--muted);
}

.status-issued,
.status-active {
    background: #e6f4ea;
    color: var(--good);
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.filter-bar input,
.filter-bar select {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 8px 10px;
    font: inherit;
}

.filter-bar input {
    flex: 1;
}

.filter-bar .year-input {
    flex: 0 0 105px;
}

.filter-bar .date-input {
    flex: 0 0 150px;
}

.invoice-filter-bar select {
    flex: 0 0 170px;
}

.capacity-meter {
    width: 110px;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #edf0f2;
}

.capacity-meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.capacity-meter span.over {
    background: var(--danger);
}

.form-panel {
    padding: 20px;
}

.form-panel.compact {
    max-width: 720px;
}

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

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

.form-grid label,
.form-stack label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-weight: 700;
}

.form-grid label:has(textarea),
.form-grid label.checkbox-field {
    grid-column: 1 / -1;
}

.form-control,
.auth-panel input {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    padding: 8px 10px;
    color: var(--text);
    font: inherit;
    width: 100%;
}

textarea.form-control {
    resize: vertical;
}

.checkbox-field {
    flex-direction: row;
    align-items: center;
}

.checkbox-field input {
    width: auto;
}

.form-actions {
    justify-content: flex-end;
    margin-top: 18px;
}

.detail-list {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 10px 14px;
    padding: 18px;
    margin: 0;
}

.detail-list dt {
    color: var(--muted);
    font-weight: 700;
}

.detail-list dd {
    margin: 0;
}

.messages {
    margin-bottom: 16px;
}

.message {
    padding: 12px 14px;
    border-radius: var(--radius);
    background: #e6f4ea;
    color: var(--good);
    border: 1px solid var(--line);
}

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

.auth-layout {
    min-height: calc(100vh - 160px);
    display: grid;
    place-items: center;
}

.auth-panel {
    width: min(420px, 100%);
    padding: 28px;
}

.auth-panel h1 {
    margin: 0 0 18px;
}

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

@media (max-width: 900px) {
    .topbar {
        align-items: flex-start;
        flex-wrap: wrap;
        height: auto;
        padding: 14px 16px;
    }

    .nav {
        order: 3;
        width: 100%;
    }

    .shell {
        width: min(100% - 24px, 1180px);
        margin-top: 20px;
    }

    .page-header,
    .two-column {
        grid-template-columns: 1fr;
    }

    .page-header {
        display: grid;
        align-items: start;
    }

    .metrics,
    .compact-metrics,
    .hour-summary-grid,
    .company-summary-layout,
    .hour-summary-values,
    .summary-band,
    .period-summary-grid,
    .dashboard-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .month-chart {
        grid-template-columns: repeat(6, minmax(36px, 1fr));
        height: 300px;
    }

    .panel {
        overflow-x: auto;
    }

    table {
        min-width: 720px;
    }
}
