:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-muted: #edf2f7;
    --text: #172033;
    --muted: #5e6b7d;
    --line: #d9e0ea;
    --blue: #2364d2;
    --green: #1f8f5f;
    --amber: #c77700;
    --shadow: 0 16px 48px rgba(23, 32, 51, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

a {
    color: inherit;
}

.app-shell-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 72px;
    padding: 14px clamp(20px, 5vw, 64px);
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
    line-height: 1.1;
}

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

.top-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.top-nav a,
.top-nav button {
    padding: 9px 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.top-nav a:hover,
.top-nav a:focus-visible,
.top-nav button:hover,
.top-nav button:focus-visible {
    background: var(--surface-muted);
    color: var(--text);
    outline: none;
}

.top-nav form {
    margin: 0;
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown summary {
    list-style: none;
    padding: 9px 12px;
    border-radius: 7px;
    color: var(--muted);
    font-weight: 600;
    cursor: pointer;
}

.nav-dropdown summary::-webkit-details-marker {
    display: none;
}

.nav-dropdown summary::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
}

.nav-dropdown[open] summary,
.nav-dropdown summary:hover,
.nav-dropdown summary:focus-visible {
    background: var(--surface-muted);
    color: var(--text);
    outline: none;
}

.nav-dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 20;
    display: grid;
    min-width: 180px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.nav-dropdown-menu a {
    display: block;
}

.login-page {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 72px);
    padding: 36px 20px;
}

.login-panel {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(300px, 420px);
    width: min(920px, 100%);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-intro {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 460px;
    padding: clamp(28px, 5vw, 56px);
    background:
        linear-gradient(135deg, rgba(35, 100, 210, 0.16), rgba(31, 143, 95, 0.14)),
        var(--surface-muted);
}

.login-intro h1 {
    font-size: clamp(2.25rem, 4vw, 3.8rem);
}

.login-intro p:not(.eyebrow) {
    max-width: 420px;
    margin: 18px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.login-form {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    padding: clamp(28px, 5vw, 48px);
}

.login-form label {
    color: var(--text);
    font-weight: 700;
}

.login-form input {
    width: 100%;
    min-height: 46px;
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    font: inherit;
}

.login-form input:focus {
    border-color: var(--blue);
    outline: 3px solid rgba(35, 100, 210, 0.14);
}

.login-form button,
.dashboard-card button.card-action {
    border: 0;
    cursor: pointer;
    font: inherit;
}

.login-form button {
    min-height: 46px;
    margin-top: 8px;
    border-radius: 7px;
    background: var(--blue);
    color: #fff;
    font-weight: 800;
}

.login-form button:hover,
.login-form button:focus-visible {
    background: var(--text);
    outline: none;
}

.validation-summary {
    color: #a42323;
    font-weight: 700;
}

.validation-summary ul {
    margin: 0 0 10px;
    padding-left: 18px;
}

.portal-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
    align-items: end;
    gap: 32px;
    padding: clamp(40px, 7vw, 86px) clamp(20px, 5vw, 64px) 32px;
    background:
        linear-gradient(135deg, rgba(35, 100, 210, 0.16), rgba(31, 143, 95, 0.14)),
        var(--surface);
    border-bottom: 1px solid var(--line);
}

.portal-hero-content {
    max-width: 760px;
}

.eyebrow,
.card-label {
    margin: 0 0 10px;
    color: var(--amber);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    max-width: 760px;
    font-size: clamp(2.4rem, 5vw, 4.5rem);
    line-height: 0.98;
}

.hero-copy {
    max-width: 640px;
    margin: 22px 0 0;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1.6;
}

.status-panel {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    align-items: center;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.status-panel strong {
    grid-column: 2;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 6px rgba(31, 143, 95, 0.16);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    padding: 28px clamp(20px, 5vw, 64px) 56px;
}

.dashboard-card {
    display: flex;
    flex-direction: column;
    min-height: 240px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.dashboard-card h2 {
    margin: 0;
    font-size: 1.28rem;
}

.dashboard-card p {
    flex: 1;
    margin: 14px 0 22px;
    color: var(--muted);
    line-height: 1.55;
}

.card-action {
    align-self: flex-start;
    padding: 10px 13px;
    border-radius: 7px;
    background: var(--text);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

.card-action:hover,
.card-action:focus-visible {
    background: var(--blue);
    outline: none;
}

.dashboard-metrics article {
    min-height: 92px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-muted);
}

.dashboard-metrics span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
}

.dashboard-metrics strong {
    display: block;
    font-size: clamp(1.25rem, 2vw, 1.75rem);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.dashboard-metrics {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    padding: 14px clamp(20px, 5vw, 64px) 0;
}

.dashboard-chart-panel {
    margin: 12px clamp(20px, 5vw, 64px) 28px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

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

.dashboard-chart-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.dashboard-chart-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.segmented-control {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 8px;
    background: var(--surface-muted);
}

.segmented-control button {
    min-height: 38px;
    padding: 0 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.segmented-control button.active,
.segmented-control button:hover,
.segmented-control button:focus-visible {
    background: var(--surface);
    color: var(--text);
    outline: none;
}

.dashboard-chart-wrap {
    overflow-x: auto;
}

.dashboard-chart {
    display: block;
    width: 100%;
    min-width: 780px;
    max-height: calc(100vh - 310px);
    height: auto;
}

.chart-grid line {
    stroke: var(--line);
}

.chart-grid text,
.chart-axis text {
    fill: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.chart-legend i {
    width: 11px;
    height: 11px;
    border-radius: 50%;
}

.legend-gross {
    background: var(--blue);
}

.legend-supplier {
    background: var(--green);
}

.legend-site {
    background: var(--amber);
}

.legend-owner {
    background: #7c3aed;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 74px;
    padding: 14px clamp(20px, 5vw, 64px);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.page-header h1 {
    font-size: 1.45rem;
    line-height: 1.2;
}

.page-header p {
    margin: 6px 0 0;
    color: var(--muted);
    font-weight: 700;
}

.secondary-action {
    min-height: 42px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--text);
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.secondary-action:hover,
.secondary-action:focus-visible {
    background: var(--blue);
    outline: none;
}

.secondary-action.active {
    background: var(--blue);
}

.primary-action,
.table-row-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 9px 13px;
    border: 0;
    border-radius: 7px;
    background: var(--blue);
    color: #fff;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.primary-action:hover,
.primary-action:focus-visible,
.table-row-action:hover,
.table-row-action:focus-visible {
    background: var(--text);
    outline: none;
}

.table-row-action {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 0.86rem;
}

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

.icon-action svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-linejoin: round;
    stroke-width: 2;
}

.table-section {
    height: calc(100vh - 146px);
    min-height: 420px;
    padding: 20px clamp(20px, 5vw, 64px) 30px;
}

.report-search-panel {
    padding: 16px clamp(20px, 5vw, 64px);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.report-search-form {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 14px;
}

.report-search-form label {
    display: grid;
    gap: 6px;
    min-width: 180px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 800;
}

.report-search-form input {
    min-height: 42px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    font: inherit;
}

.search-dropdown-field {
    position: relative;
    display: grid;
    gap: 6px;
    min-width: min(340px, 100%);
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 800;
}

.search-dropdown-trigger {
    position: relative;
    min-height: 42px;
    width: 100%;
    padding: 9px 36px 9px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.search-dropdown-trigger::after {
    content: "";
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-30%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--muted);
}

.search-dropdown-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 10;
    width: min(460px, calc(100vw - 40px));
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
}

.search-dropdown-input {
    position: sticky;
    top: 0;
    width: 100%;
    min-height: 40px;
    margin-bottom: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    font: inherit;
}

.search-dropdown-options {
    max-height: 260px;
    overflow-y: auto;
}

.search-dropdown-option {
    display: grid;
    gap: 3px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.search-dropdown-option:hover,
.search-dropdown-option:focus-visible {
    background: rgba(35, 100, 210, 0.08);
    outline: none;
}

.search-dropdown-option span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.validation-message {
    margin-top: 12px;
    padding: 12px 14px;
    border: 1px solid rgba(181, 63, 63, 0.3);
    border-radius: 7px;
    background: rgba(181, 63, 63, 0.08);
    color: #8a2f2f;
    font-weight: 800;
}

.report-toolbar {
    padding: 12px clamp(20px, 5vw, 64px);
    border-bottom: 1px solid var(--line);
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.report-table-section {
    height: calc(100vh - 280px);
}

.portal-table-shell {
    height: 100%;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.portal-table {
    width: 100%;
    min-width: 900px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.92rem;
}

.portal-table th,
.portal-table td {
    position: relative;
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.portal-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--surface-muted);
    color: var(--text);
    font-weight: 800;
    cursor: pointer;
    user-select: none;
}

.portal-table thead .filter-row th {
    top: 42px;
    z-index: 2;
    padding: 7px 8px;
    background: var(--surface);
    cursor: default;
}

.portal-table input {
    width: 100%;
    min-width: 72px;
    padding: 7px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
}

.portal-table tbody tr {
    cursor: pointer;
}

.portal-table tbody tr:hover,
.portal-table tbody tr:focus {
    background: rgba(35, 100, 210, 0.08);
    outline: none;
}

.mgd-report-table {
    min-width: 720px;
}

.mgd-report-table tbody tr {
    cursor: default;
}

.mgd-report-table td:first-child {
    width: 90px;
    text-align: center;
    font-weight: 800;
}

.mgd-report-table td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.mgd-report-table .summary-row td {
    background: var(--surface-muted);
    font-weight: 800;
}

.report-print-title {
    padding: 16px 18px 6px;
    background: var(--surface);
}

.report-print-title h2 {
    margin: 0;
    font-size: 1rem;
}

.report-print-title p {
    margin: 6px 0 0;
    color: var(--muted);
    font-weight: 700;
}

.collections-table td:nth-child(n+5),
.collections-table tfoot td {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.collections-table tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 2;
    border-top: 2px solid var(--line);
    background: var(--surface-muted);
    font-weight: 800;
}

.collections-table tfoot td:first-child {
    text-align: left;
}

.column-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
}

.empty-state {
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-weight: 700;
}

.site-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px clamp(20px, 5vw, 64px);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.site-detail-header h1 {
    margin-top: 4px;
    font-size: clamp(1.8rem, 4vw, 3rem);
}

.site-detail-header p {
    margin: 8px 0 0;
    color: var(--muted);
}

.back-link {
    color: var(--blue);
    font-weight: 800;
    text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible {
    text-decoration: underline;
    outline: none;
}

.site-ref-stack {
    display: grid;
    gap: 8px;
    min-width: 220px;
}

.site-ref-stack span {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 9px 12px;
    background: var(--surface-muted);
    border-radius: 7px;
    color: var(--muted);
}

.site-ref-stack strong {
    color: var(--text);
}

.site-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    padding: 18px clamp(20px, 5vw, 64px);
}

.site-subnav {
    display: flex;
    gap: 6px;
    padding: 10px clamp(20px, 5vw, 64px);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.site-subnav a {
    padding: 9px 13px;
    border-radius: 7px;
    color: var(--muted);
    font-weight: 800;
    text-decoration: none;
}

.site-subnav a.active,
.site-subnav a:hover,
.site-subnav a:focus-visible {
    background: var(--surface-muted);
    color: var(--text);
    outline: none;
}

.info-panel {
    min-height: 190px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.info-panel h2 {
    margin: 0 0 12px;
    font-size: 1.15rem;
}

.info-panel p,
.info-panel address {
    margin: 0 0 10px;
    color: var(--muted);
    font-style: normal;
    line-height: 1.55;
}

.info-panel strong {
    display: inline-block;
    min-width: 80px;
    color: var(--text);
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 4px clamp(20px, 5vw, 64px) 12px;
}

.tab-group {
    display: flex;
    gap: 6px;
    padding: 4px;
    background: var(--surface-muted);
    border-radius: 8px;
}

.tab-group a {
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 800;
    text-decoration: none;
}

.tab-group a.active,
.tab-group a:hover,
.tab-group a:focus-visible {
    background: var(--surface);
    color: var(--text);
    outline: none;
}

.site-machine-section {
    height: calc(100vh - 445px);
    min-height: 360px;
    padding-top: 0;
}

.site-section-table {
    height: calc(100vh - 265px);
    min-height: 440px;
    padding-top: 0;
}

.invoice-table-section {
    height: calc(100vh - 250px);
    min-height: 430px;
    padding-top: 0;
}

.invoice-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 18px clamp(20px, 5vw, 64px);
}

.invoice-detail-table-section {
    height: calc(100vh - 455px);
    min-height: 320px;
    padding-top: 0;
}

.invoice-items-table {
    min-width: 720px;
}

.invoice-items-table tbody tr {
    cursor: default;
}

.invoice-items-table tfoot td {
    font-weight: 800;
    background: var(--surface-muted);
}

.machine-summary-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
    gap: 16px;
    padding: 18px clamp(20px, 5vw, 64px);
}

.machine-info-panel {
    min-height: 0;
}

.machine-info-panel dl {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 8px 14px;
    margin: 0;
}

.machine-info-panel dt {
    color: var(--muted);
    font-weight: 700;
}

.machine-info-panel dd {
    margin: 0;
    color: var(--text);
    overflow-wrap: anywhere;
}

.hopper-panel {
    background: color-mix(in srgb, #7c3aed 8%, var(--surface));
}

.machine-section-table {
    height: calc(100vh - 430px);
    min-height: 360px;
    padding-top: 0;
}

.table-toolbar h2 {
    margin: 0;
    font-size: 1.2rem;
}

.toolbar-note {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.metric-pill {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text);
    font-weight: 800;
    white-space: nowrap;
}

.collection-detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    padding: 18px clamp(20px, 5vw, 64px);
}

.collection-panel {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.collection-panel h2 {
    margin: 0 0 14px;
    font-size: 1.08rem;
}

.collection-panel dl {
    display: grid;
    grid-template-columns: minmax(90px, 1fr) minmax(0, 1.1fr);
    gap: 8px 12px;
    margin: 0;
}

.collection-panel dt {
    color: var(--muted);
    font-weight: 700;
}

.collection-panel dd {
    margin: 0;
    color: var(--text);
    overflow-wrap: anywhere;
}

.collection-cash dd,
.collection-deductions dd,
.collection-summary dd {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.collection-info {
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.collection-cash {
    background: color-mix(in srgb, #2563eb 7%, var(--surface));
}

.collection-deductions {
    background: color-mix(in srgb, #dc2626 6%, var(--surface));
}

.collection-summary {
    background: color-mix(in srgb, #16a34a 7%, var(--surface));
}

.detail-note {
    margin: 0 clamp(20px, 5vw, 64px) 24px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: var(--surface-muted);
}

.service-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    padding: 18px clamp(20px, 5vw, 64px);
}

.service-panel {
    min-height: 420px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.service-panel h2 {
    margin: 0 0 16px;
    font-size: 1.2rem;
}

.service-call {
    padding: 14px 0;
    border-top: 1px solid var(--line);
}

.service-call:first-of-type {
    border-top: 0;
}

.service-call span {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.service-call h3 {
    margin: 5px 0 8px;
    font-size: 1rem;
}

.service-call p {
    margin: 0 0 8px;
    color: var(--muted);
    line-height: 1.45;
}

.service-call-layout {
    display: grid;
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
    gap: 18px;
    padding: 18px clamp(20px, 5vw, 64px);
}

.service-call-summary {
    min-height: 0;
}

.service-call-form-panel,
.success-panel {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

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

.portal-form label {
    display: grid;
    gap: 8px;
    color: var(--text);
    font-weight: 800;
}

.portal-form textarea {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    font: inherit;
    font-weight: 500;
}

.portal-form textarea:focus {
    border-color: var(--blue);
    outline: 3px solid rgba(35, 100, 210, 0.14);
}

.portal-form span.field-validation-error,
.portal-form label > span {
    color: #a42323;
    font-size: 0.9rem;
}

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

.success-panel h2 {
    margin: 0 0 10px;
    font-size: 1.2rem;
}

.success-panel p {
    margin: 0 0 16px;
    color: var(--muted);
}

.admin-settings-layout {
    padding: 18px clamp(20px, 5vw, 64px);
}

.admin-settings-panel {
    max-width: 760px;
}

.settings-success {
    margin-bottom: 16px;
    padding: 11px 12px;
    border: 1px solid rgba(31, 143, 95, 0.28);
    border-radius: 7px;
    background: rgba(31, 143, 95, 0.1);
    color: var(--green);
    font-weight: 800;
}

.settings-list {
    display: grid;
    gap: 12px;
}

.settings-text-field {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-weight: 800;
}

.settings-text-field input {
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    font: inherit;
    font-weight: 600;
}

.settings-text-field input:focus {
    border-color: var(--blue);
    outline: 3px solid rgba(35, 100, 210, 0.14);
}

.settings-text-field span.field-validation-error {
    color: #a42323;
    font-size: 0.9rem;
}

.toggle-field {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.toggle-field input {
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
    accent-color: var(--blue);
}

.toggle-field strong,
.toggle-field small {
    display: block;
}

.toggle-field small {
    margin-top: 3px;
    color: var(--muted);
    font-weight: 600;
    line-height: 1.4;
}

.settings-file-note {
    padding: 12px 14px;
    border-radius: 7px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

@media (max-width: 860px) {
    .app-shell-header,
    .portal-hero {
        align-items: flex-start;
    }

    .app-shell-header,
    .portal-hero,
    .dashboard-grid,
    .login-panel {
        grid-template-columns: 1fr;
    }

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

    .login-intro {
        min-height: 280px;
    }

    .app-shell-header {
        flex-direction: column;
    }

    .top-nav {
        width: 100%;
    }

    .nav-dropdown-menu {
        left: 0;
        right: auto;
    }

    .dashboard-grid {
        display: grid;
    }

    .dashboard-chart-header {
        flex-direction: column;
    }

    .page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .table-section {
        height: calc(100vh - 240px);
        min-height: 440px;
    }

    .site-detail-header,
    .table-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .site-ref-stack {
        min-width: 0;
    }

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

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

    .invoice-detail-grid {
        grid-template-columns: 1fr;
    }

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

    .site-subnav {
        overflow-x: auto;
    }

    .site-machine-section {
        height: 56vh;
        min-height: 420px;
    }

    .site-section-table {
        height: 60vh;
    }

    .invoice-table-section,
    .invoice-detail-table-section {
        height: 58vh;
    }

    .machine-section-table {
        height: 56vh;
    }

    .report-search-form {
        align-items: stretch;
    }

    .report-search-form label {
        flex: 1 1 220px;
    }

    .search-dropdown-field {
        flex: 1 1 260px;
    }

    .report-table-section {
        height: calc(100vh - 360px);
        min-height: 360px;
    }

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

    .service-call-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .portal-hero,
    .dashboard-metrics,
    .dashboard-grid,
    .page-header,
    .report-search-panel,
    .table-section,
    .site-detail-header,
    .site-summary-grid,
    .machine-summary-grid,
    .invoice-detail-grid,
    .table-toolbar {
        padding-left: 16px;
        padding-right: 16px;
    }

    .dashboard-chart-panel {
        margin-left: 16px;
        margin-right: 16px;
        padding: 16px;
    }

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

    h1 {
        font-size: 2.35rem;
    }

    .top-nav a {
        padding-left: 9px;
        padding-right: 9px;
    }

    .secondary-action {
        width: 100%;
    }

    .primary-action {
        width: 100%;
    }

    .toolbar-actions {
        width: 100%;
    }

    .tab-group {
        width: 100%;
    }

    .tab-group a {
        flex: 1;
        text-align: center;
    }

    .collection-detail-grid {
        grid-template-columns: 1fr;
        padding-left: 16px;
        padding-right: 16px;
    }

    .detail-note {
        margin-left: 16px;
        margin-right: 16px;
    }
}

@media print {
    .app-shell-header,
    .report-header,
    .report-search-panel,
    .report-toolbar,
    .filter-row,
    .column-resizer {
        display: none !important;
    }

    .table-section,
    .report-table-section,
    .portal-table-shell {
        height: auto;
        min-height: 0;
        overflow: visible;
        padding: 0;
        border: 0;
    }

    .portal-table {
        min-width: 0;
    }
}
