/* ==========================================================================
   Admin Shell & Navigation
   ========================================================================== */

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px 1fr;
  background: var(--paper);
  transition: grid-template-columns 0.18s ease;
}

/* Sidebar collapse toggle */
.sidebar-toggle {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-toggle:hover {
  background: var(--sky);
  color: var(--navy);
}

.sidebar-toggle:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Collapsed state (desktop only) */
@media (min-width: 901px) {
  html.sidebar-collapsed .admin-shell {
    grid-template-columns: 76px 1fr;
  }
  /* Let the hover tooltips escape the rail */
  html.sidebar-collapsed .sidebar {
    overflow: visible;
  }
  html.sidebar-collapsed .brand-partners,
  html.sidebar-collapsed .brand-text,
  html.sidebar-collapsed .sidebar-section-label,
  html.sidebar-collapsed .nav-label,
  html.sidebar-collapsed .user-info,
  html.sidebar-collapsed .logout-btn span {
    display: none;
  }
  html.sidebar-collapsed .brand-logo-wrap {
    justify-content: center;
  }
  html.sidebar-collapsed .sidebar-brand {
    padding-bottom: 0.8rem;
    margin-bottom: 0.8rem;
  }
  html.sidebar-collapsed .nav-link,
  html.sidebar-collapsed .nav-children .nav-link {
    justify-content: center;
    gap: 0;
    padding-inline: 0;
  }
  html.sidebar-collapsed .nav-caret { display: none; }
  html.sidebar-collapsed .nav-children {
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
  }
  html.sidebar-collapsed .user-card,
  html.sidebar-collapsed .logout-btn {
    justify-content: center;
    padding-inline: 0;
  }
  html.sidebar-collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
  }

  /* Name shown as a tooltip to the right of each icon */
  html.sidebar-collapsed .nav-link::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 0.65rem);
    top: 50%;
    transform: translateY(-50%);
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    background: var(--navy);
    color: #ffffff;
    font-size: var(--fs-xs);
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease;
    box-shadow: 0 10px 24px -12px rgb(18 40 110 / 0.8);
    z-index: 60;
  }
  html.sidebar-collapsed .nav-link:hover::after,
  html.sidebar-collapsed .nav-link:focus-visible::after {
    opacity: 1;
    visibility: visible;
  }
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem 1.25rem;
  background: #ffffff;
  border-right: 1px solid var(--line);
  color: var(--text);
  position: sticky;
  top: 0;
  height: 100vh;
  box-sizing: border-box;
  overflow-y: auto;
}

/* Brand */
.sidebar-brand {
  padding: 0 0.25rem 1.1rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.1rem;
}

.brand-partners {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.9rem;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1px solid var(--line);
}

.partner-logo {
  display: block;
  width: auto;
  object-fit: contain;
}

.partner-otrivin {
  height: 30px;
}

.partner-tv9 {
  height: 34px;
}

.partner-divider {
  width: 1px;
  height: 28px;
  background: var(--line);
  flex-shrink: 0;
}

.brand-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.brand-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--navy);
}

.sidebar-section-label {
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding: 0 0.85rem 0.6rem;
  text-transform: uppercase;
}

/* Nav links */
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding: 0.6rem 0.95rem;
  border-radius: var(--radius-full);
  color: var(--muted);
  text-decoration: none;
  font-size: var(--fs-md);
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}

.nav-link:hover {
  background: var(--sky);
  color: var(--navy);
}

.nav-link:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.nav-link.active {
  background: var(--navy);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 8px 18px -10px rgb(18 40 110 / 0.7);
}

.nav-link.active:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.nav-link.active .nav-icon {
  color: #ffffff;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  color: inherit;
  flex-shrink: 0;
}

.nav-label {
  flex: 1;
}

.nav-parent { cursor: pointer; }

.nav-caret {
  display: grid;
  place-items: center;
  margin-left: auto;
  color: currentColor;
  transition: transform 0.15s ease;
}

.nav-parent.is-open .nav-caret { transform: rotate(180deg); }

.nav-children {
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0.1rem 0 0.25rem 1.6rem;
  padding-left: 0.6rem;
  border-left: 1px solid var(--line);
}

.nav-parent.is-open + .nav-children { display: flex; }

.nav-children .nav-link {
  min-height: 2.4rem;
  font-size: var(--fs-base);
  align-items: center;
}

.nav-children .nav-label {
  white-space: normal;
  line-height: 1.3;
}

/* Sidebar Footer & User info */
.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-md);
  background: var(--sky);
  text-decoration: none;
  color: inherit;
}

a.user-card:hover,
a.user-card.is-on {
  background: #e7eefc;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(15rem, 19rem) minmax(0, 40rem);
  gap: 1.25rem;
  align-items: start;
}

.profile-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.75rem 1.5rem 1.5rem;
  text-align: center;
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  margin-bottom: 0.85rem;
  border-radius: 50%;
  background: var(--navy);
  color: #ffffff;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.profile-name {
  margin: 0;
  font-size: var(--fs-xl);
  text-transform: capitalize;
}

.profile-role {
  margin-top: 0.4rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--sky);
  color: var(--accent);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-meta {
  width: 100%;
  margin: 1.25rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  text-align: left;
}

.profile-meta > div + div {
  margin-top: 0.75rem;
}

.profile-meta dt {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.profile-meta dd {
  margin: 0.15rem 0 0;
  color: var(--navy);
  font-size: var(--fs-base);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.profile-tip {
  margin: 1.1rem 0 0;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--line-light);
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: 1.5;
  text-align: left;
}

.profile-card {
  padding: 1.4rem 1.5rem 1.5rem;
}

.profile-section {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.profile-section + .profile-section {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

/* Floated so the legend sits below the divider instead of cutting through it */
.profile-section legend {
  float: left;
  width: 100%;
  margin-bottom: 0.6rem;
  padding: 0;
  color: var(--navy);
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
}

.profile-section > legend + * {
  clear: both;
}

.profile-hint {
  margin: -0.2rem 0 0.75rem;
  color: var(--muted);
  font-size: var(--fs-xs);
}

.profile-section .field,
.profile-verify .field {
  margin: 0;
}

.match-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: var(--fs-xs);
  font-weight: 600;
}

.match-hint.ok { color: var(--accent-emerald-dark); }
.match-hint.bad { color: var(--danger); }

.profile-verify {
  margin-top: 1.25rem;
  padding: 0.95rem 1rem 1rem;
  border: 1px dashed var(--accent-border);
  border-radius: var(--radius-md);
  background: var(--accent-light);
}

.profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

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

.confirm-list {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  text-align: left;
  color: var(--ink);
}

#profile-result {
  width: min(28rem, calc(100% - 2rem));
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--navy);
  color: #ffffff;
  font-size: var(--fs-xs);
  font-weight: 700;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: var(--fs-xs);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-form {
  margin: 0;
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 2.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--ink-secondary);
  border: 1px solid var(--line);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.logout-btn:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger-border);
}

.logout-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* ==========================================================================
   Workspace Area
   ========================================================================== */

.workspace {
  padding: 2.25rem 2.75rem 3rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.workspace-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.workspace h1 {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.02em;
}

.workspace .lede {
  margin: 0.4rem 0 0;
  max-width: 46rem;
  color: var(--muted);
  font-size: var(--fs-md);
  line-height: 1.6;
}

/* Stat KPI Cards */
.stats-grid {
  display: grid;
  /* Cards share the full row width */
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.15rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-xs);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

a.stat-card {
  color: inherit;
  text-decoration: none;
  border-color: var(--accent-border);
  background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
}

a.stat-card:hover {
  border-color: var(--accent);
}

a.stat-card:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

button.stat-card {
  width: 100%;
  margin: 0;
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

button.stat-card:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 2.85rem;
  height: 2.85rem;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.stat-icon.emerald {
  background: var(--sky);
  color: var(--accent);
}

.stat-icon.teal {
  background: var(--navy);
  color: #ffffff;
}

.stat-icon.saffron {
  background: var(--saffron-light);
  color: var(--saffron);
}

.stat-icon.blue {
  background: var(--accent-emerald-light);
  color: var(--accent-emerald);
}

.stat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}

.stat-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

.stat-hint {
  margin-top: 0.2rem;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--accent);
}

/* Controls bar */
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.search-box {
  position: relative;
  max-width: 380px;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-light);
  pointer-events: none;
  display: grid;
  place-items: center;
}

.result-count {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
}

/* ==========================================================================
   Table Card
   ========================================================================== */

.panel-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  padding: 0.85rem 0.75rem;
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy);
  background: var(--sky);
  border-bottom: 1px solid var(--line);
}

td {
  padding: 0.95rem 0.75rem;
  border-top: 1px solid var(--line);
  vertical-align: middle;
  font-size: var(--fs-base);
  color: var(--text);
}

tr:hover td {
  background: #f8faff;
}

/* Driver column styling */
.driver-cell {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.driver-avatar {
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 50%;
  background: var(--navy);
  color: #ffffff;
  font-weight: 700;
  font-size: var(--fs-sm);
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.driver-meta {
  display: flex;
  flex-direction: column;
}

.driver-name {
  font-weight: 600;
  color: var(--navy);
}

.driver-badge {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
}

/* Contact column styling */
.contact-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.contact-email {
  color: var(--ink-secondary);
}

.contact-phone,
.contact-pin {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--fs-sm);
  color: var(--muted);
  font-family: var(--font-mono);
}

.contact-pin {
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.08em;
}

/* Vehicle plate: plain text that matches the PIN line */
/* Pincode in the Nominations table uses the same look */
.plate-text,
.code-text {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--navy);
  text-transform: uppercase;
  white-space: nowrap;
}

td.plate-cell {
  white-space: nowrap;
}

/* Status Pill */
.area-name-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.stop-legend {
  display: flex;
  gap: 1rem;
  margin: -0.6rem 0 1rem;
  padding: 0;
  list-style: none;
  font-size: var(--fs-xs);
  font-weight: 700;
}

.stop-legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.stop-legend li:first-child { color: var(--saffron); }

.stop-legend li:last-child { color: var(--accent-emerald); }

.stop-fact {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.4;
}

.stop-fact + .stop-fact { margin-top: 0.12rem; }

.stop-fact.scheduled { color: var(--saffron); }

.stop-fact.marked { color: var(--accent-emerald-dark, #0f6e48); }

.stop-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  flex-shrink: 0;
  transform: translateY(0.05rem);
}

.stop-dot.scheduled { background: var(--saffron); }

.stop-dot.marked { background: var(--accent-emerald); }

td.code .stop-fact-value { font-family: var(--font-mono); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  font-size: var(--fs-2xs);
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}

.status-pill.active {
  background: var(--accent-emerald-light);
  color: #0f6e48;
  border: 1px solid #bfe5d1;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Date cell */
.date-cell {
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* Row Actions */
.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  white-space: nowrap;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.1rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink-secondary);
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: var(--sky);
  border-color: var(--accent-border);
  color: var(--navy);
}

.action-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.action-btn.delete {
  color: var(--danger);
  border-color: var(--danger-border);
}

.action-btn.delete:hover {
  background: var(--danger-light);
  border-color: var(--danger);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
  text-align: center;
}

.empty-state-icon {
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: var(--sky);
  color: var(--accent);
  margin-bottom: 1.25rem;
}

.empty-state-title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.4rem;
}

.empty-state-text {
  font-size: var(--fs-md);
  color: var(--muted);
  max-width: 32rem;
  margin-bottom: 1.25rem;
}

/* Pager */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.pager-info {
  font-size: var(--fs-base);
  color: var(--muted);
  font-weight: 500;
}

.pager-actions {
  display: flex;
  gap: 0.5rem;
}

/* ==========================================================================
   Modal Dialogs
   ========================================================================== */

dialog {
  width: min(760px, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  color: var(--text);
  background: #ffffff;
  box-shadow: var(--shadow-modal);
  margin: auto;
  position: fixed;
  inset: 0;
  box-sizing: border-box;
}

dialog::backdrop {
  background: rgb(12 28 82 / 0.5);
  backdrop-filter: blur(4px);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}

.dialog-title-wrap {
  display: flex;
  flex-direction: column;
}

.dialog-head h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--navy);
}

.dialog-desc {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-top: 0.2rem;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.day-field { position: relative; }

.day-field-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  border: 1px solid var(--line);
  background: white;
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-size: var(--fs-md);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.day-field-btn svg { flex: none; color: var(--muted); }

.day-calendar {
  margin-top: 0.45rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.day-calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.day-calendar-head strong {
  font-size: var(--fs-sm);
  color: var(--navy);
}

.day-calendar-nav,
.day-cell {
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.day-calendar-nav {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  color: var(--navy);
  font-size: 1.15rem;
  line-height: 1;
}

.day-calendar-nav:hover,
.day-cell:hover { background: var(--sky); }

.day-calendar-week,
.day-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.12rem;
  text-align: center;
}

.day-calendar-week span {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0.15rem 0 0.3rem;
}

.day-cell {
  height: 2rem;
  border-radius: 999px;
  color: var(--text);
  font-size: var(--fs-sm);
}

.day-cell.is-outside { color: #b0b7c6; }

.day-cell.is-past,
.day-cell:disabled,
.day-cell.is-past:hover,
.day-cell:disabled:hover,
.day-calendar-nav:disabled,
.day-calendar-nav:disabled:hover {
  color: #c5cad3;
  background: transparent;
  cursor: not-allowed;
}

.day-cell.is-today { box-shadow: inset 0 0 0 1.5px var(--accent); }

.pin-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  grid-column: 1 / -1;
  margin: 0.35rem 0 0.2rem;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.pin-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: pin-spin 0.7s linear infinite;
}

@keyframes pin-spin { to { transform: rotate(360deg); } }

.day-cell.is-on,
.day-cell.is-on:hover {
  background: var(--accent);
  color: #ffffff;
}

.phone-group {
  display: flex;
  gap: 0.5rem;
}

.phone-group select {
  width: 7.25rem;
  flex: 0 0 7.25rem;
  padding-left: 0.65rem;
  padding-right: 0.4rem;
}

.phone-group input {
  flex: 1;
  min-width: 0;
}

.plate-input {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.required {
  color: var(--danger);
}

/* Delete confirmation specific */
.delete-dialog-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.5rem 0;
}

.delete-dialog-icon {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--danger-light);
  color: var(--danger);
  margin-bottom: 1rem;
}

.delete-dialog-content h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.delete-target-pill {
  display: inline-block;
  background: var(--line-light);
  border: 1px solid var(--line);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--ink);
  margin: 0.5rem 0 1rem;
}

.assign-panel { padding: 1.35rem 1.4rem 1.4rem; margin-bottom: 1.25rem; }

.assign-panel h2 {
  margin: 0 0 0.9rem;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--navy);
}

.assign-toolbar {
  display: grid;
  grid-template-columns: minmax(14rem, 0.7fr) 1.3fr;
  gap: 0.8rem;
}

.assign-toolbar .field { margin-bottom: 0.6rem; }

select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-size: var(--fs-md);
  color: var(--text);
}

.filter-row { display: flex; gap: 0.45rem; margin: 0.2rem 0 0.9rem; }

.filter-row .btn.is-on {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.result-group {
  display: flex;
  flex-direction: column;
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #ffffff;
  overflow: hidden;
}

.result-group > .result-row {
  border: 0;
  border-radius: 0;
}

.result-group:has(input:checked) { border-color: var(--accent); }

.locality-panel:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
  gap: 0.35rem 0.75rem;
  padding: 0.7rem 0.85rem 0.85rem;
  background: #f4f7fb;
  border-top: 1px solid var(--line);
}

.locality-choice {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  margin: 0;
  padding: 0.28rem 0.35rem;
  border-radius: 0.4rem;
  color: var(--navy);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}

.locality-choice:hover { background: #ffffff; }

.locality-choice input {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
}

.locality-choice span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.locality-choice.is-assigned {
  color: var(--navy);
  cursor: default;
}

.locality-choice.is-assigned .status-pill { margin-left: auto; }

.result-row.is-assigned .status-pill,
.result-row.is-assigned .icon-btn { flex-shrink: 0; }

#search-results label.result-row.is-assigned:has(input:checked)::after { content: none; }

#search-results .result-row { flex-wrap: wrap; }
#search-results .result-row.is-assigned .result-copy,
#search-results label.result-row .result-copy { flex-basis: auto; }

.pin-counts {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-left: auto;
}

.pin-count {
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--line-light);
  color: var(--navy);
  font-size: max(var(--fs-xs), 11px);
  font-weight: 700;
  white-space: nowrap;
}

.pin-count.pending {
  background: var(--saffron-light);
  color: var(--saffron);
}

.pin-count.completed {
  background: var(--accent-emerald-light);
  color: #0f6e48;
}

.locality-choice .result-mark { width: 1rem; height: 1rem; }

.result-row.is-child { margin-left: 1.75rem; }

#pincode-rows tr.is-child { background: #f6f8fb; }

#pincode-rows tr.is-child td:first-child .area-name-line { padding-left: 1.15rem; }

.result-list {
  display: grid;
  /* Cards in columns: 2 in the dialog, 3–4 on laptops, 5 on wide screens, 1 on phones */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  align-content: start;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Status label sits under the area name so narrow cards keep the name readable */
.result-row.is-assigned,
label.result-row:has(input:checked) { flex-wrap: wrap; row-gap: 0.4rem; }
.result-row.is-assigned .result-copy,
label.result-row:has(input:checked) .result-copy { flex-basis: calc(100% - 2.2rem); }
.result-badge { margin-left: calc(1.15rem + 0.8rem); }
label.result-row:has(input:checked)::after { margin-left: calc(1.05rem + 0.8rem); }

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #ffffff;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.result-row:hover {
  border-color: var(--accent-border);
  background: #f8faff;
}

.result-row input { flex-shrink: 0; width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--accent); cursor: pointer; }

label.result-row { cursor: pointer; }

.result-row input:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
  box-shadow: none;
}

label.result-row:has(input:focus-visible) { border-color: var(--accent); }

/* Ticked, about to be assigned */
.result-row:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* Text cue as well as colour, so selected never relies on blue alone */
label.result-row:has(input:checked)::after {
  content: 'Selected';
  flex-shrink: 0;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--accent-border);
  background: #ffffff;
  color: var(--accent);
  font-size: max(var(--fs-xs), 11px);
  font-weight: 700;
  white-space: nowrap;
}

/* Already assigned for the selected day: read-only, green */
.result-row.is-assigned,
.result-row.is-assigned:hover {
  border-color: var(--accent-emerald-border);
  background: var(--accent-emerald-light);
  cursor: default;
}

.result-mark {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--accent-emerald);
  color: #ffffff;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--accent-emerald-border);
  background: #ffffff;
  color: var(--accent-emerald-dark);
  font-size: max(var(--fs-xs), 11px);
  font-weight: 700;
  white-space: nowrap;
}

.result-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.6rem;
  font-size: max(var(--fs-xs), 11px);
  font-weight: 600;
  color: var(--muted);
}

.result-summary span {
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  background: var(--line-light);
}

.result-summary .summary-assigned { background: var(--accent-emerald-light); color: var(--accent-emerald-dark); }
.result-summary .summary-selected { background: var(--accent-light); color: var(--accent); }

.result-copy { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.1rem 0.5rem; flex: 1; }

.result-copy small,
.result-copy em { color: var(--muted); font-style: normal; font-size: var(--fs-base); }

.result-row .btn { padding: 0.45rem 0.8rem; }

/* Responsive */
@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    padding: 0.9rem 0.85rem;
  }
  .sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: 0.8rem;
    margin-bottom: 0.8rem;
  }
  .brand-partners {
    margin-bottom: 0;
    padding: 0.4rem 0.6rem;
    gap: 0.6rem;
  }
  .partner-otrivin { height: 22px; }
  .partner-tv9 { height: 26px; }
  .partner-divider { height: 22px; }
  .brand-text { flex-direction: column; align-items: flex-end; gap: 0.2rem; }
  .sidebar-section-label { display: none; }
  .side-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .nav-parent.is-open + .nav-children {
    display: contents;
  }
  .nav-link,
  .nav-children .nav-link {
    min-height: 2.5rem;
    padding: 0.5rem 0.85rem;
    font-size: var(--fs-base);
  }
  .sidebar-footer {
    flex-direction: row;
    align-items: center;
    margin-top: 0.8rem;
    padding-top: 0.8rem;
  }
  .user-card { flex: 1; min-width: 0; padding: 0.4rem 0.55rem; }
  .logout-btn { width: auto; }
  .workspace {
    padding: 1.5rem 1rem;
  }
  .workspace-head {
    flex-direction: column;
    align-items: stretch;
  }
  .pair {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  }
  .controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    max-width: 100%;
  }
  .assign-toolbar { grid-template-columns: 1fr; }
}


/* ==========================================================================
   DataTables Modern Theme Customization
   ========================================================================== */

.dataTables_wrapper {
  padding: 1.25rem 1.25rem 1rem;
  font-family: var(--font-sans);
  color: var(--ink);
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
  margin-bottom: 1.15rem;
}

.dataTables_wrapper .dataTables_length {
  float: left;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--ink-secondary);
}

.dataTables_wrapper .dataTables_length select {
  width: auto;
  display: inline-block;
  padding: 0.4rem 1.75rem 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #ffffff;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0.4rem;
  cursor: pointer;
}

.dataTables_wrapper .dataTables_filter {
  float: right;
  text-align: right;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--ink-secondary);
}

.dataTables_wrapper::after {
  content: "";
  display: table;
  clear: both;
}

table.dataTable {
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 0.75rem 0 1.25rem !important;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

table.dataTable thead th {
  padding: 0.85rem 0.75rem !important;
  font-size: var(--fs-2xs) !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  color: var(--navy) !important;
  background: var(--sky) !important;
  border-bottom: 1px solid var(--line) !important;
  position: relative;
  cursor: pointer;
  user-select: none;
}

table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
  padding-right: 1.75rem !important;
}

table.dataTable thead th.no-sort {
  cursor: default !important;
}

table.dataTable thead th.sorting:after,
table.dataTable thead th.sorting_asc:after,
table.dataTable thead th.sorting_desc:after {
  position: absolute;
  bottom: 0.85rem;
  right: 0.6rem;
  display: block;
  font-family: inherit;
  opacity: 0.4;
  font-size: var(--fs-xs);
}

table.dataTable thead th.sorting_asc:after {
  content: "▲";
  opacity: 0.9;
  color: var(--accent);
}

table.dataTable thead th.sorting_desc:after {
  content: "▼";
  opacity: 0.9;
  color: var(--accent);
}

table.dataTable tbody td {
  padding: 0.95rem 0.75rem !important;
  border-top: 1px solid var(--line) !important;
  border-bottom: none !important;
  vertical-align: middle !important;
  font-size: var(--fs-base) !important;
}

table.dataTable.no-footer {
  border-bottom: 1px solid var(--line) !important;
}

.dataTables_wrapper .dataTables_info {
  float: left;
  padding: 0.75rem 0 !important;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--muted);
}

.dataTables_wrapper .dataTables_paginate {
  float: right;
  text-align: right;
  padding: 0.5rem 0 !important;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 2rem !important;
  height: 2rem !important;
  padding: 0 0.65rem !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--line) !important;
  background: #ffffff !important;
  color: var(--ink-secondary) !important;
  font-size: var(--fs-sm) !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  margin: 0 !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--sky) !important;
  border-color: var(--accent-border) !important;
  color: var(--navy) !important;
}

/* Doubled class beats the vendor DataTables rule (loaded later) that forces color: inherit. */
.dataTables_wrapper.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--navy) !important;
  color: #ffffff !important;
  border-color: var(--navy) !important;
  box-shadow: var(--shadow-xs);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  opacity: 0.4 !important;
  cursor: not-allowed !important;
  background: transparent !important;
  border-color: var(--line) !important;
}

@media (max-width: 768px) {
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    float: none !important;
    text-align: left !important;
    margin-bottom: 0.75rem;
  }
}

/* Localities Column & Badges in Table */
.locality-col {
  max-width: 320px;
  min-width: 220px;
}

.locality-header {
  display: flex;
  align-items: center;
  /* Count badge, then the Manage button right beside it */
  justify-content: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.locality-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--sky);
  color: var(--navy);
  border: 1px solid var(--accent-border);
  font-size: var(--fs-2xs);
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

.locality-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.locality-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--line-light);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 0.15rem 0.45rem;
  font-size: var(--fs-xs);
  color: var(--text);
  line-height: 1.2;
}

.locality-more-tag {
  background: #ffffff;
  border: 1px dashed var(--accent-border);
  border-radius: var(--radius-xs);
  padding: 0.15rem 0.45rem;
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.15s ease;
}

.locality-more-tag:hover {
  background: var(--sky);
  border-color: var(--accent);
}

.locality-empty-hint {
  font-size: var(--fs-sm);
  color: var(--muted);
  font-style: italic;
}

/* Localities Management Dialog */
#localities-dialog {
  max-width: 960px;
  width: calc(100% - 2rem);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  background: #ffffff;
}

.loc-dialog-grid {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  margin-top: 1rem;
}

.loc-add-box {
  background: var(--sky);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.loc-add-title {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.loc-add-fields {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  align-items: flex-end;
}

@media (max-width: 600px) {
  .loc-add-fields {
    grid-template-columns: 1fr;
  }
}

.loc-list-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.loc-count-badge {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-secondary);
  white-space: nowrap;
}

.loc-items-container {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.loc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.loc-table th {
  position: sticky;
  top: 0;
  background: var(--sky);
  padding: 0.6rem 0.85rem;
  font-weight: 700;
  color: var(--navy);
  border-bottom: 1px solid var(--line);
  text-align: left;
  z-index: 2;
}

.loc-table td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--line-subtle);
  vertical-align: middle;
}

.loc-table tr:last-child td {
  border-bottom: none;
}

.loc-table tr:hover {
  background: #f8faff;
}

/* Localities builder in Pincode Form */
.form-localities-section {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  margin-top: 0.75rem;
}

.form-localities-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.form-localities-head h4 {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.form-localities-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
  max-height: 120px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.form-loc-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--sky);
  border: 1px solid var(--accent-border);
  color: var(--navy);
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
}

.form-loc-pill button {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: var(--fs-md);
  line-height: 1;
  padding: 0;
  margin-left: 0.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.form-loc-pill button:hover {
  color: var(--danger);
}

/* Bilingual (English / Hindi) cells */
.bilingual {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.bilingual strong {
  font-weight: 600;
  color: var(--navy);
}

/* drivers.js puts these classes on <td>; keep them table cells so columns line up with headers */
td.driver-cell,
td.contact-cell,
td.row-actions {
  display: table-cell;
}

td.driver-cell {
  white-space: nowrap;
}

td.driver-cell > .driver-avatar {
  display: inline-grid;
  vertical-align: middle;
  margin-right: 0.75rem;
}

td.driver-cell > .driver-meta {
  display: inline-flex;
  vertical-align: middle;
}

td.contact-cell > * + * {
  margin-top: 0.2rem;
}

td.row-actions {
  text-align: right;
  white-space: nowrap;
}

td.row-actions > * + * {
  margin-left: 0.4rem;
}

td.contact-cell {
  overflow-wrap: break-word;
}

td.contact-cell .contact-phone {
  white-space: nowrap;
}

/* Every table button (View, Assign, Manage, edit, delete) shares one fixed height */
td .action-btn {
  height: 2.25rem;
  min-height: 2.25rem;
  padding: 0 0.6rem;
  line-height: 1;
  vertical-align: middle;
  justify-content: center;
}

td .action-btn.icon-only {
  width: 2.25rem;
  padding: 0;
}

/* Drivers has three actions per row: let them wrap rather than push the table past its card */
#drivers-table td.row-actions {
  white-space: normal;
}

#drivers-table td.row-actions > * {
  margin: 0.2rem 0 0.2rem 0.4rem;
  white-space: nowrap;
}

/* Icon-only row actions (edit / remove) */
.icon-only {
  width: 2.25rem;
  height: 2.25rem;
  min-height: 2.25rem;
  padding: 0 !important;
  justify-content: center;
  flex-shrink: 0;
}

.btn.icon-only {
  box-shadow: var(--shadow-xs);
}

/* Delete confirmations stay compact */
#delete-dialog {
  width: min(560px, calc(100% - 2rem));
}

/* One style for every search field (page filters, table search, dialog search) */
.workspace input[type="search"],
dialog input[type="search"],
.workspace .dataTables_wrapper .dataTables_filter input {
  width: 100%;
  height: 2.75rem;
  margin: 0;
  padding: 0 1rem 0 2.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7385' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 1rem center / 16px 16px;
  box-shadow: var(--shadow-xs);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.workspace input[type="search"]:focus,
dialog input[type="search"]:focus,
.workspace .dataTables_wrapper .dataTables_filter input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.workspace .dataTables_wrapper .dataTables_filter input {
  width: 18rem;
}

.search-box .search-icon {
  display: none;
}

/* Tracking Page & Activity View */
.tracking-driver-name {
  margin: 0.35rem 0 0;
  line-height: 1.2;
}

.tracking-header-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.tracking-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-xs);
}

.tracking-date-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.tracking-date-group label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.tracking-date-group input[type="date"] {
  width: auto;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  font-family: inherit;
}

.tracking-status-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.tracking-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.tracking-pill.live {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.tracking-pill.offline {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.tracking-pill.on-duty {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.tracking-pill.on-break {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.tracking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.tracking-dot.pulse {
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.4; }
  100% { transform: scale(0.9); opacity: 1; }
}

.map-card {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-xs);
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.map-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.map-legend {
  display: flex;
  gap: 0.85rem;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
}

.map-legend i {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.28rem;
  border-radius: 50%;
  vertical-align: middle;
}

.legend-start { background: #0f6e48; }
.legend-driver { background: #1a4fd6; }
.legend-end { background: #c2410c; }

#driver-map {
  height: 380px;
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  z-index: 1;
}

.map-no-coords {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 220px;
  background: #f8fafc;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
}

.view-btn {
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
  background: var(--accent-light) !important;
}

.view-btn:hover {
  background: var(--accent) !important;
  color: #ffffff !important;
  border-color: var(--accent) !important;
}

/* ==========================================================================
   Survey Builder Styles
   ========================================================================== */
.builder-section {
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.question-builder-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.question-builder-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.question-builder-card.is-locked {
  border-color: #99f6e4;
}

.locked-label {
  margin: 0.35rem 0 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--ink);
  font-weight: 700;
}

.q-lock-note {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.q-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.q-card-title-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.q-badge {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink);
  background: #ffffff;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.q-required-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.q-required-toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.q-card-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.q-card-body {
  padding: 1.25rem;
}

.options-wrapper {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.options-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.opt-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}

.opt-marker {
  font-size: 1rem;
  color: var(--muted);
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.opt-icon-wrap {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex: 0 0 auto;
}

.opt-icon-emoji {
  width: 3.2rem;
  flex: 0 0 3.2rem;
  text-align: center;
  font-size: 1.25rem;
  padding: 0.35rem 0.2rem;
}

.opt-icon-thumb,
.preview-choice-icon img,
img.preview-choice-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.opt-icon-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  cursor: pointer;
}

.opt-icon-upload:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.opt-icon-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.15rem 0 0.75rem;
}

.opt-icon-choice {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}

.opt-icon-choice:hover {
  border-color: var(--accent);
  background: #f5f3ff;
}

.preview-choice-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.opt-text-en, .opt-text-hi {
  padding: 0.5rem 0.75rem;
  font-size: 0.88rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  flex: 1;
  min-width: 9rem;
}

.field-hi {
  margin-top: 0.4rem;
}

.q-prompt-hi,
.q-hint-hi,
.opt-text-hi {
  font-family: "Noto Sans Devanagari", "Nirmala UI", sans-serif;
}

.choice-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  margin-top: 0.85rem;
}

.choice-rules label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.choice-rules input,
.choice-rules select {
  width: auto;
  min-width: 5rem;
}

.hi-line,
.preview-hint {
  color: var(--muted);
  font-weight: 500;
}

.preview-hint {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
}

.preview-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.preview-chips .preview-choice-label {
  width: auto;
  margin: 0;
}

.preview-callout {
  padding: 0.85rem 1rem;
  background: var(--line-light);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
}

/* Callout title, then a short muted note */
.preview-callout > span:first-child {
  display: block;
  color: var(--navy);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.preview-callout > p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: var(--fs-xs);
}

.callout-stars {
  margin-top: 0.3rem;
  color: var(--saffron);
  font-size: var(--fs-xl);
  letter-spacing: 0.15em;
}

.callout-choices {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.choice-tag {
  padding: 0.2rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.choice-tag.yes {
  background: var(--accent-emerald-light);
  color: var(--accent-emerald-dark);
  border: 1px solid var(--accent-emerald-border);
}

.choice-tag.no {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.builder-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0 2rem;
}

/* Preview Modal */
.preview-dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 620px;
  width: 92%;
  box-shadow: var(--shadow-lg);
}

.preview-dialog::backdrop {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
}

.preview-dialog-inner {
  padding: 1.5rem;
}

.preview-pill {
  display: inline-block;
  background: #ecfdf5;
  color: #065f46;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.35rem;
}

.preview-body {
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.5rem 0.2rem;
}

.preview-q-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 0.85rem;
}

.preview-q-head {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.preview-q-num {
  background: #e0f2fe;
  color: #0284c7;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.preview-choice-label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  cursor: pointer;
  background: #ffffff;
  transition: background 0.12s ease;
}

.preview-choice-label:hover {
  background: #f8fafc;
}

.preview-choice-label input {
  accent-color: var(--accent);
}

.preview-rating-row {
  display: flex;
  gap: 0.6rem;
}

.preview-star-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.preview-star-label .star-icon {
  font-size: 1.4rem;
  color: #f59e0b;
}

.preview-star-label .star-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}

/* Responses Log */
.response-log-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  margin-bottom: 1rem;
}

.resp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.85rem;
}

.resp-driver-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.resp-answer-item {
  min-width: 0;
}

.resp-kicker {
  display: block;
  color: var(--accent);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.resp-name-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.resp-name {
  color: var(--ink);
  font-size: var(--fs-md);
}

.pincode-filter {
  width: min(22rem, 100%);
  margin: 0;
}

.resp-meta,
.resp-when {
  font-size: var(--fs-sm);
  color: var(--muted);
}

.resp-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: 0.75rem;
}

.resp-q-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.resp-a-val {
  margin-top: 0.3rem;
  color: var(--ink);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.45;
}

.response-switch[hidden],
.response-view[hidden],
.pincode-filter[hidden],
.empty-state[hidden],
.table-wrap[hidden],
.modal[hidden],
.sheet-modal[hidden],
.pager[hidden] {
  display: none !important;
}

.resp-topline {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.35rem;
}

.resp-topline .resp-kicker {
  display: inline;
}

.status-pill.running {
  background: var(--sky);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.status-pill.stopped {
  background: var(--saffron-light);
  color: var(--saffron);
  border: 1px solid #f3d7a8;
}

.status-pill.completed {
  background: var(--accent-emerald-light);
  color: #0f6e48;
  border: 1px solid #bfe5d1;
}

.distance-cell {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
}

.status-pill.pending {
  background: var(--saffron-light);
  color: var(--saffron);
  border: 1px solid #f3d7a8;
}

.status-pill.approved,
.status-pill.completed,
.status-pill.active {
  background: var(--accent-emerald-light);
  color: #0f6e48;
  border: 1px solid #bfe5d1;
}

.status-pill.in_progress {
  background: var(--sky);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.status-pill.rejected {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.status-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.7rem;
}

.status-badge-row:empty {
  display: none;
}

.pager .btn {
  min-height: 2.15rem;
  padding: 0.35rem 0.8rem;
}

.pager .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.rank-badge {
  display: inline-flex;
  min-width: 2.2rem;
  justify-content: center;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-full);
  background: var(--sky);
  color: var(--navy);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.place-name {
  /* Same as the driver name in the next column */
  font-weight: 600;
  color: var(--navy);
}

.muted-note {
  color: var(--muted);
  font-size: var(--fs-sm);
}

.demand-count {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--navy);
}

.source-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.source-count.web { color: var(--accent); }
.source-count.wa { color: var(--accent-emerald); }

.plate {
  display: inline-flex;
  width: fit-content;
  margin-top: 0.15rem;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--sky);
  color: var(--navy);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.driver-name {
  text-transform: capitalize;
}

th.actions-col,
table.dataTable thead th.actions-col {
  text-align: right;
}

.sheet-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.45);
}

.sheet-card {
  width: min(32rem, 100%);
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: var(--shadow-md);
}

.sheet-card .dialog-head {
  margin: 0;
  padding: 1.15rem 1.25rem 0.85rem;
}

.sheet-form {
  display: grid;
  gap: 0.9rem;
  padding: 1.1rem 1.25rem 1.25rem;
}

.sheet-form .field { margin: 0; }

.demand-panel {
  margin-top: 1.25rem;
}

.demand-panel .demand-head,
.demand-panel .demand-body {
  padding: 1.15rem 1.25rem;
}

.demand-panel .demand-head {
  border-bottom: 1px solid var(--line);
}

.demand-panel .demand-head h2 {
  margin: 0;
  font-size: var(--fs-lg);
}

.chart-list {
  margin-bottom: 0.25rem;
}

.response-switch {
  display: inline-flex;
  gap: 0.25rem;
  margin: 0;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: #ffffff;
}

.response-switch button {
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
}

.response-switch button.is-on {
  background: var(--navy);
  color: #ffffff;
}

.chart-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 32rem), 1fr));
  align-items: start;
  gap: 1rem;
}

.chart-card {
  padding: 1.15rem 1.25rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: var(--shadow-xs);
}

.chart-kicker,
.chart-meta,
.chart-empty {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.chart-head h3 {
  margin: 0.2rem 0 0.15rem;
  font-size: var(--fs-lg);
}

.bar-chart {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.3rem;
  font-size: var(--fs-sm);
  color: var(--ink-secondary);
}

.bar-label strong {
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.bar-label span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.bar-icon {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 6px;
}

.bar-track {
  height: 0.7rem;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--sky);
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--navy) 0%, var(--accent) 100%);
}

.written-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
}

/* Written answers need room: their card takes the full row */
.chart-card:has(.written-list) {
  grid-column: 1 / -1;
}

.written-answer {
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--line-light);
}

.written-answer p {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.written-answer footer {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: var(--fs-xs);
}

/* ==========================================================================
   Compact laptops (Windows 125%/150% scaling: ~1536x695, ~1280x600 CSS px)
   ========================================================================== */

@media (min-width: 901px) and (max-width: 1600px), (min-width: 901px) and (max-height: 800px) {
  html { font-size: 93.75%; }
  .admin-shell { grid-template-columns: 240px 1fr; }
  .partner-otrivin { height: 26px; }
  .partner-tv9 { height: 30px; }
  .workspace { padding: 1.75rem 2rem 2.25rem; }
  .workspace-head { margin-bottom: 1.25rem; }
  .stats-grid { gap: 0.9rem; margin-bottom: 1.25rem; }
  .stat-card { padding: 1rem 1.15rem; }
  table.dataTable tbody td { padding: 0.7rem 0.75rem !important; }
  td { padding-top: 0.7rem; padding-bottom: 0.7rem; }
}

@media (min-width: 901px) and (max-height: 720px) {
  html { font-size: 87.5%; }
  .sidebar { padding-block: 0.85rem; }
  .sidebar-brand { padding-bottom: 0.75rem; margin-bottom: 0.75rem; }
  .brand-partners { padding: 0.5rem 0.7rem; margin-bottom: 0.6rem; }
  .nav-link { min-height: 2.4rem; padding-block: 0.45rem; }
  .workspace { padding: 1.25rem 1.75rem 1.75rem; }
  .workspace h1 { font-size: var(--fs-xl); }
  .workspace-head { margin-bottom: 1rem; }
  .stats-grid { margin-bottom: 1rem; }
  .stat-card { padding: 0.8rem 1rem; }
  .dataTables_wrapper { padding: 1rem 1rem 0.75rem; }
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter { margin-bottom: 0.75rem; }
}

/* Narrow desktops: tighten cells so the one-line vehicle plate still fits without side-scrolling */
@media (min-width: 901px) and (max-width: 1200px) {
  table.dataTable tbody td,
  table.dataTable thead th { padding-left: 0.45rem !important; padding-right: 0.45rem !important; }
}

/* Stat cards whose value is words (a name, a place, a date), not a number */
.stat-value.is-text { font-size: 1.125rem; }

/* Surveys & Nominations: pieces those pages use that had no styles */
.stat-icon.indigo {
  background: var(--saffron-light);
  color: var(--saffron);
}

.form-success {
  color: var(--accent-emerald-dark);
  background: var(--accent-emerald-light);
  border: 1px solid var(--accent-emerald-border);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  font-weight: 500;
  margin: 0.5rem 0;
}

.cell-title {
  color: var(--navy);
  font-weight: 600;
}

.cell-sub {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.responses-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.responses-link:hover { color: var(--accent-hover); }

.status-toggle-select {
  width: auto;
  min-height: 2.25rem;
  padding: 0 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
}

/* Detail pages (survey responses, pincode nominations): header buttons and toolbar */
.head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.response-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Survey responses and pincode nominations: cards in columns, not one per row */
.responses-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
  align-items: start;
  gap: 1rem;
}

.responses-list .response-log-card { margin-bottom: 0; }

/* 150% browser/Windows zoom on a 1920px screen (~1280px CSS wide): one step smaller again */
@media (min-width: 901px) and (max-width: 1300px) {
  html { font-size: 81.25%; }
  .admin-shell { grid-template-columns: 220px 1fr; }
  .workspace { padding: 1.1rem 1.4rem 1.5rem; }
}

/* ==========================================================================
   CMS — Stories Management System
   ========================================================================== */

.story-modal-card {
  width: min(44rem, 94vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}

.story-modal-card .dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--line-light);
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
}

.story-modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.story-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line-light);
  background: #ffffff;
}

/* View Modal Specifics */
.story-view-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  background: var(--sky);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.story-view-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  margin: 0 0 0.6rem;
}

.story-view-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  font-size: var(--fs-xs);
  margin-bottom: 1.25rem;
}

.story-view-desc-card {
  background: var(--line-light);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem;
  color: var(--text);
  font-size: var(--fs-base);
  line-height: 1.65;
  white-space: pre-wrap;
  margin-bottom: 1.5rem;
}

.story-gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.story-gallery-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.story-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.story-photo-card {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f8fafc;
  box-shadow: var(--shadow-xs);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
  display: block;
  text-decoration: none;
}

.story-photo-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.story-photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.story-photo-card .photo-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(18, 40, 110, 0.8);
  color: #ffffff;
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  backdrop-filter: blur(4px);
}

.story-single-hero {
  width: 100%;
  max-height: 320px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  background: #f8fafc;
}

.story-single-hero img {
  width: 100%;
  height: 100%;
  max-height: 320px;
  object-fit: cover;
  display: block;
}

/* Table Specific Components */
.story-order-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--muted);
  background: var(--line-light);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 0.15rem 0.5rem;
}

.story-heading-chip {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--navy);
  background: var(--sky);
  border: 1px solid var(--accent-border);
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.story-title-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: 360px;
}

.story-title-text {
  font-weight: 700;
  color: var(--ink);
  font-size: var(--fs-base);
  line-height: 1.35;
}

.story-desc-preview {
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-images-preview {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.story-thumb-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-xs);
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--line-light);
  box-shadow: var(--shadow-xs);
  display: block;
}

.story-thumb-fallback {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  background: var(--sky);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.story-images-count-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-full);
  background: var(--line-light);
  border: 1px solid var(--line);
  font-size: var(--fs-2xs);
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

/* Form Image Manager */
.story-img-builder-box {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  background: var(--line-subtle);
}

.story-img-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.story-img-preview-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: var(--shadow-xs);
}

.story-img-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.story-img-remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(18, 40, 110, 0.85);
  color: #ffffff;
  border: none;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, transform 0.15s ease;
}

.story-img-remove-btn:hover {
  background: var(--danger);
  transform: scale(1.1);
}

/* Assign driver popup: wider, with the area cards in 3 columns */
#assign-dialog { width: min(1040px, calc(100% - 2rem)); }
#assign-results { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 900px) {
  #assign-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  #assign-results { grid-template-columns: 1fr; }
}

/* Hint inside an area list ("Choose a driver…", "No pincode … matched"): full width, highlighted */
.result-list > .empty-state {
  grid-column: 1 / -1;
  flex-direction: row;
  gap: 0.6rem;
  margin: 0.25rem 0;
  padding: 1.1rem 1.25rem;
  border: 1px dashed var(--accent-border);
  border-radius: var(--radius-md);
  background: var(--accent-light);
  color: var(--navy);
  font-size: var(--fs-md);
  font-weight: 600;
}

.result-list > .empty-state::before {
  content: "i";
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-family: Georgia, serif;
  font-size: var(--fs-sm);
  font-style: italic;
  font-weight: 700;
}

/* Table consistency: same secondary-text size in DataTables cells, and no extra-bold numbers */
table.dataTable tbody td.date-cell { font-size: var(--fs-sm) !important; }
.responses-link strong { font-weight: 700; }
.btn-toggle-status { font: inherit; }

/* Page header actions: one height whether or not the button has an icon */
.workspace-head .btn {
  height: 2.65rem;
  padding-block: 0;
  white-space: nowrap;
}

.workspace-head .btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.home-sections {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.home-section {
  padding: 1.15rem 1.25rem 1.25rem;
}

.home-section-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.9rem;
}

.home-index {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.home-kicker {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.home-section h2 {
  margin: 0.15rem 0 0;
  color: var(--navy);
  font-size: 1.15rem;
}

.home-copy p {
  margin: 0 0 0.65rem;
  color: var(--text);
  line-height: 1.6;
}

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

.home-points {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.home-points span {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--sky);
  color: var(--navy);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.75rem;
}

.home-item {
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 0.75rem);
  background: #f8faff;
}

.home-item strong {
  display: block;
  color: var(--navy);
  line-height: 1.35;
}

.home-item p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.home-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-steps li {
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 0.75rem);
  background: #fff;
}

.home-steps b {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--navy);
}

.home-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0.85rem;
}

.home-edit-card {
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #f8faff;
}

.home-edit-card .field:last-child {
  margin-bottom: 0;
}

.home-photo {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.home-photo img,
.home-photo video {
  width: 7.5rem;
  height: 5rem;
  object-fit: cover;
  border-radius: 0.65rem;
  border: 1px solid var(--line);
  background: #fff;
}

.home-photo video {
  width: 12rem;
  height: 7rem;
  background: #111;
}

.home-photo.home-icon img {
  width: 3rem;
  height: 3rem;
  object-fit: contain;
  background: var(--sky);
}

.home-lang-field {
  margin-bottom: 0.85rem;
}

.home-lang-label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 650;
  color: var(--navy);
}

.home-lang-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.home-lang-grid .field {
  margin: 0;
}

.home-lang-grid .tox-tinymce {
  width: 100%;
  border-radius: 0.65rem;
}

.home-photo .home-lang-field {
  flex: 1 1 100%;
  margin: 0;
}

@media (max-width: 720px) {
  .home-lang-grid {
    grid-template-columns: 1fr;
  }
}

.home-photo .btn {
  height: 2.3rem;
  position: relative;
}

.home-step-actions {
  grid-column: 1 / -1;
  justify-self: start;
}

.home-add-card {
  margin: 0 0 0.85rem;
}

.home-photo input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.payload-json {
  margin: 0;
  max-width: 28rem;
  max-height: 9rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #334155;
}

.call-detail {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.7rem 1rem;
  margin: 0;
}

.call-detail dt {
  color: var(--muted);
  font-size: var(--fs-sm);
}

.call-detail dd {
  margin: 0;
  word-break: break-word;
}

.call-payload-title {
  margin: 1.25rem 0 0.55rem;
  font-size: var(--fs-sm);
  color: var(--navy);
}

#call-dialog .payload-json {
  max-width: none;
  max-height: 18rem;
}
