/* Global layout */

:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #111827;
    --muted: #4b5563;
    --border: #e5e7eb;
    --brand: #2563eb;
    --brand-hover: #1d4ed8;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 10px 20px rgba(15, 23, 42, 0.05);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
}

h1 {
    font-size: 2rem;
    letter-spacing: -0.01em;
    line-height: 1.2;
    margin: 0 0 0.75rem;
}

h3 {
    font-size: 1.1rem;
    margin: 0 0 0.6rem;
}

.card h1 {
    margin-top: 0;
}

.card h3 {
    margin-top: 0;
}

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

a:hover {
    text-decoration: underline;
}

.filter-current {
    margin: 0.25rem 0 0.85rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 0.35rem 0 0.75rem;
}

.filter-row-label {
    min-width: 68px;
    font-weight: 600;
    color: #374151;
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.btn.btn-filter {
    padding: 0.4rem 0.95rem;
    border-radius: 999px;
    font-size: 0.8rem;
    line-height: 1.2;
    user-select: none;
}

.layout-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.dashboard-no-scroll {
    overflow: hidden;
}

.dashboard-no-scroll .layout-shell {
    height: 100vh;
}

.dashboard-no-scroll .site-main {
    overflow: hidden;
}

.dashboard-no-scroll .container {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.dashboard-layout {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    height: 100%;
    min-height: 0;
}

.calendar-no-scroll {
    overflow: hidden;
}

.calendar-no-scroll .layout-shell {
    height: 100vh;
}

.calendar-no-scroll .site-main {
    overflow: hidden;
}

.calendar-no-scroll .container {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.calendar-layout {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
}

.calendar-layout .card {
    margin-bottom: 0;
}

.calendar-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.calendar-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.calendar-filters .filter-row {
    flex: 1 1 360px;
    margin: 0;
}

.dashboard-no-scroll .dashboard-top {
    flex: 0 0 auto;
}

.dashboard-no-scroll .orders-table-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.dashboard-no-scroll .orders-table-card .table-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

.dashboard-top {
    display: grid;
    grid-template-columns: 0.8fr 5.4fr;
    gap: 0.70rem;
    align-items: stretch;
    margin-bottom: 0;
}

.dashboard-top .card {
    margin-bottom: 0;
}

.dashboard-side {
    display: flex;
    flex-direction: column;
    gap: 0.70rem;
}

.dashboard-side .card {
    margin-bottom: 0;
}

.orders-summary-card {
    flex: 1 1 auto;
}

.new-order-btn {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.1rem 1.2rem;
    text-decoration: none;
    background: #2563eb;
    color: #ffffff;
    border-radius: 12px;
    border: 1px solid #1d4ed8;
    font-weight: 600;
    min-height: 120px;
    justify-content: center;
    box-shadow: 0 10px 16px rgba(37, 99, 235, 0.18);
    transition: transform 120ms ease, box-shadow 120ms ease;
    text-align: center;
}

.new-order-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 22px rgba(37, 99, 235, 0.24);
    color: #ffffff;
}

.new-order-title {
    font-size: 1.1rem;
    letter-spacing: 0.01em;
}

.new-order-subtitle {
    font-size: 0.85rem;
    opacity: 0.85;
    font-weight: 500;
}

.tracking-layout {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.tracking-layout .card {
    margin-bottom: 0;
}

.tracking-top {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 0.70rem;
    align-items: stretch;
}

.tracking-top .card {
    margin-bottom: 0;
}

@media (max-width: 980px) {
    .dashboard-top {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    .tracking-top {
        grid-template-columns: 1fr;
    }
}

.filters-card {
    display: flex;
    flex-direction: column;
}

.filters-scroll {
    overflow: auto;
    min-height: 0;
    max-height: 360px;
    padding-right: 0.25rem;
    scrollbar-gutter: stable;
    padding-left: 16px;
}

.filters-scroll--dashboard {
    max-height: none;
    overflow: visible;
    padding-left: 0;
    padding-right: 0;
}

.filter-form {
    display: grid;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.filter-form .filter-row-label {
    display: grid;
    gap: 0.35rem;
}

.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.dashboard-no-scroll .filters-scroll {
    max-height: min(360px, 35vh);
}

.filters-scroll > :first-child {
    margin-top: 0;
}

.filters-scroll > :last-child {
    margin-bottom: 0;
}

@media (max-width: 980px) {
    .filters-scroll {
        max-height: none;
    }

    .dashboard-no-scroll .filters-scroll {
        max-height: none;
    }
}

/* Header */

.site-header {
    background: #036aaa;
    color: #f9fafb;
    padding: 0.7rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
}

.site-header-inner {
    max-width: 1520px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #f9fafb;
    text-decoration: none;
    border-radius: 8px;
    padding: 0.1rem 0.35rem;
}

.site-brand:hover {
    text-decoration: none;
    background: rgba(255, 255, 255, 0.08);
}

.site-logo {
    display: block;
    height: 70px;
    width: auto;
}

.btn.nav-toggle-btn {
    display: none;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.9rem;
    align-items: center;
}

.site-nav a {
    color: #e5e7eb;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    font-size: 1.2rem;
}

.site-nav a:visited {
    color: #ffffff;
}

.site-nav a:hover {
    text-decoration: none;
    color: #ffffff;
    background: rgb(26, 143, 227, 0.5);
}

.site-nav span {
    color: #ffffff;
    font-size: 1.2rem; 
    font-weight: bold;
}

/* Auth pages */
.auth-page .site-nav,
.auth-page .nav-toggle-btn {
    display: none;
}

/* Main area */

.site-main {
    flex: 1;
    padding: 0.85rem 0.85rem 1.5rem;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
}

/* Cards and panels */

.card {
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 0.85rem 1rem;
    margin-bottom: 0.65rem;
    box-shadow: var(--shadow);
}

.card p {
    margin: 0.5rem 0;
}

.card p:last-child {
    margin-bottom: 0;
}

/* Order detail layout */
.order-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.order-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.order-detail-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    align-items: start;
}

.order-detail-column h3 {
    margin: 0 0 0.5rem;
}

.order-detail-column h4 {
    margin: 0.75rem 0 0.5rem;
}

.order-detail-table {
    margin-bottom: 0.75rem;
}

.order-detail-column .order-detail-table:last-of-type {
    margin-bottom: 0;
}

.table-section-row th {
    background: #f9fafb;
    font-weight: 700;
    text-transform: none;
    color: #111827;
}

/* Buttons */

.btn {
    display: inline-block;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    background: #ffffff;
    color: #111827;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease;
}

.btn:hover {
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}

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

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

.btn-secondary {
    background: #ffffff;
    border-color: #d1d5db;
    color: #374151;
}

.btn-secondary:hover {
    background: #f3f4f6;
}

.btn-id {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    padding: 0.2rem 0;
    font-variant-numeric: tabular-nums;
}

.btn-danger {
    background: #b91c1c;
    border-color: #991b1b;
    color: #ffffff;
}

.btn-danger:hover {
    background: #8a2121;
}

.btn-success {
    background: #16a34a;
    border-color: #15803d;
    color: #ffffff;
}

.btn-success:hover {
    background: #15803d;
}

/* Form controls */

input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    max-width: 100%;
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(37, 99, 235, 0.35);
    outline-offset: 1px;
    border-color: rgba(37, 99, 235, 0.65);
}

.form-row label {
    font-weight: 600;
    display: inline-block;
    margin-bottom: 0.25rem;
}

/* Tables */

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    -webkit-overflow-scrolling: touch;
}

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

th,
td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

th {
    background: #f9fafb;
    font-weight: 600;
}

tbody tr:hover {
    background: rgba(37, 99, 235, 0.04);
}

tr.is-overdue {
    background: #ffcccc;
}

.orders-table-card .table-wrapper {
    overflow: auto;
    max-height: min(70vh, 720px);
}

.orders-table-card thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.orders-table-card {
    padding: 0.65rem;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.summary-table th,
.summary-table td {
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
}

.summary-table th {
    background: transparent;
    font-weight: 700;
    color: #111827;
}

.summary-table td {
    text-align: right;
    color: var(--muted);
    white-space: nowrap;
}

.summary-table tbody tr:last-child th,
.summary-table tbody tr:last-child td {
    border-bottom: 0;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    justify-content: flex-end;
}

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

.orders-table-card th.actions-cell,
.orders-table-card td.actions-cell {
    text-align: right;
}

/* Status pill */

.status-pill {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-pill + .status-pill {
    margin-left: 0.25rem;
}

.status-NEW {
    background: #e0f2fe;
    color: #1d4ed8;
}

.status-AWAITING_RESOURCE {
    background: #e5e7eb;
    color: #374151;
}

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

.status-DATES_CONFIRMED {
    background: #dcfce7;
    color: #166534;
}

.status-PREINSTALL_IN_PROGRESS {
    background: #e0f2fe;
    color: #075985;
}

.status-SITE_SURVEY_IN_PROGRESS {
    background: #fefce8;
    color: #a16207;
}

.status-SITE_SURVEY_COMPLETED {
    background: #ecfccb;
    color: #3f6212;
}

.status-READY_FOR_CONFIG {
    background: #fff7ed;
    color: #9a3412;
}

.status-CONFIG_IN_PROGRESS {
    background: #f0f9ff;
    color: #0369a1;
}

.status-CONFIG_COMPLETED {
    background: #ecfdf3;
    color: #047857;
}

.status-READY_FOR_INSTALL {
    background: #fef9c3;
    color: #854d0e;
}

.status-INSTALL_IN_PROGRESS {
    background: #ecfeff;
    color: #155e75;
}

.status-INSTALLED {
    background: #e0f2f1;
    color: #047857;
}

.status-ON_HOLD {
    background: #e0e7ff;
    color: #3730a3;
}

.status-CANCELLED {
    background: #fee2e2;
    color: #991b1b;
}

.status-CLOSED {
    background: #e5e7eb;
    color: #374151;
}

.status-router-shipped {
    background: #ecfdf3;
    color: #047857;
}

.status-router-not-shipped {
    background: #f3f4f6;
    color: #6b7280;
}

.status-router-not-received {
    background: #fef3c7;
    color: #92400e;
}

.status-router-received {
    background: #dcfce7;
    color: #166534;
}

/* Alerts */
.alert-success {
    background: #dcfce7;
    color: #166534;
}

/* Availability pills */
.status-pill.avail-pill {
    font-weight: 600;
}

.status-pill.avail-pill.avail-AVAILABLE {
    background: #dcfce7;
    color: #166534;
}

.status-pill.avail-pill.avail-WORKING {
    background: #e0f2fe;
    color: #075985;
}

.status-pill.avail-pill.avail-NOT_AVAILABLE {
    background: #fef2f2;
    color: #b91c1c;
}

.status-pill.avail-pill.avail-HOLIDAY {
    background: #fef3c7;
    color: #92400e;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .25rem .6rem;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
    line-height: 1;
    border: 1px solid #e5e7eb;
}

.avail-pill {
    white-space: nowrap;
}

/* Availability pages */

.availability-pattern-form {
    display: flex;
    gap: 0.9rem;
    flex-direction: column;
    align-items: stretch;
}

.availability-pattern-fields p {
    margin: 0;
}

.availability-pattern-fields {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: start;
    width: 100%;
}

.pattern-section {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.75rem;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.pattern-section-title {
    font-weight: 600;
    color: #374151;
}

.pattern-toggle-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.range-days-section {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.75rem;
    background: #f9fafb;
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.range-days-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.range-days-all {
    padding: 0.25rem 0.65rem;
    font-size: 0.8rem;
    border-radius: 999px;
}

.pattern-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.pattern-toggle input {
    position: absolute;
    opacity: 0;
}

.pattern-toggle span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    font-size: 0.85rem;
    font-weight: 600;
    color: #111827;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.pattern-toggle input:checked + span {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.pattern-toggle input:focus + span,
.pattern-toggle input:focus-visible + span {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.pattern-days .pattern-toggle span {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.availability-form-grid {
    display: grid;
    gap: 0.5rem 1rem;
    grid-template-columns: repeat(6, minmax(140px, 1fr));
    align-items: start;
}

.onboarding-grid {
    display: grid;
    gap: 0.75rem 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: start;
}

.form-help {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

.my-calendar-wrapper {
    margin-top: 0.75rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.my-availability-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.5rem;
    min-width: 720px;
}

.my-calendar-head {
    font-weight: 600;
    font-size: 0.85rem;
    color: #6b7280;
    padding: 0.2rem 0.2rem;
}

.my-calendar-cell {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.5rem;
    background: #ffffff;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    text-decoration: none;
    color: inherit;
}

.my-calendar-cell:hover {
    text-decoration: none;
    background: #f8fafc;
    border-color: #cbd5f5;
}

.my-calendar-muted {
    opacity: 0.45;
}

.my-calendar-selected {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}

.my-calendar-daynum {
    font-size: 0.85rem;
    font-weight: 600;
}

.my-calendar-meta {
    font-size: 0.72rem;
    color: #6b7280;
    display: grid;
    gap: 0.2rem;
}

.avail-PENDING {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.availability-pending {
    margin: 0 0 0.75rem;
    color: #92400e;
    font-weight: 600;
}

.availability-requests-table th.actions-cell,
.availability-requests-table td.actions-cell {
    text-align: right;
}

.request-actions-form {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    flex-wrap: nowrap;
}

.request-actions-buttons {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
}

.request-note-input {
    width: 160px;
    padding: 0.25rem 0.45rem;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 0.8rem;
}

.availability-days {
    display: grid;
    gap: 0.5rem;
}

.availability-day-row {
    display: grid;
    grid-template-columns: 140px 180px 1fr;
    gap: 0.5rem;
    align-items: center;
}

.availability-field-label {
    display: none;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.availability-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.availability-calendar-nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.availability-calendar-controls {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.availability-calendar-engineer {
    min-width: 240px;
}

.calendar-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.calendar-no-scroll .calendar-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: hidden;
}

.calendar-head-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.5rem;
    grid-auto-rows: 170px;
}

.calendar-no-scroll .calendar-grid {
    flex: 1 1 auto;
    min-height: 0;
    grid-auto-rows: minmax(0, 1fr);
}

.calendar-head {
    font-weight: 600;
    font-size: 0.9rem;
    color: #6b7280;
    padding: 0.25rem 0.25rem;
}

.calendar-cell {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.6rem;
    background: #fff;
    height: 100%;
    overflow: hidden;
}

.calendar-cell-link {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    color: inherit;
    text-decoration: none;
}

.calendar-cell-link:hover {
    text-decoration: none;
    border-color: #cbd5f5;
    background: #f8fafc;
}

.calendar-muted { opacity: 0.45; }

.calendar-daynum {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.calendar-cell .avail-pill {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-availability-count {
    display: flex;
    align-items: flex-start;
    flex: 0 0 auto;
}

.calendar-availability-empty .status-pill {
    background: #f3f4f6;
    color: #6b7280;
    border-color: #e5e7eb;
}

.availability-meta {
    margin-top: 0.35rem;
    display: grid;
    gap: 0.2rem;
    font-size: 0.75rem;
    color: #6b7280;
}

.availability-orders {
    font-size: 0.72rem;
    color: #4b5563;
}

.availability-orders a {
    color: inherit;
    text-decoration: underline;
}

.avail-UNSET {
    background: #f3f4f6;
    color: #6b7280;
}

.avail-WORKING {
    background: #e0f2fe;
    color: #075985;
    border-color: #bae6fd;
}

.avail-AVAILABLE {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.avail-NOT_AVAILABLE {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

.avail-HOLIDAY {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* Availability compact view */

.availability-compact-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.availability-compact-subtitle {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.availability-compact-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin: 0.65rem 0 0.75rem;
}

.availability-control {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.availability-control label,
.availability-control-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #4b5563;
}

.availability-search input {
    min-width: 220px;
}

.availability-toggle-group {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.availability-toggle-group .btn {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.availability-toggle-group .btn.is-active {
    background: var(--brand);
    border-color: var(--brand);
    color: #ffffff;
}

.availability-checkbox {
    flex-direction: row;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    color: #374151;
}

.availability-compact-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 0.75rem;
    align-items: start;
}

.availability-compact-table {
    font-size: 0.8rem;
    min-width: 980px;
}

.availability-compact-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
}

.availability-compact-table th,
.availability-compact-table td {
    padding: 0.35rem 0.45rem;
    vertical-align: top;
}

.availability-compact-engineer {
    min-width: 160px;
}

.engineer-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.engineer-meta {
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.availability-row-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: #9ca3af;
    display: inline-block;
    box-shadow: 0 0 0 2px #ffffff;
}

.availability-compact-row.row-available .availability-row-dot {
    background: #16a34a;
}

.availability-compact-row.row-unavailable .availability-row-dot {
    background: #dc2626;
}

.availability-day-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.availability-day-label {
    font-weight: 600;
}

.availability-day-totals {
    display: grid;
    gap: 0.15rem;
    font-size: 0.7rem;
    color: #6b7280;
}

.day-total {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.day-total-label {
    font-weight: 700;
    color: #374151;
}

.availability-compact-cell {
    cursor: pointer;
    transition: box-shadow 120ms ease, transform 120ms ease;
}

.availability-compact-cell:hover {
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.availability-compact-cell.is-selected {
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.55);
}

.availability-compact-cell.is-blocked {
    opacity: 1;
}

.availability-compact-cell.cell-status-available {
    background: #ecfdf5;
}

.availability-compact-cell.cell-status-partially-booked {
    background: #fffbeb;
}

.availability-compact-cell.cell-status-fully-booked {
    background: #fef2f2;
}

.availability-compact-cell.cell-status-unavailable {
    background: #f3f4f6;
}

.availability-compact-cell.cell-status-unavailable .availability-cell-content {
    align-items: center;
    justify-content: center;
}

.availability-unavailable-label {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    border: 1px solid #fecaca;
    background: #fee2e2;
    color: #b91c1c;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.availability-compact-cell.cell-status-unavailable .availability-unavailable-label {
    display: inline-flex;
}

.availability-compact-cell.cell-status-unavailable .availability-indicators,
.availability-compact-cell.cell-status-unavailable .availability-cell-actions {
    display: none;
}

.availability-full-label {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    border: 1px solid #f59e0b;
    background: #fefce8;
    color: #b45309;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.availability-compact-cell[data-fully-booked]:not([data-fully-booked=""]) .availability-full-label {
    display: inline-flex;
}

.availability-compact-cell[data-fully-booked]:not([data-fully-booked=""]) .availability-indicators {
    display: none;
}

.availability-cell-content {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 56px;
}

.availability-indicators {
    display: grid;
    gap: 0.2rem;
}

.availability-indicator {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    color: #6b7280;
}

.indicator-label {
    width: 12px;
    font-size: 0.65rem;
    font-weight: 700;
    text-align: center;
    color: #374151;
}

.indicator-bar {
    position: relative;
    width: 40px;
    height: 6px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.indicator-fill {
    position: absolute;
    inset: 0;
    width: var(--fill, 0%);
    background: #9ca3af;
}

.indicator-value {
    font-variant-numeric: tabular-nums;
}

.availability-indicator.is-available .indicator-fill {
    background: #16a34a;
}

.availability-indicator.is-available .indicator-bar {
    background: #dcfce7;
}

.availability-indicator.is-partially-booked .indicator-fill {
    background: #f59e0b;
}

.availability-indicator.is-partially-booked .indicator-bar {
    background: #fef3c7;
}

.availability-indicator.is-fully-booked .indicator-fill {
    background: #dc2626;
}

.availability-indicator.is-fully-booked .indicator-bar {
    background: #fee2e2;
}

.availability-indicator.is-unavailable .indicator-fill {
    background: #9ca3af;
}

.availability-indicator.is-unavailable .indicator-bar {
    background: #f3f4f6;
}

.availability-indicator.is-unavailable .indicator-value {
    color: #9ca3af;
}

.availability-compact-table[data-emphasis="survey"] .availability-indicator[data-type="install"],
.availability-compact-table[data-emphasis="install"] .availability-indicator[data-type="survey"] {
    opacity: 0.35;
}

.availability-cell-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.bookings-popover-wrap {
    position: relative;
    display: inline-flex;
}

.bookings-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    cursor: pointer;
}

.bookings-trigger:hover {
    background: #f3f4f6;
}

.bookings-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: #2563eb;
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 600;
}

.bookings-popover {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.35rem;
    width: 240px;
    max-width: 260px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 0.5rem;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 120ms ease, transform 120ms ease;
    z-index: 20;
}

.bookings-popover.is-floating {
    position: fixed;
    top: 0;
    left: 0;
    margin: 0;
}

.bookings-popover-wrap.is-open .bookings-popover {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.bookings-popover-list {
    display: grid;
    gap: 0.45rem;
    max-height: 220px;
    overflow-y: auto;
}

.bookings-group-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 0.15rem;
}

.bookings-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.15rem;
}

.bookings-list a {
    font-size: 0.75rem;
    color: #111827;
    text-decoration: none;
}

.bookings-list a:hover {
    text-decoration: underline;
}

.availability-details-panel {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
    background: #ffffff;
    min-height: 280px;
    position: sticky;
    top: 0.85rem;
}

.details-empty {
    font-size: 0.85rem;
    color: var(--muted);
}

.details-content.is-hidden,
.details-empty.is-hidden,
.details-empty-text.is-hidden {
    display: none;
}

.details-header {
    display: grid;
    gap: 0.2rem;
    margin-bottom: 0.65rem;
}

.details-title {
    font-size: 1rem;
    font-weight: 600;
}

.details-meta {
    font-size: 0.75rem;
    color: var(--muted);
}

.details-section {
    margin-top: 0.65rem;
}

.details-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.details-capacity {
    display: grid;
    gap: 0.2rem;
    font-size: 0.85rem;
    color: #111827;
}

.details-bookings .bookings-popover-list {
    max-height: 180px;
}

.details-notes {
    font-size: 0.85rem;
    color: #111827;
    white-space: pre-wrap;
}

.details-actions {
    margin-top: 0.75rem;
}

.expense-reveal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.is-hidden {
    display: none;
}

@media (max-width: 1100px) {
    .availability-compact-layout {
        grid-template-columns: 1fr;
    }

    .availability-details-panel {
        position: static;
    }

    .availability-compact-table {
        min-width: 720px;
    }
}

@media (max-width: 768px) {
    .availability-compact-controls {
        align-items: stretch;
    }

    .availability-compact-table {
        min-width: 640px;
    }

    .availability-search input {
        min-width: 0;
    }
}



/* Forms */

form .form-row {
    margin-bottom: 0.8rem;
}

form label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

.form-actions .btn {
    min-width: 160px;
    text-align: center;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

form input,
form select,
form textarea {
    width: 100%;
    padding: 0.4rem 0.45rem;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 0.9rem;
    background: #ffffff;
    color: #111827;
}

form input:focus,
form select:focus,
form textarea:focus {
    border-color: #2563eb;
    outline: none;
    box-shadow: 0 0 0 1px #2563eb33;
}

form input[type="date"],
form input[type="file"] {
    padding: 0.3rem 0.35rem;
}

.form-errors {
    margin: 0 0 0.6rem;
    color: #b91c1c;
    font-size: 0.85rem;
}

/* Notes */

/* scroll box: remove inner padding so items align properly */
.notes-scroll{
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0;
}

/* remove default UL/LI spacing */
.notes-list{
  list-style: none;
  margin: 0;
  padding: 0;
}

.note-item{
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid #acacac;
}

.note-item:last-child{
  border-bottom: 0;
}

.note-meta{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 4px 0;
  font-size: 0.875rem;
  color: #6b7280;
}

.note-author{
  font-weight: 700;
  color: #000000;
  font-size: 14px;
}

.note-time{
  white-space: nowrap;
}

.note-body{
  margin: 0;
  text-align: left;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;   /* modern: breaks long strings */
  word-break: break-word;    /* fallback */
}


/* Alerts */

.alert {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.alert-info {
    background: #e0f2fe;
    color: #075985;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

/* Responsive */

@media (max-width: 768px) {
    .site-header-inner {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        color: #ffffff;
    }

    .btn.nav-toggle-btn {
        display: inline-flex;
        margin-left: auto;
        white-space: nowrap;
    }

    .site-nav {
        width: 100%;
        display: none;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
        padding: 0.5rem 0 0.25rem;
    }

    .site-header-inner.nav-open .site-nav {
        display: flex;
    }

    .site-nav a {
        width: 100%;
        padding: 0.55rem 0.65rem;
    }

    .site-nav form {
        width: 100%;
    }

    .dashboard-no-scroll {
        overflow: auto;
    }

    .dashboard-no-scroll .layout-shell {
        height: auto;
        min-height: 100vh;
    }

    .dashboard-no-scroll .site-main {
        overflow: auto;
    }

    .dashboard-no-scroll .container {
        height: auto;
    }

    .dashboard-layout {
        height: auto;
    }

    .dashboard-no-scroll .orders-table-card {
        flex: 0 0 auto;
    }

    .dashboard-no-scroll .orders-table-card .table-wrapper {
        max-height: none;
    }

    .calendar-no-scroll {
        overflow: auto;
    }

    .calendar-no-scroll .layout-shell {
        height: auto;
        min-height: 100vh;
    }

    .calendar-no-scroll .site-main {
        overflow: auto;
    }

    .calendar-no-scroll .container {
        height: auto;
    }

    .calendar-layout {
        height: auto;
    }

    .calendar-card {
        flex: 0 0 auto;
    }

    .calendar-no-scroll .calendar-wrapper {
        overflow-y: visible;
    }

    .site-main {
        padding: 0.9rem 0.75rem 1.5rem;
    }

    .card {
        padding: 0.85rem 0.9rem;
    }

    table {
        font-size: 0.8rem;
    }

    th,
    td {
        padding: 0.35rem 0.4rem;
    }

    .availability-pattern-form {
        align-items: stretch;
    }

    .availability-pattern-fields {
        width: 100%;
    }

    .availability-pattern-form .btn {
        width: 100%;
        justify-content: center;
    }

    .availability-day-row {
        grid-template-columns: 1fr;
        padding: 0.65rem 0.75rem;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: #ffffff;
    }

    .availability-field-label {
        display: block;
    }

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

    .my-availability-calendar {
        min-width: 540px;
        gap: 0.35rem;
    }

    .my-calendar-cell {
        min-height: 110px;
        padding: 0.4rem;
    }

    .request-note-input {
        width: 100%;
    }

    .request-actions-form {
        flex-direction: column;
        align-items: stretch;
    }

    .request-actions-buttons {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .calendar-head-row,
    .calendar-grid {
        gap: 0.35rem;
        min-width: 540px;
    }

    .calendar-grid {
        grid-auto-rows: 130px;
    }

    .calendar-no-scroll .calendar-grid {
        grid-auto-rows: 130px;
    }

    .calendar-cell {
        padding: 0.45rem;
    }

    .calendar-head {
        font-size: 0.8rem;
        padding: 0.2rem 0.2rem;
    }

    .calendar-cell .status-pill {
        font-size: 0.72rem;
        padding: 0.12rem 0.4rem;
    }

    .availability-calendar-engineer {
        min-width: 0;
        flex: 1 1 220px;
    }

    .availability-calendar-controls .btn {
        flex: 1 1 auto;
    }
}
