/* ==========================================================================
   KLICKIT Job Sheet Dashboard
   Design language: repair-workshop diagnostics. Graphite surfaces, a single
   amber "solder" accent for brand/pending, teal for approved states, coral
   for rejected. Job numbers & serials set in mono, like a receipt printer.
   Status pills are drawn like ink stamps — a nod to the physical job-sheet
   stub customers walk away with.
   ========================================================================== */

:root{
  --bg:            #14171b;
  --surface:       #1c2025;
  --surface-2:     #232830;
  --border:        #2f353d;
  --border-soft:   #262b32;

  --text:          #e9e7e1;
  --text-dim:      #9aa1ab;
  --text-faint:    #656d78;

  --amber:         #f0a83c;
  --amber-dim:     #4a3a1e;
  --teal:          #3fd6b6;
  --teal-dim:      #1c3d38;
  --coral:         #ef6a63;
  --coral-dim:     #422527;
  --slate:         #8891a0;
  --slate-dim:     #2c313a;

  /* branch colors */
  --branch-andheri: #6c9ef7;
  --branch-thane:   #7ee6a6;
  --branch-dadar:   #f29b9b;
  --branch-vashi:   #f7c56b;

  --font-display: 'Barlow Condensed', sans-serif;
  --font-body:    'Inter', sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;

  --radius: 8px;
  --radius-sm: 5px;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 1.5px 1.5px, rgba(255,255,255,0.028) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
}
:focus-visible{ outline: 2px solid var(--amber); outline-offset: 2px; }
button{ font-family: inherit; }

/* ---------- layout shell ---------- */
.app{ display:flex; min-height:100vh; }

.sidebar{
  width: 248px;
  flex-shrink:0;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  display:flex;
  flex-direction:column;
  padding: 20px 16px;
  position: sticky;
  top:0;
  height:100vh;
  overflow-y:auto;
}

.brand{ display:flex; align-items:center; gap:10px; padding: 4px 6px 22px; }
.brand__mark{ color: var(--amber); flex-shrink:0; }
.brand__text{ display:flex; flex-direction:column; line-height:1.15; }
.brand__name{ font-family: var(--font-display); font-weight:700; font-size:21px; letter-spacing: 0.06em; }
.brand__sub{ font-size:10.5px; color: var(--text-faint); letter-spacing:0.03em; }

.nav__label{
  font-family: var(--font-display);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 18px 8px 8px;
}
.nav__label:first-of-type{ margin-top:4px; }

.nav__item{
  display:flex; align-items:center; gap:9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  cursor:pointer;
  text-decoration:none;
}
.nav__item.is-active{ background: var(--surface-2); color: var(--text); }
.nav__dot{ width:6px; height:6px; border-radius:50%; background: var(--amber); }

.branch-list, .status-list{ display:flex; flex-direction:column; gap:2px; }

.branch-row{
  display:flex; align-items:center; justify-content:space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor:pointer;
  color: var(--text-dim);
  font-size: 13.5px;
}
.branch-row:hover{ background: var(--surface-2); }
.branch-row.is-active{ background: var(--surface-2); color: var(--text); }
.branch-row.is-active .branch-row__initial{ background: var(--amber); color:#1c1503; }
.branch-row__left{ display:flex; align-items:center; gap:9px; }
.branch-row__initial{
  width:20px; height:20px; border-radius:5px;
  background: var(--surface-2);
  border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-mono); font-size:10px; font-weight:600;
  color: var(--text-dim);
}
.branch-row__count{ font-family: var(--font-mono); font-size:12px; color: var(--text-faint); }

.status-row{
  display:flex; align-items:center; justify-content:space-between;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor:pointer;
  font-size:13.5px;
  color: var(--text-dim);
}
.status-row:hover{ background: var(--surface-2); }
.status-row.is-active{ background: var(--surface-2); color: var(--text); }
.status-row__left{ display:flex; align-items:center; gap:9px; }
.status-row__swatch{ width:8px; height:8px; border-radius:2px; }
.status-row__count{ font-family: var(--font-mono); font-size:12px; color: var(--text-faint); }

.sidebar__foot{ margin-top:auto; padding: 16px 8px 4px; border-top:1px solid var(--border-soft); }
.sidebar__foot-row{ font-size:11.5px; color: var(--text-dim); }
.sidebar__foot-row.muted{ color: var(--text-faint); margin-top:2px; }

/* ---------- main column ---------- */
.main{ flex:1; min-width:0; display:flex; flex-direction:column; height:100vh; }

.topbar{
  display:flex; align-items:center; gap:18px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink:0;
}
.icon-btn{
  background: var(--surface); border:1px solid var(--border);
  color: var(--text-dim); width:36px; height:36px; border-radius: var(--radius-sm);
  display:none; align-items:center; justify-content:center; cursor:pointer;
}
.topbar__title h1{
  font-family: var(--font-display); font-weight:600; font-size: 26px;
  margin:0; letter-spacing:0.01em;
}
.topbar__title p{ margin:1px 0 0; font-size:12.5px; color: var(--text-faint); }

.topbar__search{
  flex:1; max-width: 380px;
  display:flex; align-items:center; gap:8px;
  background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
  color: var(--text-faint);
  margin-left: auto;
}
.topbar__search input{
  background:none; border:none; outline:none; color: var(--text);
  font-size:13.5px; width:100%; font-family: var(--font-body);
}
.topbar__search input::placeholder{ color: var(--text-faint); }

.btn{
  display:inline-flex; align-items:center; gap:7px;
  border-radius: var(--radius-sm); border:1px solid var(--border);
  padding: 9px 15px; font-size: 13.5px; font-weight:600; cursor:pointer;
  background: var(--surface); color: var(--text); white-space:nowrap;
}
.btn--primary{ background: var(--amber); color:#1c1503; border-color: var(--amber); }
.btn--primary:hover{ filter: brightness(1.06); }
.btn--secondary{ background: var(--surface-2); color: var(--text); border-color: var(--text-faint); }
.btn--secondary:hover{ background: rgba(255,255,255,0.04); }
.btn--danger{ background: var(--coral); color:#1c1503; border-color: var(--coral); }
.btn--danger:hover{ filter: brightness(1.06); }

.drawer__head-actions{ display:flex; align-items:center; gap:10px; }

.link-btn{
  background:none; border:none; color: var(--amber); font-size:13px; font-weight:600;
  cursor:pointer; padding:0;
}

.scroll-area{ flex:1; overflow-y:auto; padding: 22px 28px 40px; }

/* ---------- stat cards ---------- */
.stats{
  display:grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.stat-card{
  background: var(--surface);
  border:1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  position:relative;
  overflow:hidden;
}
.stat-card::before{
  content:'';
  position:absolute; left:0; top:0; bottom:0; width:3px;
  background: var(--accent, var(--text-faint));
}
.stat-card__label{
  font-size: 11px; letter-spacing:0.06em; text-transform:uppercase;
  color: var(--text-faint); font-weight:600;
}
.stat-card__value{
  font-family: var(--font-display); font-size: 30px; font-weight:600;
  margin-top: 4px; line-height:1;
}
.stat-card__sub{ font-size:11px; color: var(--text-faint); margin-top:5px; }

/* ---------- filter bar ---------- */
.filterbar{
  display:flex; align-items:center; gap:14px; flex-wrap:wrap;
  margin-bottom: 16px;
}
.filterbar__divider{ width:1px; height:22px; background: var(--border); }
.filterbar__spacer{ flex:1; }
.chipgroup{ display:flex; gap:7px; flex-wrap:wrap; }
.chip{
  border:1px solid var(--border); background: var(--surface);
  color: var(--text-dim); border-radius: 999px;
  padding: 6px 13px; font-size: 12.5px; font-weight:500; cursor:pointer;
  display:flex; align-items:center; gap:6px;
}
.chip:hover{ border-color: var(--text-faint); }
.chip.is-active{ background: var(--surface-2); color: var(--text); border-color: var(--text-dim); }
.chip__swatch{ width:7px; height:7px; border-radius:2px; }

/* Branch-specific styles */
.branch-andheri .branch-row__initial,
.chip.branch-andheri,
.branch-badge.branch-andheri,
.job-table td.branch-andheri { background: transparent; color: var(--branch-andheri); }
.branch-thane .branch-row__initial,
.chip.branch-thane,
.branch-badge.branch-thane,
.job-table td.branch-thane { background: transparent; color: var(--branch-thane); }
.branch-dadar .branch-row__initial,
.chip.branch-dadar,
.branch-badge.branch-dadar,
.job-table td.branch-dadar,
.job-table tbody tr.branch-dadar td.cell-jobno { background: transparent; color: var(--branch-dadar); }
.branch-vashi .branch-row__initial,
.chip.branch-vashi,
.branch-badge.branch-vashi,
.job-table td.branch-vashi,
.job-table tbody tr.branch-vashi td.cell-jobno { background: transparent; color: var(--branch-vashi); }

.branch-badge{ display:inline-flex; align-items:center; gap:8px; padding:4px 8px; border-radius:6px; font-weight:600; }
.job-table td.branch-andheri::before{ content:''; display:inline-block; width:8px; height:8px; background:var(--branch-andheri); margin-right:8px; border-radius:2px; }
.job-table td.branch-thane::before{ content:''; display:inline-block; width:8px; height:8px; background:var(--branch-thane); margin-right:8px; border-radius:2px; }
.job-table td.branch-dadar::before{ content:''; display:inline-block; width:8px; height:8px; background:var(--branch-dadar); margin-right:8px; border-radius:2px; }
.job-table td.branch-vashi::before{ content:''; display:inline-block; width:8px; height:8px; background:var(--branch-vashi); margin-right:8px; border-radius:2px; }

/* ---------- table ---------- */
.table-wrap{
  background: var(--surface);
  border:1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow:hidden;
}
.job-table{ width:100%; border-collapse:collapse; }
.job-table thead th{
  text-align:left;
  font-family: var(--font-display);
  font-size: 12px; letter-spacing:0.07em; text-transform:uppercase;
  color: var(--text-faint); font-weight:600;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.job-table tbody tr{
  border-bottom: 1px solid var(--border-soft);
  cursor:pointer;
}
.job-table tbody tr:last-child{ border-bottom:none; }
.job-table tbody tr:hover{ background: rgba(240,168,60,0.045); }
.job-table td{ padding: 13px 16px; font-size: 13.5px; vertical-align:top; }

.cell-jobno{ font-family: var(--font-mono); font-size:12.5px; color: var(--amber); }
.cell-jobno span{ display:block; font-family: var(--font-body); color: var(--text-faint); font-size:11px; margin-top:2px; }

.cell-customer strong{ display:block; font-weight:600; }
.cell-customer span{ display:block; color: var(--text-faint); font-size:11.5px; margin-top:2px; }

.cell-device strong{ display:block; font-weight:600; }
.cell-device span{ display:block; color: var(--text-faint); font-size:11.5px; margin-top:2px; font-family: var(--font-mono); }

.cell-date{ font-family: var(--font-mono); font-size:12.5px; color: var(--text-dim); white-space:nowrap; }
.cell-eta{ font-family: var(--font-mono); font-size:12.5px; color: var(--text-dim); white-space:nowrap; }
.align-right{ text-align:right; }

.stamp{
  display:inline-flex; align-items:center; gap:6px;
  padding: 4px 10px 4px 8px;
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 12px; font-weight:600; letter-spacing:0.05em; text-transform:uppercase;
  border: 1.5px solid currentColor;
  white-space:nowrap;
}
.stamp::before{ content:''; width:6px; height:6px; border-radius:50%; background:currentColor; }
.stamp--pending{ color: var(--amber); background: var(--amber-dim); }
.stamp--approved-pending{ color: #e7c76b; background: #3a3320; }
.stamp--approved{ color: var(--teal); background: var(--teal-dim); }
.stamp--closed{ color: var(--slate); background: var(--slate-dim); }
.stamp--rejected{ color: var(--coral); background: var(--coral-dim); }

.empty-state{
  display:flex; flex-direction:column; align-items:center; gap:8px;
  padding: 60px 20px; color: var(--text-faint);
}
.empty-state p{ margin:0; font-size:13.5px; }

/* ---------- new job form ---------- */
.modal-backdrop{
  position:fixed; inset:0; background: rgba(10,12,14,0.65);
  opacity:0; pointer-events:none; transition: opacity .18s ease;
  z-index: 60;
}
.modal-backdrop.is-open{ opacity:1; pointer-events:auto; }

.job-form-modal{
  position:fixed; top:50%; left:50%; width:min(460px, 92vw);
  transform: translate(-50%, -50%) scale(.96);
  background: var(--surface);
  border:1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  opacity:0; pointer-events:none; transition: all .22s ease;
  z-index: 61;
}
.job-form-modal.is-open{ opacity:1; pointer-events:auto; transform: translate(-50%, -50%) scale(1); }

.job-form-modal__head{
  display:flex; align-items:flex-start; justify-content:space-between;
  gap:12px; padding: 20px 22px 12px; border-bottom: 1px solid var(--border-soft);
}
.job-form-modal__eyebrow{
  font-family: var(--font-mono); font-size:11px; color: var(--amber);
  letter-spacing:0.06em; margin:0 0 4px; text-transform:uppercase;
}
.job-form-modal__head h3{ margin:0; font-family: var(--font-display); font-size:22px; font-weight:600; }
.job-form-modal__close{ display:flex; }

.job-form{ display:grid; gap:14px; padding: 18px 22px 22px; }
.field{ display:flex; flex-direction:column; gap:6px; }
.field span{ font-size:12px; font-weight:600; color: var(--text-dim); }
.field input, .field select{
  background: var(--surface-2); border:1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size:13.5px;
}
.field input:focus, .field select:focus{ outline:none; border-color: var(--amber); }

.job-form__actions{ display:flex; justify-content:flex-end; gap:10px; margin-top:6px; }

/* ---------- drawer ---------- */
.drawer-backdrop{
  position:fixed; inset:0; background: rgba(10,12,14,0.55);
  opacity:0; pointer-events:none; transition: opacity .18s ease;
  z-index: 40;
}
.drawer-backdrop.is-open{ opacity:1; pointer-events:auto; }

.drawer{
  position:fixed; top:0; right:0; height:100vh; width: 440px; max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform .22s cubic-bezier(.2,.8,.2,1);
  z-index: 41;
  display:flex; flex-direction:column;
}
.drawer.is-open{ transform: translateX(0); }

.drawer__head{
  display:flex; align-items:flex-start; justify-content:space-between;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.drawer__eyebrow{
  font-family: var(--font-mono); font-size:11px; color: var(--amber);
  letter-spacing:0.06em; margin:0 0 4px;
}
.drawer__head h2{ margin:0; font-family: var(--font-display); font-size:22px; font-weight:600; }

.drawer__body{ padding: 18px 22px 30px; overflow-y:auto; flex:1; }

.dgroup{ margin-bottom: 22px; }
.dgroup__title{
  font-family: var(--font-display); font-size:12px; letter-spacing:0.1em;
  text-transform:uppercase; color: var(--text-faint); margin: 0 0 10px;
  padding-bottom:7px; border-bottom: 1px dashed var(--border);
}
.dgrid{ display:grid; grid-template-columns: 1fr 1fr; gap: 11px 14px; }
.dfield{ min-width:0; }
.dfield__label{ font-size:10.5px; color: var(--text-faint); text-transform:uppercase; letter-spacing:0.05em; }
.dfield__value{ font-size:13.5px; margin-top:2px; word-break:break-word; }
.dfield__value.mono{ font-family: var(--font-mono); font-size:12.5px; }
.dfield--full{ grid-column: 1 / -1; }

.dnote{
  background: var(--surface-2); border:1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 11px 13px;
  font-size: 12.5px; color: var(--text-dim); line-height:1.5;
}
.dnote strong{ color: var(--text); }

.dcost{ display:flex; gap:12px; }
.dcost__box{
  flex:1; background: var(--surface-2); border:1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.dcost__box .dfield__label{ margin-bottom:3px; }
.dcost__box .dfield__value{ font-family: var(--font-mono); font-size:17px; font-weight:600; }

/* ---------- responsive ---------- */
@media (max-width: 1100px){
  .stats{ grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px){
  .sidebar{
    position:fixed; z-index:50; left:0; top:0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 20px 0 40px rgba(0,0,0,0.4);
  }
  .sidebar.is-open{ transform: translateX(0); }
  .icon-btn{ display:flex; }
  .topbar__search{ display:none; }
  .job-table thead{ display:none; }
  .job-table, .job-table tbody, .job-table tr, .job-table td{ display:block; width:100%; }
  .job-table tr{ padding: 12px 16px; }
  .job-table td{ padding: 3px 0; border:none; }
  .cell-cost{ text-align:left; }
}
@media (max-width: 560px){
  .stats{ grid-template-columns: repeat(2, 1fr); }
  .topbar{ padding: 14px 16px; }
  .scroll-area{ padding: 16px 16px 40px; }
}

@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; }
}

/* ---------- loading / error toast ---------- */
.api-toast{
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.api-toast.is-visible{ opacity:1; transform: translateX(-50%) translateY(0); }
.api-toast.is-error{ border-color: var(--coral); color: var(--coral); }
