body {
    margin: 0;
    font-family: sans-serif;
    background: #f4f6f8;
    color: #1f2933;
    line-height: 1.5;
}

a {
    color: inherit;
}

.site-header {
    color: #fff;
    padding: 20px 0;
}

.site-header a {
    color: #fff;
    text-decoration: none;
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 24px;
}

.site-brand {
    flex: 1 1 auto;
    min-width: 0;
}

.site-brand h1 {
    margin: 0;
    font-size: 1.5rem;
}

.site-brand a {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.site-logo {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
}

.site-header-panel {
    display: grid;
    flex: 0 0 auto;
    align-items: end;
    justify-items: end;
    gap: 8px;
    text-align: right;
}

.site-header-status,
.site-header-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.site-header-nav a {
    font-weight: 600;
}

.header-link-button {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

.header-link-button:hover,
.header-link-button:focus {
    text-decoration: underline;
}

.impersonation-badge {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 999px;
    font-size: 0.85rem;
}

.container {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
}

.page-head,
.actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 24px 0 16px;
}

.card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
    margin: 24px 0;
}

.narrow {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

form {
    display: grid;
    gap: 12px;
}

label {
    display: grid;
    gap: 6px;
}

input,
select,
textarea,
button {
    font: inherit;
    padding: 10px 12px;
}

input,
select,
textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #bcccdc;
    border-radius: 8px;
    background: #fff;
    color: #102a43;
}

textarea {
    resize: vertical;
}

button,
.button-link {
    display: inline-block;
    font: inherit;
    padding: 10px 12px;
    color: #fff;
    border: 0;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.button-link:hover,
button:hover {
    opacity: 0.92;
}

.button-link:active,
button:active {
    transform: translateY(1px);
}

.button-link:disabled,
button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.inline-form {
    display: inline-block;
    margin-right: 8px;
}

.inline-form button {
    width: auto;
}

.card h2,
.card h3 {
    margin-top: 0;
}

.intro-text {
    color: #486581;
}

.panel-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-top: 20px;
}

.info-panel,
.metric-card {
    padding: 18px;
    border: 1px solid #d9e2ec;
    border-radius: 12px;
    background: #f8fbfd;
}

.info-panel strong {
    display: block;
    margin-bottom: 6px;
    color: #102a43;
}

.line-usage-panel {
    gap: 12px;
    display: grid;
}

.line-usage-panel h3 {
    margin-bottom: 0;
}

.line-usage-caption {
    margin: 0;
    color: #486581;
    font-size: 0.9rem;
}

.line-usage-list {
    display: grid;
    gap: 10px;
}

.line-usage-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #d9e2ec;
}

.line-usage-label {
    font-weight: 800;
    color: #102a43;
    flex: 0 0 auto;
}

.line-usage-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #102a43;
    text-align: right;
}

.line-usage-note {
    margin: 0;
    color: #7b8794;
    font-size: 0.8rem;
    line-height: 1.45;
}

.metric-card {
    gap: 6px;
    display: grid;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
}

.metric-card strong {
    font-size: 1.6rem;
    color: #102a43;
}

.section-head {
    display: grid;
    gap: 6px;
    margin: 24px 0 12px;
}

.section-head h3,
.section-head p {
    margin: 0;
}

.section-head p {
    color: #486581;
}

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

.detail-row {
    display: grid;
    gap: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e4ecf3;
}

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

.detail-label {
    font-size: 0.88rem;
    font-weight: 700;
    color: #486581;
}

.detail-value {
    color: #102a43;
    word-break: break-word;
}

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

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

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

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-label input {
    width: auto;
}

.muted-text {
    margin: 0;
    color: #6b7c93;
    font-size: 0.92rem;
}

.form-error {
    margin: 0;
    padding: 10px 12px;
    border: 1px solid #f4b6c2;
    border-radius: 8px;
    background: #fff1f4;
    color: #b42318;
    font-size: 0.92rem;
}

.error-summary {
    margin-bottom: 20px;
    padding: 14px 16px;
    border: 1px solid #f4b6c2;
    border-radius: 10px;
    background: #fff1f4;
    color: #b42318;
}

.error-summary strong {
    display: block;
    margin-bottom: 8px;
}

.error-summary ul {
    margin: 0;
    padding-left: 20px;
}

.error-summary li + li {
    margin-top: 6px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.centered-action {
    display: flex;
    justify-content: center;
    margin-top: 28px;
}

.button-link-large {
    min-width: 180px;
    padding: 14px 20px;
    text-align: center;
    font-size: 1rem;
}

.compact-action {
    margin-top: 20px;
}

.compact-button {
    min-width: 220px;
    width: auto;
}

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

.pagination-bar p {
    margin: 0;
    color: #486581;
}

.pagination-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination-links-bottom {
    margin-top: 16px;
    justify-content: flex-end;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #ffffff;
    color: #0f4c81;
    text-decoration: none;
    font-weight: 700;
}

.pagination-link.is-current {
    background: #0f4c81;
    border-color: #0f4c81;
    color: #ffffff;
}

.hero-actions .inline-form {
    margin: 0;
}

.cycle-chart-section {
    margin-top: 28px;
}

.chart-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.chart-card {
    border: 1px solid #d9e2ec;
    border-radius: 16px;
    padding: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
}

.chart-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.chart-card-head h4 {
    margin: 0;
    color: #102a43;
}

.chart-average {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
    margin-bottom: 12px;
    text-align: center;
}

.chart-average-label,
.chart-average-unit {
    font-size: 0.88rem;
    color: #486581;
}

.chart-average-value {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #334e68;
    font-weight: 700;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 999px;
}

.google-chart {
    width: 100%;
    min-height: 300px;
}

.qr-card {
    display: grid;
    justify-items: start;
    gap: 12px;
    margin: 20px 0;
}

.completion-highlight {
    display: grid;
    gap: 16px;
    margin: 24px 0;
}

.completion-primary {
    gap: 8px;
    padding: 20px 22px;
    border: 1px solid #d9e2ec;
    border-radius: 16px;
    background: linear-gradient(180deg, #f8fbfd 0%, #ffffff 100%);
}

.completion-primary-value {
    font-size: 2rem;
    font-weight: 800;
    color: #0f4c81;
}

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

.completion-metric {
    border: 1px solid #d9e2ec;
    border-radius: 16px;
    padding: 18px 20px;
}

.completion-qr-card {
    justify-items: center;
}

.completion-qr-image {
    width: 180px;
}

.qr-image {
    width: 240px;
    max-width: 100%;
    height: auto;
    padding: 12px;
    background: #fff;
    border: 1px solid #d9e2ec;
    border-radius: 12px;
}

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

th,
td {
    padding: 10px;
    border-bottom: 1px solid #d9e2ec;
    text-align: left;
    vertical-align: top;
}

table thead th {
    background: #f7fafc;
    color: #486581;
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
}

table tbody tr:hover {
    background: #f9fbfc;
}

.table-wrap {
    overflow-x: auto;
}

.admin-contractors-table {
    min-width: 1020px;
}

.line-flag-col {
    width: 92px;
}

.line-summary-col {
    width: 220px;
}

.admin-public-queues-table {
    min-width: 900px;
}

.contractor-queue-table {
    min-width: 980px;
}

.contractor-name-cell {
    font-weight: 700;
}

.slug-cell {
    font-family: monospace;
    color: #243b53;
}

.contact-cell {
    min-width: 180px;
}

.contact-cell span {
    display: block;
    line-height: 1.6;
}

.minutes-cell {
    white-space: nowrap;
}

.actions-cell {
    min-width: 220px;
}

.line-flag-cell {
    min-width: 92px;
    white-space: nowrap;
}

.line-summary-cell {
    min-width: 190px;
    white-space: nowrap;
}

.line-summary-content {
    display: grid;
    gap: 4px;
}

.line-summary-value {
    display: inline-block;
    color: #102a43;
    font-weight: 700;
}

.line-summary-note {
    font-size: 0.78rem;
    line-height: 1.4;
    word-break: break-word;
    white-space: normal;
}

.cell-placeholder {
    display: block;
    min-height: 1.4em;
}

.actions-cell .button-link,
.actions-cell .inline-form {
    margin: 0 8px 8px 0;
}

.customer-info-cell {
    min-width: 220px;
}

.stacked-cell {
    display: grid;
    gap: 4px;
}

.sub-info {
    font-size: 0.88rem;
    color: #6b7c93;
}

.sub-link {
    font-size: 0.84rem;
    color: #486581;
    text-decoration: underline;
    word-break: break-all;
}

.secondary-action {
    display: flex;
    justify-content: center;
    margin-top: 14px;
}

.sub-link-button {
    font-size: 0.88rem;
    color: #486581;
    text-decoration: underline;
}

.text-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: #0f4c81;
    text-decoration: underline;
    cursor: pointer;
}

.reason-modal {
    width: min(520px, calc(100% - 32px));
    border: 0;
    border-radius: 14px;
    padding: 0;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
}

.reason-modal::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.reason-modal-content {
    padding: 24px;
}

.reason-modal-content h3 {
    margin-top: 0;
}

.public-error-modal .reason-modal-content {
    display: grid;
    gap: 16px;
}

.error-list {
    margin: 0;
    padding-left: 20px;
    color: #9b1c1c;
}

.error-list li + li {
    margin-top: 8px;
}

.url-cell a {
    color: #0f4c81;
    text-decoration: underline;
    word-break: break-all;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.2;
}

.status-active {
    background: #d9f2e3;
    color: #166534;
}

.status-inactive {
    background: #fde8e8;
    color: #9b1c1c;
}

.status-waiting {
    background: #e1effe;
    color: #1e429f;
}

.status-completed {
    background: #e6fffa;
    color: #0f766e;
}

.status-skipped {
    background: #fef3c7;
    color: #92400e;
}

.status-cancelled {
    background: #fde8e8;
    color: #b42318;
}

@media (max-width: 720px) {
    .site-header-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .site-header-panel {
        width: 100%;
        justify-items: start;
        text-align: left;
    }

    .site-header-status,
    .site-header-nav {
        justify-content: flex-start;
    }

    .page-head,
    .actions,
    .hero-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .card {
        padding: 18px;
    }

    .hero-actions .button-link,
    .hero-actions button,
    .actions .button-link,
    .actions button {
        width: 100%;
        box-sizing: border-box;
        text-align: center;
    }
}
