/* v7.0 — bright operations dashboard
   Inspired by modern project dashboards: cheerful, airy and still practical for dispatch work. */

:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f8f9fc;
  --panel-3: #eef1f7;
  --text: #1c2430;
  --muted: #7f8a99;
  --line: #e4e8ef;
  --line-strong: #d3d9e3;
  --accent: #3767f5;
  --accent-ink: #ffffff;
  --red: #ee6269;
  --red-soft: #fff0f1;
  --amber: #e7a93e;
  --amber-soft: #fff7e8;
  --green: #43b979;
  --green-soft: #edf9f3;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(36, 50, 75, .07);
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  min-width: 320px;
  font-variant-numeric: tabular-nums;
}

/* Left navigation */
.topbar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  height: 100vh;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  background: #ffffff;
  border-right: 1px solid var(--line);
  border-bottom: 0;
  backdrop-filter: none;
  z-index: 50;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #6d74f7, #2f67f6 60%, #8a5cf5);
  color: white;
  font-weight: 900;
  font-size: 17px;
  box-shadow: 0 6px 16px rgba(55,103,245,.22);
}

.brand-title {
  color: #17202b;
  font-size: 15px;
  font-weight: 850;
  letter-spacing: -.02em;
}

.brand-sub {
  margin-top: 2px;
  color: #8a94a2;
  font-size: 10px;
  line-height: 1.25;
}

.file-badge {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 20px;
  max-width: none;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8f9fc;
  color: #677282;
  font-size: 10px;
  line-height: 1.35;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.file-badge:hover {
  border-color: #cfd6e2;
  background: #f1f4f9;
}

.app-shell {
  width: calc(100% - 220px);
  max-width: none;
  margin: 0 0 0 220px;
  padding: 24px 28px 32px;
}

.workspace {
  display: grid;
  gap: 14px;
}

/* Side navigation built from existing module tabs */
.module-tabs {
  position: fixed;
  left: 18px;
  top: 108px;
  z-index: 55;
  width: 184px;
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
}

.module-tabs::before {
  content: "Workspace";
  display: block;
  margin: 0 0 4px 8px;
  color: #a0a8b4;
  font-size: 10px;
  font-weight: 750;
}

.module-tab {
  position: relative;
  width: 100%;
  min-height: 40px;
  padding: 10px 12px 10px 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #657180;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  transition: .15s ease;
}

.module-tab:hover {
  background: #f5f7fb;
  color: #303b49;
}

.module-tab.active {
  background: #edf2ff;
  color: #2457ef;
}

.module-tab.active::after {
  content: "";
  position: absolute;
  left: -18px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  height: auto;
  background: #3767f5;
  border-radius: 0 3px 3px 0;
}

/* Filters / toolbar */
.control-rail {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(38,55,82,.04);
}

.selectors {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  flex: 1;
}

label {
  color: #798493;
  font-size: 10px;
  font-weight: 750;
}

select,
textarea,
input[type="text"],
input[type="time"],
input[type="date"] {
  background: #ffffff !important;
  border: 1px solid #dfe4ec !important;
  color: #27313f !important;
  border-radius: 9px !important;
  outline: none;
  box-shadow: none !important;
}

select {
  display: block;
  min-width: 160px;
  height: 38px;
  margin-top: 6px;
  padding: 8px 34px 8px 10px;
  font-size: 11px;
  font-weight: 650;
}

.selectors label:nth-child(2) select {
  min-width: 310px;
}

select:focus,
textarea:focus,
input:focus {
  border-color: #8eabff !important;
  box-shadow: 0 0 0 3px rgba(55,103,245,.08) !important;
}

/* Cards */
.card,
.cut-manager-panel,
.upload-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px !important;
  box-shadow: var(--shadow) !important;
}

.module {
  display: grid;
  gap: 14px;
}

.eyebrow,
.mini-title {
  color: #8893a2;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .10em;
  text-transform: uppercase;
}

.subtle {
  color: #7f8a99;
  font-size: 11px;
  line-height: 1.5;
}

.section-heading h2,
.global-cut-manager-head h2,
.survey-toolbar h2,
.global-issues-titleline h2 {
  color: #202a36;
  font-size: 16px !important;
  font-weight: 800;
  letter-spacing: -.02em;
}

/* Issues card */
.compact-global-issues {
  background: linear-gradient(135deg, #f6f2ff 0%, #fbfaff 60%, #ffffff 100%);
  border-color: #e9e0ff;
  box-shadow: 0 8px 24px rgba(113,83,190,.07) !important;
}

.compact-global-issues .global-issues-head {
  padding: 14px 16px 10px;
}

.global-issues-titleline {
  gap: 14px;
}

.compact-metrics {
  gap: 7px;
}

.compact-metrics .issue-metric {
  min-width: 100px;
  padding: 7px 9px;
  border-radius: 9px;
  border-color: #e8e2f5;
  background: rgba(255,255,255,.8);
}

.issue-metric span {
  color: #8b8299;
  font-size: 9px;
}

.issue-metric strong {
  color: #342e3f;
  font-size: 15px;
}

.compact-note {
  padding: 0 16px 12px;
  color: #8b8496;
  font-size: 10px;
}

/* Overview / colourful metric blocks */
.overview-grid {
  display: grid;
  grid-template-columns: minmax(340px, 1.55fr) repeat(3, minmax(150px,.55fr));
  gap: 12px;
}

.route-card,
.metric-card {
  min-height: 112px;
  padding: 16px 18px;
  border: 0;
}

.route-card {
  color: #ffffff;
  background: linear-gradient(135deg, #5267f5 0%, #3767f5 55%, #6d5cf4 100%);
  box-shadow: 0 12px 26px rgba(55,103,245,.20) !important;
}

.route-card .eyebrow,
.route-card .subtle {
  color: rgba(255,255,255,.72);
}

.route-title {
  margin-top: 7px;
  color: #ffffff;
  font-size: 24px;
  font-weight: 850;
  letter-spacing: -.03em;
}

.route-places {
  margin-top: 4px;
  color: rgba(255,255,255,.90);
  font-size: 12px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  box-shadow: none !important;
}

.metric-card:nth-child(2) {
  background: linear-gradient(135deg, #eff6ff, #f7fbff);
  border-color: #dcecff;
}

.metric-card:nth-child(3) {
  background: linear-gradient(135deg, #fff0f1, #fff7f7);
  border-color: #ffdfe2;
}

.metric-card:nth-child(4) {
  background: linear-gradient(135deg, #fff7e7, #fffaf1);
  border-color: #f8e8c3;
}

.metric-card::after {
  content: "";
  position: absolute;
  width: 72px;
  height: 72px;
  right: -22px;
  top: -22px;
  border-radius: 50%;
  opacity: .35;
}

.metric-card:nth-child(2)::after { background: #8dc6ff; }
.metric-card:nth-child(3)::after { background: #ff9ea3; }
.metric-card:nth-child(4)::after { background: #ffc969; }

.metric-label {
  color: #7a8695;
  font-size: 10px;
  font-weight: 700;
}

.metric-value {
  margin-top: 8px;
  color: #222d39;
  font-size: 30px;
  font-weight: 850;
  letter-spacing: -.04em;
}

.metric-card:nth-child(3) .metric-value { color: #e6565e; }
.metric-card:nth-child(4) .metric-value { color: #b9801f; }

.metric-sub {
  margin-top: 2px;
  color: #8893a1;
  font-size: 10px;
}

/* Planner */
.compact-planner-grid {
  grid-template-columns: 275px minmax(0,1fr);
  gap: 12px;
}

.compact-cut-card {
  padding: 14px;
  border-color: #e8ebf2;
}

.compact-cut-card .section-heading h2 {
  font-size: 15px !important;
}

.selected-duty-list {
  gap: 6px;
  max-height: 230px;
}

.selected-duty-list .selected-duty {
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 9px !important;
  border: 1px solid #e8ebf1;
  background: #fafbfe;
  color: #394454;
}

.selected-duty-list .selected-duty:hover {
  background: #f2f5fb;
  border-color: #d9e0eb;
}

.selected-duty-name {
  color: #273240;
  font-size: 11px;
  font-weight: 850;
}

.selected-duty-meta {
  color: #7e8997;
  font-size: 9px;
}

/* Tables */
.table-card,
.summary-card,
.survey-table-card,
.global-cut-manager-card {
  overflow: hidden;
}

.table-heading {
  padding: 14px 16px 10px;
  border-bottom: 1px solid #edf0f4;
  background: #ffffff;
}

.table-scroll {
  background: #ffffff;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 10px;
  background: #f7f8fb;
  color: #7d8897;
  border-bottom: 1px solid #dfe4eb;
  font-size: 9px;
  letter-spacing: .035em;
  text-transform: uppercase;
  font-weight: 800;
  white-space: nowrap;
}

.data-table td {
  padding: 10px;
  color: #344050;
  border-bottom: 1px solid #edf0f4;
  white-space: nowrap;
  background: #ffffff;
}

.data-table tbody tr:hover td {
  background: #f8faff !important;
}

.data-table tr.dropped td {
  background: #fff2f3 !important;
  color: #624044;
  border-bottom-color: #f6d8da;
}

.data-table tr.dropped:hover td {
  background: #ffecee !important;
}

.planner-grid .table-card > .table-scroll {
  min-height: 420px;
  max-height: calc(100vh - 355px);
}

/* Status / exception tags */
.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  border: 0;
  font-size: 9px;
  font-weight: 800;
}

.status.operated {
  color: #278755;
  background: #eaf8f0;
}

.status.dropped {
  color: #c64149;
  background: #ffe3e5;
}

.exception {
  color: #b87915;
  font-weight: 750;
}

.hw-bad {
  color: #e24f57;
  font-weight: 800;
}

.alert-chip {
  border: 0;
  border-radius: 999px;
  padding: 5px 8px;
  background: #fff2cd;
  color: #9c6b14;
  font-size: 9px;
  font-weight: 800;
}

.alert-chip.danger {
  background: #ffe4e6;
  color: #c74850;
}

/* Buttons */
.btn,
.trip-cut-btn,
.now-btn,
.modal-close {
  border-radius: 9px !important;
  box-shadow: none !important;
}

.btn {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid #dfe4eb;
  background: #ffffff;
  color: #3a4554;
  font-size: 10px;
  font-weight: 780;
}

.btn:hover {
  filter: none;
  background: #f5f7fb;
  border-color: #d2d8e2;
}

.btn.primary {
  color: #ffffff;
  background: #3767f5;
  border-color: #3767f5;
  box-shadow: 0 6px 14px rgba(55,103,245,.18) !important;
}

.btn.primary:hover {
  background: #2f5de5;
  border-color: #2f5de5;
}

.btn.secondary {
  color: #3157c9;
  background: #edf2ff;
  border-color: #dce5ff;
}

.btn.danger {
  color: #c8474f;
  background: #fff0f1;
  border-color: #ffd7da;
}

.btn.ghost {
  color: #667180;
  background: transparent;
}

.trip-cut-btn {
  padding: 6px 9px;
  border: 1px solid #e0e5ec;
  background: #f7f8fb;
  color: #526070;
  font-size: 9px;
  font-weight: 800;
}

.trip-cut-btn.restore {
  color: #c8464e;
  background: #fff0f1;
  border-color: #ffd5d9;
}

.data-manager-trigger {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.data-count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  color: #3158d6;
  background: #edf2ff;
  border: 1px solid #dbe5ff;
  font-size: 9px;
}

/* Cut Duty Manager */
.compact-cut-manager {
  background: #ffffff;
}

.compact-cut-manager .global-cut-manager-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid #edf0f4;
}

.cut-manager-topgrid {
  grid-template-columns: minmax(320px,.72fr) minmax(520px,1.28fr);
  gap: 12px;
  padding: 12px;
}

.cut-manager-panel {
  padding: 14px;
  border-radius: 12px !important;
  border: 1px solid #e8ebf2;
  background: #fbfcfe;
  box-shadow: none !important;
}

.cut-entry-panel {
  background: linear-gradient(135deg, #f5f7ff, #fbfcff);
  border-color: #e1e6fb;
}

.ops-export-panel {
  background: linear-gradient(135deg, #fffaf0, #fffdf8);
  border-color: #f0e4c6;
}

.cut-duty-composer {
  height: 38px;
  border-radius: 9px;
}

.cut-entry-composer .btn {
  height: 38px;
}

.cut-input-pills {
  min-height: 40px;
  max-height: 90px;
  padding: 7px;
  border-radius: 9px;
  background: #ffffff;
}

.cut-input-pill {
  height: 27px;
  border-radius: 999px;
  background: #fff0f1;
  color: #bf4a51;
  border-color: #ffd9dc;
}

.ops-status-preview {
  min-height: 118px;
  max-height: 180px;
  background: #ffffff !important;
  color: #3a4653 !important;
  border-radius: 9px !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
}

/* Survey */
.survey-toolbar {
  padding: 16px;
  background: linear-gradient(135deg, #eef7ff, #ffffff);
  border-color: #ddecf8;
}

.survey-stats {
  gap: 7px;
}

.stat-pill {
  border-radius: 999px;
  padding: 6px 10px;
  background: #ffffff;
  color: #7e8997;
  border-color: #e1e6ed;
  font-size: 10px;
}

.stat-pill strong {
  color: #2d3846;
}

.toggle {
  border-radius: 999px;
  padding: 7px 10px;
  background: #ffffff;
  color: #52606f;
  border-color: #dfe4eb;
}

.toggle span {
  background: #d9dee7;
}

.toggle input:checked + span {
  background: #4d72f4;
}

.cell-input {
  min-height: 31px;
  padding: 6px 7px;
  border-radius: 7px !important;
}

.now-btn {
  color: #3155c4;
  background: #edf2ff;
  border-color: #dce5ff;
}

/* Duty manager */
.modal-backdrop {
  background: rgba(31, 41, 55, .35);
  backdrop-filter: blur(5px);
  padding: 22px;
}

.duty-manager {
  width: min(1220px, 96vw);
  max-height: calc(100vh - 44px);
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid #e0e5ec;
  box-shadow: 0 28px 70px rgba(39,52,78,.18);
}

.duty-manager-head {
  padding: 18px 20px 14px;
  background: #ffffff;
  border-bottom: 1px solid #edf0f4;
}

.duty-manager-head h2 {
  margin: 4px 0 3px;
  color: #202a36;
  font-size: 24px;
  font-weight: 850;
}

.modal-close {
  width: 36px;
  height: 36px;
  background: #f5f7fa;
  border-color: #e0e5eb;
  color: #788493;
}

.duty-manager-toolbar {
  padding: 11px 18px;
  background: #fafbfe;
  border-bottom-color: #edf0f4;
}

.duty-manager-count {
  color: #3c4755;
  font-size: 11px;
  font-weight: 750;
}

.duty-manager-scroll {
  max-height: calc(100vh - 235px);
}

.duty-manager-foot {
  padding: 11px 18px;
  background: #fafbfe;
  border-top-color: #edf0f4;
}

.additional-trip-form {
  padding: 14px 18px;
  background: #f7f9ff;
  border-bottom-color: #e6eaf3;
}

.additional-trip-grid input {
  height: 36px;
  background: #ffffff !important;
}

.manual-trip-badge {
  border-radius: 999px;
  background: #edf4ff;
  border-color: #d8e7ff;
  color: #3b66cc;
}

/* Data manager */
.data-manager-backdrop {
  background: rgba(31,41,55,.28);
  backdrop-filter: blur(4px);
}

.data-manager-pane {
  width: min(620px,94vw);
  background: #ffffff;
  border-left: 1px solid #e0e5eb;
  box-shadow: -18px 0 50px rgba(35,47,70,.12);
}

.data-manager-head {
  padding: 18px;
  background: #ffffff;
  border-bottom-color: #edf0f4;
}

.data-manager-head h2 {
  margin: 4px 0;
  color: #202a36;
  font-size: 20px;
  font-weight: 850;
}

.data-manager-toolbar {
  padding: 11px 14px;
  background: #fafbfe;
  border-bottom-color: #edf0f4;
}

.data-manager-drop-zone {
  margin: 10px 10px 0;
  padding: 11px 12px;
  border-radius: 10px;
  border-color: #d8dee8;
  background: #f8faff;
}

.data-manager-drop-zone:hover,
.data-manager-drop-zone:focus-visible {
  border-color: #91aafa;
  background: #f2f6ff;
}

.data-manager-drop-zone.dragging {
  transform: none;
  border-color: #557cf4;
  background: #edf2ff;
  box-shadow: 0 0 0 3px rgba(55,103,245,.08);
}

.data-manager-drop-icon {
  border-radius: 8px;
  color: #3e64d7;
  background: #edf2ff;
  border-color: #dce5ff;
}

.data-manager-list {
  padding: 10px;
  gap: 7px;
}

.data-item {
  padding: 11px 12px;
  border-radius: 10px;
  background: #ffffff;
  border-color: #e5e9f0;
}

.data-item:hover {
  background: #fafbfe;
  border-color: #d6dce6;
}

.data-item.active {
  background: #eef4ff;
  border-color: #cfdcff;
  box-shadow: inset 3px 0 0 #4f76f5;
}

.data-item-title {
  color: #2b3542;
  font-size: 11px;
  font-weight: 800;
}

.data-active-badge {
  border-radius: 999px;
  background: #e8f7ee;
  color: #2e8e5b;
}

.data-manager-foot {
  padding: 11px 14px;
  background: #fafbfe;
  border-top-color: #edf0f4;
}

/* Upload screen */
.upload-view {
  min-height: calc(100vh - 80px);
}

.upload-card {
  width: min(680px,100%);
  padding: 38px;
  background: #ffffff;
  border-radius: 18px !important;
  box-shadow: 0 18px 50px rgba(45,61,87,.10) !important;
}

.upload-card h1 {
  color: #202a36;
  font-size: 30px;
  letter-spacing: -.04em;
}

.upload-card p {
  color: #7f8a99;
}

.upload-icon {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  color: #3767f5;
  background: #edf2ff;
  border-color: #dce5ff;
}

.drop-zone {
  border-radius: 13px;
  border-color: #cfd8e7;
  background: #f8faff;
}

.drop-zone:hover,
.drop-zone.dragging {
  transform: none;
  background: #edf2ff;
  border-color: #6485f6;
}

/* Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: #c0c7d2 #f0f2f6;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #f0f2f6;
}

::-webkit-scrollbar-thumb {
  background: #c0c7d2;
  border: 2px solid #f0f2f6;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #aeb7c3;
}

/* Toast */
.toast {
  bottom: 18px;
  border-radius: 10px;
  padding: 9px 12px;
  background: #25313d;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(31,41,55,.18);
  font-size: 10px;
}

/* Responsive */
@media (max-width: 1100px) {
  .topbar { width: 190px; }
  .app-shell {
    width: calc(100% - 190px);
    margin-left: 190px;
    padding: 18px;
  }
  .module-tabs {
    left: 14px;
    width: 162px;
  }
  .selectors label:nth-child(2) select { min-width: 240px; }
  .overview-grid { grid-template-columns: minmax(280px,1.3fr) repeat(3,minmax(125px,.55fr)); }
}

@media (max-width: 860px) {
  .overview-grid { grid-template-columns: 1fr 1fr; }
  .route-card { grid-column: 1 / -1; }
  .metric-card:last-child { grid-column: 1 / -1; }
  .compact-planner-grid { grid-template-columns: 1fr; }
  .cut-manager-topgrid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .topbar {
    position: sticky;
    inset: 0 auto auto 0;
    width: 100%;
    height: 60px;
    padding: 0 14px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-sub { display: none; }
  .file-badge { display: none; }

  .app-shell {
    width: 100%;
    margin-left: 0;
    padding: 12px;
  }

  .module-tabs {
    position: static;
    width: 100%;
    flex-direction: row;
    gap: 6px;
    padding: 0;
  }

  .module-tabs::before { display: none; }

  .module-tab {
    width: auto;
    flex: 1;
    min-height: 38px;
    padding: 8px 8px;
    text-align: center;
  }

  .module-tab.active::after { display: none; }

  .control-rail {
    align-items: stretch;
    flex-direction: column;
  }

  .selectors {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .selectors label:last-child { grid-column: 1 / -1; }
  .selectors label:nth-child(2) select { min-width: 0; }

  .overview-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .route-card { grid-column: 1 / -1; }
  .metric-card:last-child { grid-column: 1 / -1; }

  .modal-backdrop { padding: 8px; }
  .duty-manager {
    max-height: 94vh;
    border-radius: 16px 16px 0 0;
  }

  .data-manager-pane {
    border-radius: 16px 16px 0 0;
  }
}
