:root {
  --bg: #f5f7f6;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #65726d;
  --line: #dbe2df;
  --accent: #0f766e;
  --accent-strong: #0b5d56;
  --warning: #b45309;
  --danger: #b42318;
  --ok: #15803d;
  --shadow: 0 18px 45px rgba(20, 35, 30, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(520px, 1fr);
  min-height: 100vh;
}

.app-shell.has-details {
  grid-template-columns: 300px minmax(520px, 1fr) 280px;
}

.sidebar,
.details {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 14px;
  overflow: auto;
}

.details {
  border-right: 0;
  border-left: 1px solid var(--line);
  display: none;
}

.app-shell.has-details .details {
  display: block;
}

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

.logout-button {
  width: 100%;
  margin-bottom: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.section-header h2 {
  margin: 0;
}

.brand h1 {
  font-size: 16px;
}

.brand p {
  font-size: 12px;
}

.brand p,
.eyebrow,
.section-header span,
.meta,
label {
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fbfcfb;
}

.summary-card strong {
  display: block;
  font-size: 18px;
  line-height: 1;
  margin-bottom: 4px;
}

.summary-card span {
  display: block;
  font-size: 11px;
  line-height: 1.15;
}

.filters {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 6px 8px;
}

textarea {
  resize: vertical;
}

.section-header,
.topbar,
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-header {
  margin-bottom: 10px;
}

.section-header h2 {
  font-size: 16px;
}

.orders-list {
  display: grid;
  gap: 7px;
}

.order-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 9px;
  cursor: pointer;
}

.order-card:hover,
.order-card.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.order-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.order-number {
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 750;
  background: #e7f5f2;
  color: var(--accent-strong);
  white-space: nowrap;
}

.badge.hp {
  background: #eaf1ff;
  color: #1d4ed8;
}

.badge.lenovo {
  background: #fff1f2;
  color: #be123c;
}

.badge.opiekait {
  background: #ecfeff;
  color: #0891b2;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-button,
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 34px;
  padding: 6px 10px;
  background: white;
  color: var(--ink);
  cursor: pointer;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 750;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.map-area {
  position: relative;
  height: calc(100vh - 59px);
  min-height: 520px;
  overflow: hidden;
  background: #dfe9e4;
}

.service-map {
  width: 100%;
  height: 100%;
  min-height: 520px;
}

.leaflet-container {
  width: 100%;
  height: 100%;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container {
  overflow: hidden;
  touch-action: pan-x pan-y;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
}

.leaflet-tile {
  border: 0;
  visibility: hidden;
}

.leaflet-tile-loaded {
  visibility: inherit;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control-zoom {
  margin: 10px;
}

.leaflet-control-zoom a {
  display: block;
  width: 30px;
  height: 30px;
  border-bottom: 1px solid #ccc;
  background: #fff;
  color: #111;
  line-height: 30px;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
}

.leaflet-control-attribution {
  margin: 0;
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.8);
  font-size: 11px;
}

.map-message {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: calc(100vh - 59px);
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.map-marker {
  display: grid;
  place-items: center;
  position: relative;
  width: 34px;
  height: 34px;
  border: 2px solid white;
  border-radius: 50% 50% 50% 0;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 800;
  transform: rotate(-45deg);
  box-shadow: 0 8px 20px rgba(20, 35, 30, 0.2);
}

.map-marker::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.map-marker.hp {
  background: #2563eb;
}

.map-marker.lenovo {
  background: #be123c;
}

.map-marker.is-active {
  outline: 3px solid rgba(15, 118, 110, 0.28);
}

.map-marker span {
  position: relative;
  z-index: 1;
  color: white;
  transform: rotate(45deg);
}

.detail-empty {
  display: grid;
  place-items: center;
  min-height: 50vh;
  color: var(--muted);
  text-align: center;
}

.detail-card h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.detail-card h3 {
  margin: 16px 0 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

.detail-rows {
  display: grid;
  gap: 10px;
}

.detail-row {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.detail-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.note-field {
  min-height: 96px;
  line-height: 1.4;
}

.read-only-note {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  padding: 9px;
  color: var(--muted);
  line-height: 1.4;
}

.protocol-button {
  width: 100%;
  margin: 14px 0 2px;
}

.worker-tiles {
  display: grid;
  gap: 8px;
}

.worker-tile {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 42px;
  border-radius: 6px;
  text-align: left;
}

.worker-tile span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #edf3f0;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.worker-tile.is-selected {
  border-color: var(--accent);
  background: #eefaf7;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

dialog {
  width: min(620px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

#adminDialog {
  width: min(840px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.dialog-form {
  display: grid;
  gap: 18px;
}

.admin-dialog {
  max-height: min(760px, calc(100vh - 42px));
  overflow: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.wide {
  grid-column: 1 / -1;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  margin: 0;
}

.admin-section {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.admin-section h3,
.admin-section p {
  margin: 0;
}

.form-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 8px;
}

.region-checks,
.region-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-tile {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  background: white;
  color: var(--ink);
  font-size: 13px;
}

.check-tile input {
  width: auto;
  min-height: auto;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
}

.users-list {
  display: grid;
  gap: 10px;
}

.user-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}

.user-card strong {
  display: block;
  margin-bottom: 3px;
}

.user-card p {
  color: var(--muted);
  font-size: 13px;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.danger-button {
  border-color: #f2c9c4;
  background: #fff6f5;
  color: var(--danger);
}

.danger-button.is-strong {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}

.region-pill {
  min-height: 30px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.region-pill.is-selected {
  border-color: var(--accent);
  background: #eefaf7;
  color: var(--accent-strong);
  font-weight: 750;
}

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(rgba(245, 247, 246, 0.9), rgba(245, 247, 246, 0.9)),
    radial-gradient(circle at 20% 20%, rgba(15, 118, 110, 0.16), transparent 30%),
    #f5f7f6;
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.demo-accounts {
  display: grid;
  gap: 8px;
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.demo-accounts h2 {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.demo-accounts button {
  text-align: left;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 280px 1fr;
  }

  .app-shell.has-details {
    grid-template-columns: 280px 1fr;
  }

  .details {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar,
  .details {
    border: 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .map-area {
    height: 520px;
    min-height: 520px;
  }

  .service-map {
    height: 520px;
    min-height: 520px;
  }
}
