:root {
    --bg: #f4f5f7;
    --card-bg: #ffffff;
    --border: #e1e4e8;
    --text: #1f2328;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success-bg: #ecfdf5;
    --success-border: #34d399;
    --error-bg: #fef2f2;
    --error-border: #f87171;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

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

/* ---- Top bar ---- */
.topbar {
    background: #111827;
    color: #fff;
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand:hover { text-decoration: none; }
.brand-logo {
    display: inline-flex;
    align-items: center;
    background: #fff;
    border-radius: 6px;
    padding: 5px 9px;
}
.brand-logo img {
    height: 26px;
    width: auto;
    display: block;
}
.topbar nav { display: flex; gap: 16px; flex: 1; }
.topbar nav a { color: #d1d5db; }
.topbar nav a:hover { color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.who { color: #9ca3af; font-size: 0.9rem; }
.btn-link { color: #d1d5db; font-size: 0.9rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
/* Schedule page uses the full window width for a larger calendar. */
.container-wide .container,
.container-wide .topbar-inner { max-width: 1800px; }

.sitefooter {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 30px 0;
}

/* ---- Flash messages ---- */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.flash-success { background: var(--success-bg); border-color: var(--success-border); color: #065f46; }
.flash-error { background: var(--error-bg); border-color: var(--error-border); color: #991b1b; }
.flash ul { margin: 0; padding-left: 20px; }

/* ---- Stat cards ---- */
.stat-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
    color: var(--text);
}
.stat-card:hover { border-color: var(--primary); text-decoration: none; }
.stat-card.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
.stat-count { display: block; font-size: 1.6rem; font-weight: 700; }
.stat-label { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 2px; }

/* ---- Filter bar ---- */
/* ---- Mini day calendar (home page) ---- */
.mini-cal-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}
.mini-cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.mini-cal-header h2 { margin: 0; font-size: 1.1rem; }
.mini-cal-date { font-size: 0.85rem; margin: 2px 0 10px; }
.mini-cal-loading, .mini-cal-empty { padding: 20px 4px; font-size: 0.9rem; }
.mini-cal-clickable { cursor: pointer; }
.mini-cal-clickable:hover .mini-col-body { background-color: #fafbff; }

.mini-cal-scroll { overflow-x: auto; }
.mini-cal-grid { display: flex; min-width: 100%; }

.mini-gutter { flex: 0 0 40px; }
.mini-gutter-head { height: 30px; }
.mini-gutter-body { position: relative; }
.mini-hour {
    position: absolute;
    right: 4px;
    transform: translateY(-50%);
    font-size: 0.65rem;
    color: var(--muted);
}

.mini-col { flex: 1 0 120px; border-left: 1px solid var(--border); min-width: 0; }
.mini-col-head {
    height: 30px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 6px;
    font-size: 0.78rem;
    font-weight: 600;
    border-top: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mini-col-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.mini-col-body {
    position: relative;
    background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px);
    background-repeat: repeat-y;
    background-size: 100% 42px;
}

.mini-ev {
    position: absolute;
    left: 2px;
    right: 2px;
    border-left: 3px solid #2563eb;
    border-radius: 3px;
    padding: 2px 4px;
    overflow: hidden;
    font-size: 0.68rem;
    line-height: 1.15;
}
.mini-ev-shadow { border-left-style: dashed; opacity: 0.9; }
.mini-ev-done { border-left-color: #059669; }
.mini-ev-time { font-weight: 700; color: var(--muted); font-size: 0.62rem; }
.mini-ev-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mini-ev-crew { margin-left: 3px; }
.mini-ev-check {
    margin-left: 3px;
    color: #fff;
    background: #059669;
    border-radius: 50%;
    padding: 0 3px;
    font-weight: 800;
}

/* ---- Dispatch map (home page) ---- */
.map-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}
.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}
.map-header h2 { margin: 0; font-size: 1.1rem; }
.map-controls { display: flex; align-items: center; gap: 8px; }
.map-date-label { margin: 0; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.map-controls input[type="date"] { width: auto; padding: 7px 10px; }
.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 10px;
    min-height: 8px;
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.legend-dot {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex: 0 0 11px;
    vertical-align: middle;
}
.dispatch-map {
    width: 100%;
    height: 420px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #eef1f5;
}
.map-status { margin: 8px 0 0; font-size: 0.85rem; }
.map-info { font-size: 0.88rem; min-width: 200px; max-width: 260px; }
.map-info-title { font-weight: 700; margin-bottom: 4px; }
.map-info-row { margin: 2px 0; color: #374151; }
.map-info-link { display: inline-block; margin-top: 6px; font-weight: 600; }

/* Leaflet custom pin: remove the default divIcon white box. */
.dispatch-pin { background: transparent; border: none; }
.dispatch-pin svg { display: block; }

/* Photo pin: circular tech photo with colored ring + pointer. */
.photo-pin { position: relative; width: 44px; height: 56px; box-sizing: border-box; }
.photo-pin-img {
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid #2563eb;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.photo-pin-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
    border-radius: 50%;
}
/* Override Leaflet's default marker-image rules so the face stays centered. */
.leaflet-marker-icon .photo-pin-img img,
.dispatch-pin .photo-pin-img img {
    max-width: none !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center center !important;
    margin: 0 !important;
}
.photo-pin-point {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 10px solid #2563eb;
}
/* "+N" crew badge on pins. */
.pin-wrap { position: relative; width: 30px; height: 42px; }
.pin-badge {
    position: absolute;
    top: -4px;
    right: -8px;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    border-radius: 8px;
    background: #111827;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    border: 1.5px solid #fff;
    box-sizing: border-box;
}
.pin-badge-photo { top: -2px; right: -2px; }
.map-info-crew-label { font-weight: 700; margin-top: 4px; }
.sched-event-crew {
    float: right;
    font-size: 0.7rem;
    background: rgba(17,24,39,0.12);
    border-radius: 8px;
    padding: 0 5px;
    font-weight: 700;
}
/* Completion checkmark on appointments whose ticket is Resolved/Closed. */
.sched-event-check {
    float: right;
    margin-left: 4px;
    font-size: 0.78rem;
    font-weight: 800;
    color: #fff;
    background: #059669;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
}
.sched-event-done { border-left-color: #059669 !important; }
.crew-primary { opacity: 0.85; font-weight: 700; }
.crew-primary::after { content: " (primary)"; font-size: 0.78rem; color: var(--muted); font-weight: 400; }

/* Tickets that couldn't be geocoded. */
.map-unplaceable {
    margin-top: 10px;
    padding: 10px 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    font-size: 0.85rem;
}
.unplaceable-title { font-weight: 700; color: #92400e; margin-bottom: 6px; }
.unplaceable-item { padding: 4px 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.unplaceable-addr { color: #374151; }
.unplaceable-reason { color: #9a3412; font-size: 0.8rem; }
.place-pin-btn { margin-left: auto; }
.map-place-banner {
    background: #2563eb;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 0.88rem;
    font-weight: 600;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
    align-items: center;
}
.filter-bar input[type="text"] {
    flex: 1;
    min-width: 220px;
}

/* ---- Forms ---- */
input[type="text"], input[type="email"], input[type="password"], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    margin: 12px 0 4px;
}
.form-card, .status-form { 
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0 16px;
}
/* City / State / ZIP row: city wide, state narrow, zip medium. */
.address-row {
    display: grid;
    grid-template-columns: 2fr 0.7fr 1fr;
    gap: 0 16px;
}
@media (max-width: 520px) {
    .address-row { grid-template-columns: 1fr; }
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    color: var(--text);
    margin: 10px 0;
}
.checkbox-label input { width: auto; }

/* Row of checkboxes (e.g. Service Type) */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin: 4px 0 8px;
}
.checkbox-group .checkbox-label {
    margin: 4px 0;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 6px;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-secondary:hover { background: #d1d5db; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; }
.btn-block { width: 100%; margin-top: 18px; }

/* ---- Ticket table ---- */
.ticket-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.ticket-table th, .ticket-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}
.ticket-table th { background: #f9fafb; color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #f9fafb; }
.empty-row { text-align: center; color: var(--muted); padding: 30px; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge-internal { background: #fef3c7; color: #92400e; margin-left: 8px; }
.priority-Low { background: #e5e7eb; color: #374151; }
.priority-Medium { background: #dbeafe; color: #1e40af; }
.priority-High { background: #fed7aa; color: #9a3412; }
.priority-Critical { background: #fecaca; color: #991b1b; }

.status-Open { background: #dbeafe; color: #1e40af; }
.status-In-Progress { background: #fef3c7; color: #92400e; }
.status-Pending { background: #ede9fe; color: #5b21b6; }
.status-Resolved { background: #d1fae5; color: #065f46; }
.status-Closed { background: #e5e7eb; color: #374151; }

a.stat-card.status-Open { border-top: 3px solid #2563eb; }
a.stat-card.status-In-Progress { border-top: 3px solid #d97706; }
a.stat-card.status-Pending { border-top: 3px solid #7c3aed; }
a.stat-card.status-Resolved { border-top: 3px solid #059669; }
a.stat-card.status-Closed { border-top: 3px solid #6b7280; }

/* ---- Ticket detail ---- */
.ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 18px;
    gap: 16px;
}
.ticket-header-actions {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    flex-shrink: 0;
}
.muted { color: var(--muted); font-size: 0.9rem; }
.ticket-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    align-items: start;
}
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
}
.card h3 { margin-top: 0; }
.description-text { white-space: pre-wrap; line-height: 1.5; }
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin-top: 14px; }
.meta-list dt { color: var(--muted); font-size: 0.85rem; }
.meta-list dd { margin: 0; }

.comment-list { list-style: none; padding: 0; margin: 0 0 16px; }
.comment {
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
}
.comment:last-child { border-bottom: none; }
.comment-internal { background: #fffbeb; padding: 12px; border-radius: 6px; border-bottom: none; margin-bottom: 8px; }
.comment-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.comment-form textarea { margin-bottom: 4px; }

/* ---- Login page ---- */
.login-body {
    background: #111827;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-box {
    background: #fff;
    padding: 32px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 360px;
}
.login-box h1 { margin-top: 0; font-size: 1.3rem; text-align: center; }
.login-logo {
    display: block;
    width: 100%;
    max-width: 240px;
    height: auto;
    margin: 0 auto 18px;
}

@media (max-width: 800px) {
    .stat-row { grid-template-columns: repeat(2, 1fr); }
    .ticket-grid { grid-template-columns: 1fr; }
    .ticket-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* =====================================================================
   Technicians page
   ===================================================================== */
.tech-add-form {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 0 16px;
    align-items: end;
}
.hidden-form { display: none; }
.tech-thumb {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #2563eb;
    display: block;
}
.tech-thumb-placeholder {
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}
.actions-cell { display: flex; gap: 8px; white-space: nowrap; }
.btn-sm { padding: 5px 11px; font-size: 0.85rem; }
input[type="color"] {
    width: 44px;
    height: 34px;
    padding: 2px;
    cursor: pointer;
}

/* =====================================================================
   Schedule page layout
   ===================================================================== */
.schedule-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.schedule-toolbar h1 { margin: 0; }
.schedule-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.schedule-nav input[type="date"] {
    width: auto;
    padding: 8px 10px;
}
.view-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}
.btn-toggle {
    background: #fff;
    color: var(--text);
    border: none;
    border-radius: 0;
    padding: 8px 16px;
}
.btn-toggle + .btn-toggle { border-left: 1px solid var(--border); }
.btn-toggle.active { background: var(--primary); color: #fff; }
#weekTechnicianSelect { width: auto; min-width: 160px; padding: 8px 10px; }

.schedule-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 18px;
    align-items: start;
}
.schedule-sidebar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    position: sticky;
    top: 16px;
}
.schedule-sidebar h3 { margin-top: 0; }
.small { font-size: 0.82rem; }

.unscheduled-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 80vh;
    overflow-y: auto;
}
.ticket-card {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 4px solid #9ca3af;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: grab;
    font-size: 0.85rem;
}
.ticket-card:active { cursor: grabbing; }
.ticket-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.ticket-card-number { font-weight: 700; color: var(--muted); font-size: 0.78rem; }
.ticket-card-subject { color: var(--text); }
.priority-border-Low { border-left-color: #9ca3af; }
.priority-border-Medium { border-left-color: #3b82f6; }
.priority-border-High { border-left-color: #f97316; }
.priority-border-Critical { border-left-color: #dc2626; }

.ticket-card.highlight {
    box-shadow: 0 0 0 2px var(--primary);
    animation: highlight-pulse 1.4s ease-in-out 2;
}
@keyframes highlight-pulse {
    0%, 100% { box-shadow: 0 0 0 2px var(--primary); }
    50% { box-shadow: 0 0 0 5px rgba(37,99,235,0.25); }
}

/* =====================================================================
   Calendar grid
   ===================================================================== */
.schedule-calendar-wrap {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.calendar-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 85vh;
}
.calendar-grid { min-width: 100%; }

.cal-row { display: flex; }
.cal-header-row {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #fff;
    border-bottom: 1px solid var(--border);
}
.cal-gutter {
    width: 64px;
    flex: 0 0 64px;
    position: relative;
}
.cal-gutter-spacer { border-right: 1px solid var(--border); }
.cal-tech-header {
    width: 280px;
    flex: 1 0 280px;
    padding: 12px 14px;
    border-right: 1px solid var(--border);
    border-top: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}
.tech-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 10px;
}

.cal-body-row { position: relative; }
.cal-hour-label {
    position: absolute;
    right: 8px;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
}
.cal-tech-column {
    width: 280px;
    flex: 1 0 280px;
    position: relative;
    border-right: 1px solid var(--border);
    background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px);
    background-repeat: repeat-y;
    cursor: cell;
}
.cal-tech-column.drag-over { background-color: #eff6ff; }

.cal-tech-column.is-today { background-color: #fafbff; }
.cal-tech-header.is-today { background: #eff6ff; }

.now-line-column {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    border-top: 2px solid #dc2626;
    z-index: 2;
    pointer-events: none;
}

.sched-event {
    position: absolute;
    left: 5px;
    right: 5px;
    border-left: 4px solid #2563eb;
    border-radius: 5px;
    padding: 6px 9px;
    font-size: 0.82rem;
    overflow: hidden;
    cursor: grab;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.sched-event:active { cursor: grabbing; }
/* Crew copies (appointment shown in a non-primary crew member's column). */
.sched-event-shadow {
    border-left-style: dashed;
    opacity: 0.92;
    background-image: repeating-linear-gradient(
        45deg,
        rgba(255,255,255,0.0),
        rgba(255,255,255,0.0) 6px,
        rgba(255,255,255,0.35) 6px,
        rgba(255,255,255,0.35) 12px
    );
}
.sched-event-time { font-weight: 700; font-size: 0.76rem; color: var(--muted); }
.sched-event-title { font-weight: 600; line-height: 1.3; }
.sched-event-ticket { font-size: 0.76rem; color: var(--muted); }
.resize-handle {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 9px;
    cursor: ns-resize;
}

/* =====================================================================
   Modal
   ===================================================================== */
/* The [hidden] attribute must always win over display rules below. */
[hidden] { display: none !important; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}
/* Only become a visible flex container when NOT hidden. */
.modal-backdrop:not([hidden]) {
    display: flex;
}
.modal {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 18px;
}
.modal-actions-right { display: flex; gap: 8px; }
.ticket-link-badge {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

/* =====================================================================
   Ticket detail: scheduled appointments list
   ===================================================================== */
.appt-list { list-style: none; padding: 0; margin: 0 0 12px; }
.appt-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
.appt-list li:last-child { border-bottom: none; }

@media (max-width: 900px) {
    .schedule-layout { grid-template-columns: 1fr; }
    .schedule-sidebar { position: static; }
}


/* ---- Time Clock ---- */
.timeclock-header { margin-bottom: 16px; }
.timeclock-header h1 { margin-bottom: 2px; }
.timeclock-card { padding: 0; overflow: hidden; }
.timeclock-table { width: 100%; border-collapse: collapse; }
.timeclock-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: #f9fafb;
    border-bottom: 1px solid var(--border);
}
.timeclock-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.timeclock-table tr:last-child td { border-bottom: none; }
.tc-name-col { width: 30%; }
.tc-action-col { width: 150px; }

.tc-name { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.tc-photo {
    width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
    object-position: center center; border: 2px solid #2563eb; display: block;
}
.tc-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: 0 0 14px; }

.tc-bar-wrap {
    position: relative;
    height: 24px;
    background: #eef1f5;
    border-radius: 12px;
    overflow: hidden;
    min-width: 160px;
}
.tc-bar-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0;
    background: linear-gradient(90deg, #10b981, #059669);
    border-radius: 12px;
    transition: width 0.4s ease;
}
.tc-bar-label {
    position: relative;
    z-index: 1;
    display: block;
    text-align: center;
    line-height: 24px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #1f2328;
}
/* Over 40 hours: full red bar, hours keep counting in the label. */
.tc-bar-wrap.tc-over .tc-bar-fill {
    width: 100% !important;
    background: linear-gradient(90deg, #ef4444, #dc2626);
}
.tc-bar-wrap.tc-over .tc-bar-label { color: #fff; }

.tc-btn {
    width: 100%;
    padding: 9px 14px;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    color: #fff;
    transition: background 0.15s ease, transform 0.05s ease;
}
.tc-btn:active { transform: translateY(1px); }
.tc-btn:disabled { opacity: 0.6; cursor: default; }
.tc-btn-in { background: #059669; }
.tc-btn-in:hover:not(:disabled) { background: #047857; }
.tc-btn-out { background: #dc2626; }
.tc-btn-out:hover:not(:disabled) { background: #b91c1c; }

.tc-footnote { padding: 12px 16px; margin: 0; }

@media (max-width: 640px) {
    .timeclock-table th.tc-name-col { width: auto; }
    .tc-action-col { width: 120px; }
    .tc-bar-wrap { min-width: 110px; }
}

/* ---- Time Clock: expandable timesheet ---- */
.tc-expand-col { width: 130px; }
.tc-expand { text-align: right; }
.tc-expand-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
}
.tc-expand-btn:hover { background: #f3f4f6; }
.tc-detail-cell { background: #f9fafb; padding: 0 16px 16px; }
.tc-timesheet { padding-top: 12px; }

.ts-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.ts-week-label { font-weight: 700; }
.ts-print { margin-left: auto; text-decoration: none; }
.ts-total { margin-bottom: 12px; font-size: 0.9rem; }

.ts-day {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
}
.ts-day-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.ts-day-name { font-weight: 700; font-size: 0.9rem; }
.ts-day-hours { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.ts-empty { font-size: 0.82rem; padding: 4px 0; }

.ts-entry {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
    flex-wrap: wrap;
}
.ts-entry:last-of-type { border-bottom: none; }
.ts-entry-fields { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.ts-entry-fields label {
    display: flex;
    flex-direction: column;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    gap: 3px;
}
.ts-entry-fields input[type="datetime-local"] {
    padding: 6px 8px;
    font-size: 0.85rem;
    width: auto;
}
.ts-entry-hours { font-size: 0.82rem; font-weight: 600; align-self: center; }
.ts-open-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    color: #065f46;
    background: #d1fae5;
    padding: 1px 6px;
    border-radius: 999px;
    margin-left: 4px;
}
.ts-entry-actions { display: flex; gap: 6px; align-items: center; }
.ts-add-btn { margin-top: 8px; font-size: 0.82rem; }

@media (max-width: 640px) {
    .tc-expand-col { width: auto; }
    .ts-entry-fields input[type="datetime-local"] { width: 100%; }
}
