:root {
  --brand: #1a56db;
  --brand-dark: #1341aa;
  --sidebar-bg: #1e2533;
  --sidebar-header-bg: #161c28;
  --sidebar-width: 220px;
}

body { background: #f4f6f9; font-size: 0.92rem; margin: 0; }

/* ── Auth ── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
  background-image:
    linear-gradient(rgba(26,86,219,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26,86,219,.07) 1px, transparent 1px);
  background-size: 40px 40px;
  position: relative;
  overflow: hidden;
}
.auth-wrapper::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(26,86,219,.2) 0%, transparent 70%);
  top: -150px; left: -150px;
  pointer-events: none;
}
.auth-wrapper::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(0,180,255,.12) 0%, transparent 70%);
  bottom: -100px; right: -100px;
  pointer-events: none;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(26,86,219,.15);
  box-shadow: 0 0 60px rgba(26,86,219,.15), 0 20px 60px rgba(0,0,0,.4);
  position: relative;
  z-index: 1;
}
.auth-card .card-body { padding: 2rem; }
.auth-logo {
  font-size: 2.4rem;
  background: linear-gradient(135deg, var(--brand), #00b4d8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-title { color: #0f172a; font-weight: 700; font-size: 1.5rem; letter-spacing: .5px; }
.auth-card .form-label { color: #334155; font-size: .82rem; font-weight: 600; }
.auth-card .form-control {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  border-radius: 8px;
}
.auth-card .form-control:focus {
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
  color: #0f172a;
}
.auth-card .form-control::placeholder { color: #94a3b8; }
.auth-card .btn-outline-secondary { background: #f8fafc; border-color: #cbd5e1; color: #64748b; }
.auth-card .btn-outline-secondary:hover { background: #f1f5f9; }
.btn-login {
  background: linear-gradient(135deg, var(--brand), #00b4d8);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: .5px;
  padding: .6rem;
  transition: opacity .2s, transform .1s;
}
.btn-login:hover { opacity: .9; transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }
.auth-error { color: #ff6b8a; font-size: .82rem; min-height: 1.2em; }

/* ── App shell ── */
#app-shell { display: none; }
#app-shell.visible { display: flex; min-height: 100vh; flex-direction: row; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: sticky;
  top: 0;
  overflow: hidden;
  z-index: 1040;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1rem 1.1rem;
  background: var(--sidebar-header-bg);
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sidebar-header i { color: var(--brand); font-size: 1.2rem; }

.sidebar-nav { flex: 1; padding: .5rem 0; overflow-y: auto; scrollbar-width: none; }
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-group-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #5a6a88;
  padding: .9rem 1.1rem .25rem;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem 1.1rem;
  color: #a8b5cc;
  border-radius: 0;
  font-size: .87rem;
  border-left: 3px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.sidebar .nav-link i { font-size: 1rem; width: 1.1rem; flex-shrink: 0; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active {
  background: rgba(26,86,219,.2);
  color: #fff;
  border-left-color: var(--brand);
  font-weight: 600;
}

.sidebar-footer {
  padding: .75rem 1.1rem;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: .8rem;
  color: #6b7a99;
  flex-shrink: 0;
}

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1039;
}
.sidebar-overlay.active { display: block; }

/* ── App body ── */
.app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Top bar ── */
.top-bar {
  background: var(--brand);
  color: #fff;
  padding: .5rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  flex-shrink: 0;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,.85);
  font-size: 1.45rem;
  line-height: 1;
  padding: 0 .25rem;
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: #fff; }

.global-search-wrap { flex: 1; max-width: 420px; }
.global-search-icon {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  border-right: none;
  color: rgba(255,255,255,.8);
}
.global-search-input {
  background: rgba(255,255,255,.15) !important;
  border: 1px solid rgba(255,255,255,.25) !important;
  border-left: none !important;
  color: #fff !important;
  caret-color: #fff;
}
.global-search-input::placeholder { color: rgba(255,255,255,.5) !important; }
.global-search-input:focus {
  background: rgba(255,255,255,.22) !important;
  box-shadow: 0 0 0 .2rem rgba(255,255,255,.18) !important;
  outline: none;
}

/* ── Content ── */
#main-content { flex: 1; padding: 1rem; overflow-y: auto; }

/* ── Table ── */
.claims-table th { white-space: nowrap; font-size: .82rem; background: #f8f9fa; }
.claims-table td { vertical-align: middle; font-size: .85rem; }
.claims-table tbody tr { cursor: pointer; transition: background .1s; }
.claims-table tbody tr:hover { background: #eef2ff; }

.badge-status {
  font-size: .72rem;
  padding: .25em .6em;
  border-radius: 20px;
  white-space: nowrap;
}

/* ── Filters bar ── */
.filters-bar { background: #fff; border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ── Pagination ── */
.pagination { gap: .2rem; }
.page-link { border-radius: 6px !important; font-size: .82rem; }

/* ── Claim detail ── */
.detail-section { background: #fff; border-radius: 8px; padding: 1rem 1.25rem; margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.detail-section h6 { color: var(--brand); font-weight: 700; border-bottom: 1px solid #e8ecf0; padding-bottom: .4rem; margin-bottom: .75rem; }

/* ── Comments ── */
.comment-item { border-left: 3px solid var(--brand); padding: .5rem .75rem; background: #f8f9fa; border-radius: 0 6px 6px 0; }
.comment-author { font-weight: 600; font-size: .8rem; color: var(--brand); }
.comment-date { font-size: .75rem; color: #888; }
.comment-system { border-left-color: #aaa; }
.comment-system .comment-author { color: #777; }

/* ── Status colors ── */
.s-new           { background: #e0f2fe; color: #0369a1; }
.s-need-schedule { background: #fee2e2; color: #dc2626; }
.s-scheduled     { background: #dbeafe; color: #1d4ed8; }
.s-need-auth     { background: #f3e8ff; color: #6b21a8; }
.s-autho-sent    { background: #ccfbf1; color: #0f766e; }
.s-need-parts    { background: #fff7ed; color: #c2410c; }
.s-parts-ordered { background: #fef9c3; color: #a16207; }
.s-need-bill     { background: #ede9fe; color: #7c3aed; }
.s-billed        { background: #dcfce7; color: #15803d; }
.s-completed     { background: #f3f4f6; color: #6b7280; }
.s-hold          { background: #fce7f3; color: #be185d; }
.s-default       { background: #f3f4f6; color: #374151; }

/* ── Loading ── */
.loading-spinner { display: flex; align-items: center; justify-content: center; padding: 3rem; }

/* ── Schedule page ── */
.sched-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem .75rem;
}
.sched-date-label {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1e2533;
}
.sched-date-picker {
  width: 150px;
  cursor: pointer;
}
.sched-nav-wrap, .cal-nav-wrap {
  display: flex;
  align-items: stretch;
  gap: .25rem;
}
.sched-nav-btn, .cal-nav-btn {
  flex-shrink: 0;
  width: 2rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  border: none;
  background: transparent;
}
.sched-list {
  padding: 0 .75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.sched-card {
  display: flex;
  background: #fff;
  border-radius: .5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow .15s;
}
.sched-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,.13); }
.sched-card-bar {
  width: 5px;
  background: var(--brand);
  flex-shrink: 0;
}
.sched-card-body {
  padding: .75rem 1rem;
  flex: 1;
}
.sched-type {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--brand);
  text-transform: uppercase;
  margin-bottom: .15rem;
}
.sched-client {
  font-size: 1rem;
  font-weight: 600;
  color: #1e2533;
}
.sched-address {
  font-size: .85rem;
  color: #475569;
  margin: .2rem 0 .4rem;
}
.sched-maps-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  flex-shrink: 0;
  color: var(--brand);
  font-size: 1.75rem;
  text-decoration: none;
  border-left: 1px solid #f1f5f9;
  transition: background .15s;
}
.sched-maps-btn:hover { background: #f0f7ff; }
.sched-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.sched-claim-num {
  font-size: .75rem;
  color: #94a3b8;
}
.sched-empty {
  text-align: center;
  color: #94a3b8;
  padding: 4rem 1rem;
  font-size: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}
.sched-empty i { font-size: 2.5rem; }

/* ── Address autocomplete ── */
.address-ac-dropdown {
  position: absolute;
  z-index: 9999;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: .375rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  max-height: 200px;
  overflow-y: auto;
}
.address-ac-item {
  padding: .35rem .75rem;
  cursor: pointer;
  font-size: .85rem;
}
.address-ac-item:hover { background: #f1f5f9; }

/* ── Schedule time column ── */
.sched-time-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  min-width: 76px;
  padding: .75rem .5rem .75rem .75rem;
  flex-shrink: 0;
}
.sched-time-start {
  font-size: .88rem;
  color: #475569;
  white-space: nowrap;
}
.sched-time-dur {
  font-size: .82rem;
  color: #94a3b8;
  margin-top: .1rem;
}
.sched-card-divider {
  width: 1px;
  background: #e2e8f0;
  align-self: stretch;
  flex-shrink: 0;
}
.sched-arrival {
  font-size: .78rem;
  color: #94a3b8;
  margin: .15rem 0 .3rem;
}

/* ── Status pipeline ── */
.status-pipeline-scroll {
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.status-pipeline-scroll::-webkit-scrollbar { display: none; }
.status-pipeline {
  display: flex;
  gap: 0;
  width: max-content;
  padding: .75rem 0 .5rem;
}
.status-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  flex: 0 0 72px;
  width: 72px;
  position: relative;
  padding: 0 4px;
}
.status-step::after {
  content: '';
  position: absolute;
  top: 21px;
  left: calc(50% + 22px);
  right: calc(-50% + 22px);
  height: 2px;
  background: #dee2e6;
  z-index: 0;
}
.status-step:last-child::after { display: none; }
.status-step-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #dee2e6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 1.1rem;
  background: #fff;
  position: relative;
  z-index: 1;
  transition: all .15s;
}
.status-step:hover .status-step-circle {
  border-color: var(--sp-color, var(--brand));
  color: var(--sp-color, var(--brand));
}
.status-step.sp-past .status-step-circle {
  border-color: var(--sp-color, var(--brand));
  color: var(--sp-color, var(--brand));
  background: color-mix(in srgb, var(--sp-color, var(--brand)) 12%, white);
}
.status-step.sp-past::after { background: var(--sp-color, var(--brand)); }
.status-step.sp-active .status-step-circle {
  border-color: var(--sp-color, var(--brand));
  background: var(--sp-color, var(--brand));
  color: #fff;
}
.status-step-label {
  font-size: .62rem;
  text-align: center;
  margin-top: 5px;
  color: #94a3b8;
  line-height: 1.2;
  width: 100%;
}
.status-step.sp-active .status-step-label {
  color: var(--sp-color, var(--brand));
  font-weight: 700;
}
.status-step.sp-past .status-step-label {
  color: #475569;
}
.status-pipeline-wrap {
  display: flex;
  align-items: flex-start;
  gap: 0;
}
.status-pipeline-wrap .status-pipeline-scroll {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}
.status-pipeline-wrap .status-step.sp-hold {
  flex-shrink: 0;
  padding-top: .75rem;
}
.status-step.sp-has-sched {
  flex: 0 0 96px;
  width: 96px;
}
.claim-contact-card {
  display: flex;
  background: #fff;
  border-radius: .5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  overflow: hidden;
}
.claim-contact-body {
  flex: 1;
  padding: .75rem 1rem;
}
.claim-contact-name {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.3;
}
.claim-contact-num {
  font-size: .8rem;
  font-weight: 400;
  color: #94a3b8;
}
.claim-contact-addr {
  font-size: .875rem;
  color: #334155;
  margin-top: .15rem;
  line-height: 1.4;
}
.claim-contact-phone {
  font-size: .875rem;
  color: #0369a1;
  margin-top: .1rem;
}

.tech-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tech-info-title {
  font-size: .875rem;
  font-weight: 600;
  color: #475569;
}
.section-count-badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 600;
  background: #e2e8f0;
  color: #64748b;
  border-radius: 999px;
  padding: 0 .45rem;
  line-height: 1.6;
  vertical-align: middle;
  margin-left: .25rem;
}
.tech-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.tech-toggle-btn:hover { background: #e2e8f0; color: #1e293b; }
.tech-toggle-icon { transition: transform .2s; }
.tech-toggle-icon.tech-toggle-open { transform: rotate(180deg); }

.sp-sched-date, .sp-sched-time {
  font-size: .58rem;
  color: #1e293b;
  white-space: nowrap;
  text-align: center;
  line-height: 1.3;
  font-weight: 600;
}
.sp-sched-time { color: #334155; font-weight: 400; }
.status-step.sp-active .sp-sched-date,
.status-step.sp-active .sp-sched-time { color: #1e293b; }
.status-step.sp-hold .status-step-circle {
  border-color: #be185d;
  color: #be185d;
}
.status-step.sp-hold:hover .status-step-circle {
  background: #fce7f3;
}
.status-step.sp-hold.sp-hold-active .status-step-circle {
  background: #be185d;
  color: #fff;
  border-color: #be185d;
}
.status-step.sp-hold .status-step-label { color: #be185d; }
.status-step.sp-hold::after { display: none; }

/* ── Mobile ── */
@media (max-width: 767px) {
  .sidebar-toggle { display: block; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    height: 100vh;
    height: 100dvh;
  }
  .sidebar.open { transform: translateX(0); }
  #main-content { padding: .6rem; }
  .filters-bar .row > div { margin-bottom: .4rem; }
  .detail-section { padding: .75rem; }
  .table-responsive { font-size: .78rem; }
}

@media (min-width: 768px) {
  .sidebar-toggle { display: none; }
}

/* Photo grid */
.photo-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.photo-thumb { position: relative; width: 133px; height: 133px; border-radius: 8px; overflow: hidden; background: #f1f5f9; flex-shrink: 0; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; display: block; }
.photo-del-btn { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(0,0,0,.5); color: #fff; font-size: .75rem; display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.photo-del-btn:hover { background: rgba(220,38,38,.85); }

/* Activity feed */
.activity-item { padding: .4rem 0; border-bottom: 1px solid #f1f5f9; }
.activity-item:last-child { border-bottom: none; }
.activity-meta { display: flex; justify-content: space-between; margin-bottom: .1rem; }
.activity-author { font-weight: 600; font-size: .8rem; color: #1e293b; }
.activity-date { font-size: .75rem; color: #94a3b8; }

/* ── Calendar ── */
.cal-header {
  padding: 1rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 10;
}
.cal-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
}
.cal-date-label {
  font-weight: 600;
  font-size: .95rem;
  text-transform: capitalize;
  color: #1e293b;
}
.cal-date-picker { max-width: 155px; }
.cal-tech-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .25rem; }
.cal-tech-item { margin: 0; }

/* Grid */
.cal-grid-wrap { overflow: auto; }
.cal-grid { display: flex; min-width: fit-content; }
.cal-time-col { width: 64px; flex-shrink: 0; }
.cal-col-header {
  position: relative;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 600;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  padding: 0 1rem 0 .5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}
.cal-resize-handle {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  transition: background .15s;
}
.cal-resize-handle:hover { background: rgba(26,86,219,.2); }
.cal-time-labels { position: relative; }
.cal-hour-label {
  height: 64px;
  display: flex;
  align-items: flex-start;
  padding: 4px 8px 0 0;
  justify-content: flex-end;
  font-size: .68rem;
  color: #94a3b8;
  box-sizing: border-box;
  border-right: 1px solid #e5e7eb;
}
.cal-cols-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cal-col-headers { display: flex; }
.cal-col-headers .cal-col-header { flex: 1; min-width: 160px; border-left: 1px solid #e5e7eb; border-right: none; }
.cal-body { position: relative; display: flex; }
.cal-lines { position: absolute; inset: 0; pointer-events: none; }
.cal-hour-line { height: 64px; border-top: 1px solid #f1f5f9; box-sizing: border-box; }
.cal-col {
  flex: 1;
  min-width: 200px;
  position: relative;
  border-left: 1px solid #e5e7eb;
}
.cal-col .sched-card { z-index: 1; }
.activity-text { font-size: .85rem; color: #475569; }
