:root {
  --ink: #10242d;
  --ink-soft: #53646b;
  --navy: #071b25;
  --surface: #ffffff;
  --canvas: #edf1f2;
  --line: #dce4e6;
  --primary: #0b826f;
  --primary-dark: #086655;
  --primary-soft: #e3f3ef;
  --ok: #1b9a74;
  --soon: #d88b14;
  --alert: #d85445;
  --neutral: #71838a;
  --shadow: 0 18px 48px rgba(16, 36, 45, 0.16);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body { margin: 0; overflow: hidden; background: var(--canvas); }

button, input, select, textarea { font: inherit; }
button { color: inherit; }

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.topbar {
  min-height: 92px;
  padding: 16px 24px;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto minmax(210px, 1fr);
  align-items: center;
  gap: 20px;
  color: #fff;
  background:
    radial-gradient(circle at 78% -80%, rgba(22, 181, 150, 0.35), transparent 46%),
    var(--navy);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  color: #9ce2d5;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
}
.brand-mark svg { width: 26px; height: 26px; stroke-width: 2; }

.eyebrow {
  margin: 0 0 3px;
  font-size: 10px;
  line-height: 1;
  font-weight: 750;
  letter-spacing: 0.15em;
  color: #70838a;
}
.brand .eyebrow { color: #74b9ad; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 20px; line-height: 1.2; letter-spacing: -0.02em; }
h2 { margin-bottom: 0; font-size: 19px; letter-spacing: -0.02em; }
h3 { font-size: 14px; }
.version-badge {
  margin-left: 5px;
  padding: 2px 6px;
  display: inline-block;
  vertical-align: 2px;
  border: 1px solid rgba(156, 226, 213, 0.28);
  border-radius: 999px;
  color: #9ce2d5;
  background: rgba(156, 226, 213, 0.08);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.06em;
}

.summary { display: flex; align-items: stretch; }
.metric {
  min-width: 83px;
  padding: 5px 17px;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background 150ms ease;
}
.metric:first-child { border-left: 0; }
.metric:hover, .metric.active { background: rgba(255, 255, 255, 0.07); }
.metric-value { display: block; font-size: 21px; font-weight: 750; line-height: 1.1; }
.metric-label { font-size: 11px; color: #9fb0b6; white-space: nowrap; }
.metric-ok .metric-value { color: #65d6bb; }
.metric-soon .metric-value { color: #f0b44d; }
.metric-alert .metric-value { color: #f1897e; }

.button {
  min-height: 40px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.button:active { transform: translateY(1px); }
.button-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.button-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.button-secondary { color: var(--primary-dark); background: var(--primary-soft); border-color: #c9e8df; }
.button-secondary:hover { background: #d5ede7; }
.button-ghost { color: #52646a; background: #fff; border-color: var(--line); }
.button-ghost:hover { background: #f4f7f7; border-color: #cbd6d8; }
.button-danger { color: #b83e32; background: #fff; border-color: #efcac6; }
.button-danger:hover { background: #fff3f1; }
.button svg { width: 17px; height: 17px; stroke-width: 2; }
.add-device { justify-self: end; min-height: 45px; padding-inline: 18px; box-shadow: 0 10px 24px rgba(1, 78, 65, 0.25); }

.filterbar {
  min-height: 70px;
  padding: 11px 24px;
  display: grid;
  grid-template-columns: minmax(250px, 1.4fr) repeat(3, minmax(150px, 0.7fr)) auto;
  gap: 10px;
  align-items: center;
  background: #f7f9f9;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 3px 10px rgba(16, 36, 45, 0.05);
  z-index: 3;
}

.search-field { position: relative; }
.search-field svg {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 18px;
  transform: translateY(-50%);
  color: #708187;
}
.search-field input, .select-field select {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
.search-field input { padding: 0 14px 0 42px; }
.search-field input:focus, .select-field select:focus, .form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: #56aa9b;
  box-shadow: 0 0 0 3px rgba(11, 130, 111, 0.12);
}
.select-field { position: relative; }
.select-field > span {
  position: absolute;
  z-index: 1;
  top: 6px;
  left: 12px;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.06em;
  color: #809097;
  text-transform: uppercase;
  pointer-events: none;
}
.select-field select { padding: 15px 32px 2px 11px; font-size: 12px; font-weight: 650; }
.clear-filters { min-height: 46px; }

.workspace { min-height: 0; display: grid; grid-template-columns: 370px minmax(0, 1fr); }
.device-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #f8fafa;
  border-right: 1px solid var(--line);
  z-index: 2;
}
.panel-heading {
  min-height: 73px;
  padding: 17px 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.panel-heading h2 { font-size: 16px; }
.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #62747a;
  background: #fff;
  cursor: pointer;
}
.icon-button:hover { color: var(--primary); background: var(--primary-soft); border-color: #c9e8df; }
.icon-button svg { width: 18px; height: 18px; }
.device-list { flex: 1; overflow: auto; padding: 10px; }
.panel-legal {
  margin: 0;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  color: #87969b;
  background: #fff;
  font-size: 9px;
  line-height: 1.35;
  text-align: center;
}

.device-card {
  width: 100%;
  margin: 0 0 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: start;
  border: 1px solid #e0e7e8;
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 2px 5px rgba(16, 36, 45, 0.035);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.device-card:hover, .device-card.active {
  border-color: #75b9ad;
  box-shadow: 0 7px 20px rgba(16, 36, 45, 0.09);
  transform: translateY(-1px);
}
.device-symbol {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #687a80;
  background: #edf2f3;
}
.device-symbol svg { width: 20px; }
.device-symbol.current { color: #08785f; background: #def3ec; }
.device-symbol.soon { color: #a56408; background: #fff0d6; }
.device-symbol.overdue { color: #b53d31; background: #fde5e2; }
.device-main { min-width: 0; }
.device-name { margin: 0 0 2px; overflow: hidden; font-size: 13px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.device-meta { margin: 0 0 8px; overflow: hidden; color: #78898f; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.review-line { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; }
.review-line.current { color: #15795f; }
.review-line.soon { color: #a4650b; }
.review-line.overdue { color: #b74639; }
.review-line.no-date { color: #71838a; }
.review-line i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.card-chevron { color: #a0adb1; margin-top: 8px; }
.card-chevron svg { width: 16px; height: 16px; }

.empty-state {
  margin: auto;
  padding: 28px;
  max-width: 300px;
  text-align: center;
}
.empty-icon {
  width: 62px;
  height: 62px;
  margin: 0 auto 15px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #4b9c8e;
  background: var(--primary-soft);
}
.empty-icon svg { width: 30px; height: 30px; }
.empty-state h3 { margin-bottom: 7px; font-size: 16px; }
.empty-state p { margin-bottom: 17px; color: #718188; font-size: 12px; line-height: 1.5; }

.map-panel { min-width: 0; position: relative; }
#map { width: 100%; height: 100%; background: #dbe4e3; }
.leaflet-control-zoom a { color: var(--ink) !important; }
.leaflet-popup-content-wrapper { border-radius: 10px; box-shadow: 0 12px 35px rgba(16, 36, 45, 0.18); }
.leaflet-popup-content { margin: 13px 15px; font-family: inherit; }
.popup-name { margin-bottom: 3px; font-size: 13px; font-weight: 750; }
.popup-meta { color: #728288; font-size: 11px; }
.map-key {
  position: absolute;
  z-index: 500;
  left: 12px;
  bottom: 12px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 1px solid rgba(16, 36, 45, 0.12);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 5px 18px rgba(16, 36, 45, 0.12);
  backdrop-filter: blur(8px);
  font-size: 10px;
  font-weight: 650;
}
.map-key span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-ok { background: var(--ok); }
.dot-soon { background: var(--soon); }
.dot-alert { background: var(--alert); }
.dot-neutral { background: var(--neutral); }

.map-hint {
  position: absolute;
  z-index: 600;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 9px;
  color: #fff;
  background: #0a554a;
  box-shadow: 0 8px 25px rgba(7, 50, 43, 0.28);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.map-hint[hidden] { display: none !important; }
.map-hint button { padding: 0 0 0 10px; border: 0; border-left: 1px solid rgba(255, 255, 255, .25); color: #bfe3dc; background: transparent; cursor: pointer; font-size: 11px; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: #7de1cd; box-shadow: 0 0 0 5px rgba(125, 225, 205, 0.18); }

.map-marker-wrap { background: transparent; border: 0; }
.map-marker {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 12%;
  color: #fff;
  background: var(--neutral);
  box-shadow: 0 5px 12px rgba(16, 36, 45, 0.28);
  transform: rotate(-45deg);
}
.map-marker svg { width: 16px; height: 16px; stroke-width: 2.2; transform: rotate(45deg); }
.map-marker.current { background: var(--ok); }
.map-marker.soon { background: var(--soon); }
.map-marker.overdue { background: var(--alert); }
.map-marker.preview { background: var(--primary); animation: markerPulse 1.5s infinite; }
@keyframes markerPulse { 50% { box-shadow: 0 0 0 10px rgba(11, 130, 111, 0.18), 0 5px 12px rgba(16, 36, 45, 0.28); } }

.drawer-backdrop {
  position: fixed;
  z-index: 900;
  inset: 0;
  background: rgba(4, 20, 27, 0.24);
  opacity: 0;
  transition: opacity 180ms ease;
}
.drawer-backdrop.visible { opacity: 1; }
.editor-drawer {
  position: fixed;
  z-index: 1000;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(510px, 100vw);
  background: #fff;
  box-shadow: -18px 0 50px rgba(16, 36, 45, 0.18);
  transform: translateX(105%);
  transition: transform 220ms cubic-bezier(.2, .8, .2, 1);
}
.editor-drawer.open { transform: translateX(0); }
.editor-drawer form { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.drawer-header { min-height: 76px; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.drawer-header h2 { font-size: 20px; }
.drawer-body { overflow: auto; padding: 0 20px 22px; }
.form-section { padding: 20px 0; border-bottom: 1px solid #e7ecee; }
.form-section:last-child { border-bottom: 0; }
.form-section > h3 { margin-bottom: 15px; color: #334950; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-field { display: block; margin-bottom: 13px; }
.form-field:last-child { margin-bottom: 0; }
.form-field > span { display: block; margin: 0 0 6px; color: #51636a; font-size: 11px; font-weight: 700; }
.form-field b { color: var(--alert); }
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
.form-field input, .form-field select { height: 42px; padding: 0 11px; }
.form-field textarea { padding: 10px 11px; resize: vertical; line-height: 1.45; }
.form-field input::placeholder, .form-field textarea::placeholder { color: #a4afb3; }
.location-card { padding: 12px; display: flex; gap: 11px; align-items: center; border: 1px solid var(--line); border-radius: 9px; background: #f8fafa; }
.location-icon { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 8px; color: var(--primary); background: var(--primary-soft); }
.location-icon svg { width: 19px; height: 19px; }
.location-card strong, .location-card span { display: block; }
.location-card strong { margin-bottom: 2px; font-size: 12px; }
.location-card span { color: #7a898e; font-size: 10px; }
.location-card.has-location { border-color: #b8ded6; background: #f0f8f6; }
.location-actions { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 8px; }
.location-note { margin: 8px 0 0; color: #7a898e; font-size: 10px; line-height: 1.45; }
.device-photo-card {
  min-height: 180px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #cbd7da;
  border-radius: 10px;
  background: #f6f9f9;
}
.device-photo-card.has-photo { border-style: solid; border-color: #badcd5; background: #e9f3f1; }
.device-photo-card img { width: 100%; max-height: 280px; display: block; object-fit: contain; background: #e8eeee; }
.device-photo-placeholder { padding: 24px; display: grid; justify-items: center; color: #74868c; text-align: center; }
.device-photo-placeholder svg { width: 34px; height: 34px; margin-bottom: 10px; color: #589b8f; }
.device-photo-placeholder strong { margin-bottom: 4px; color: #42575e; font-size: 12px; }
.device-photo-placeholder span { font-size: 10px; }
.device-photo-status { min-height: 15px; margin: 8px 0 0; color: #75868c; font-size: 10px; line-height: 1.45; }
.device-photo-actions { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 8px; }
.drawer-footer { min-height: 70px; padding: 12px 20px; display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); background: #f9fbfb; }
.footer-spacer { flex: 1; }

.toast {
  position: fixed;
  z-index: 1200;
  left: 50%;
  bottom: 24px;
  max-width: calc(100vw - 32px);
  padding: 11px 15px;
  border-radius: 9px;
  color: #fff;
  background: #19343d;
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 901px) {
  .drawer-backdrop { pointer-events: none; background: transparent; }
}

@media (max-width: 1080px) {
  .topbar { grid-template-columns: minmax(210px, 1fr) auto auto; }
  .metric { min-width: 65px; padding-inline: 10px; }
  .metric-label { font-size: 10px; }
  .filterbar { grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(125px, .7fr)) auto; }
  .workspace { grid-template-columns: 335px minmax(0, 1fr); }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .app-shell { min-height: 100%; height: auto; grid-template-rows: auto auto auto; }
  .topbar { grid-template-columns: 1fr auto; }
  .summary { grid-column: 1 / -1; order: 3; overflow-x: auto; }
  .metric { flex: 1; }
  .filterbar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .clear-filters { display: none; }
  .workspace { height: auto; min-height: 900px; grid-template-columns: 1fr; grid-template-rows: 500px minmax(400px, auto); }
  .map-panel { grid-row: 1; }
  .device-panel { grid-row: 2; border-right: 0; border-top: 1px solid var(--line); }
  .device-list { max-height: none; }
  .drawer-backdrop.visible { display: block; }
}

@media (max-width: 560px) {
  .topbar { padding: 14px; gap: 14px; }
  .brand-mark { width: 40px; height: 40px; }
  .brand .eyebrow { display: none; }
  h1 { font-size: 17px; }
  .add-device { width: 44px; min-width: 44px; padding: 0; font-size: 0; }
  .add-device svg { width: 20px; height: 20px; }
  .summary { margin: 0 -14px -14px; border-top: 1px solid rgba(255,255,255,.1); }
  .metric { padding: 10px 8px; text-align: center; }
  .metric-value { font-size: 18px; }
  .filterbar { padding: 10px 12px; }
  .select-field:last-of-type { grid-column: 1 / -1; }
  .workspace { grid-template-rows: 410px minmax(420px, auto); }
  .map-key { max-width: calc(100% - 24px); flex-wrap: wrap; gap: 6px 11px; }
  .map-hint { top: 10px; max-width: calc(100% - 20px); white-space: normal; }
  .drawer-header, .drawer-body, .drawer-footer { padding-left: 15px; padding-right: 15px; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .drawer-footer .button { padding-inline: 11px; }
  .drawer-footer .button-danger { width: 42px; padding: 0; font-size: 0; }
  .drawer-footer .button-danger svg { width: 18px; height: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Serwer, logowanie i zarządzanie */
.auth-screen {
  min-height: 100%;
  padding: 32px 18px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 20px;
  color: #fff;
  background:
    radial-gradient(circle at 75% 10%, rgba(35, 182, 153, .25), transparent 38%),
    linear-gradient(135deg, #061923, #0b2b35);
  overflow: auto;
}
.auth-brand { display: flex; align-items: center; gap: 13px; width: min(430px, 100%); }
.auth-brand h1 { font-size: 25px; }
.auth-brand .eyebrow { color: #75bdaf; }
.auth-card { width: min(430px, 100%); padding: 30px; color: var(--ink); background: #fff; border: 1px solid rgba(255,255,255,.15); border-radius: 18px; box-shadow: 0 28px 70px rgba(0,0,0,.3); }
.auth-card h2 { margin: 6px 0 8px; font-size: 25px; }
.auth-lead { margin-bottom: 24px; color: #718188; font-size: 13px; line-height: 1.55; }
.auth-legal { margin: 0; color: #7d9aa3; font-size: 10px; }
.auth-error { margin-top: 14px; padding: 11px 12px; color: #a9362d; background: #fff0ee; border: 1px solid #f3cbc7; border-radius: 8px; font-size: 12px; line-height: 1.45; }
.button-block { width: 100%; min-height: 46px; margin-top: 8px; }
.field-hint { margin: -6px 0 13px; color: #7c8d92; font-size: 10px; }
#authLoading { padding: 30px 0; text-align: center; color: #61767d; }
.spinner { width: 30px; height: 30px; margin: 0 auto 12px; display: block; border: 3px solid #dce9e7; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy { opacity: .72; pointer-events: none; }

.topbar { grid-template-columns: minmax(210px, .85fr) auto minmax(400px, 1.3fr); }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 7px; min-width: 0; }
.button-top { min-height: 38px; padding-inline: 11px; color: #c5d2d6; background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); font-size: 11px; }
.button-top:hover { color: #fff; background: rgba(255,255,255,.12); }
.button-top.active { color: #fff; background: rgba(101,214,187,.2); border-color: rgba(101,214,187,.45); }
.settings-button { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.12); border-radius: 9px; color: #a9bcc1; background: rgba(255,255,255,.06); cursor: pointer; }
.settings-button:hover, .settings-button:focus-visible { color: #fff; background: rgba(255,255,255,.13); border-color: rgba(156,226,213,.5); outline: none; }
.settings-button svg { width: 19px; height: 19px; }
.user-menu { min-height: 42px; padding: 3px 9px 3px 12px; display: flex; align-items: center; gap: 9px; border: 1px solid rgba(255,255,255,.12); border-radius: 9px; color: #fff; background: rgba(255,255,255,.06); cursor: pointer; text-align: right; }
.user-menu span, .user-menu strong, .user-menu small { display: block; }
.user-menu strong { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.user-menu small { color: #8eabb2; font-size: 9px; }
.user-menu svg { width: 17px; color: #9bb2b8; }
.task-badge { min-width: 18px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; color: #5a2f00; background: #ffc45f; border-radius: 99px; font-size: 9px; }
.assignee { margin-top: 6px; display: block; color: #688087; font-size: 10px; }
.device-tags { margin: 0 0 7px; display: flex; flex-wrap: wrap; gap: 5px; }
.condition-tag, .priority-tag { padding: 3px 6px; border-radius: 99px; font-size: 9px; font-weight: 750; }
.condition-tag { color: #496066; background: #edf2f3; }
.condition-operational { color: #08765d; background: #def3ec; }
.condition-attention { color: #99600a; background: #fff0d6; }
.condition-offline { color: #5d6d72; background: #e8edef; }
.condition-failure { color: #fff; background: #c83c31; }
.condition-in_progress { color: #145a88; background: #dceefa; }
.condition-waiting { color: #6a4b8a; background: #eee3f7; }
.priority-tag { color: #40565d; background: #edf1f5; border: 1px solid #dde4e7; }
.device-card.has-failure { border-color: #e3a19b; box-shadow: inset 3px 0 0 #c83c31; }
.map-marker.failure { background: #c83c31; box-shadow: 0 0 0 5px rgba(200,60,49,.18), 0 5px 12px rgba(16,36,45,.28); }
.card-chevron { font-size: 22px; line-height: 1; }
#map.picking { cursor: crosshair; }

.photo-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.photo-item { margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #f6f9f9; }
.photo-item img { width: 100%; height: 135px; display: block; object-fit: cover; }
.photo-item figcaption { min-height: 45px; padding: 8px; display: flex; align-items: center; justify-content: space-between; gap: 6px; color: #5f7178; font-size: 10px; line-height: 1.3; }
.photo-item figcaption span { overflow: hidden; }
.photo-item figcaption button { padding: 0; border: 0; color: #b23e34; background: none; cursor: pointer; font-size: 10px; font-weight: 700; }
.photo-upload { margin-top: 12px; padding: 12px; border: 1px dashed #cbd8da; border-radius: 9px; background: #f8fafa; }
.photo-upload .form-field { margin-bottom: 8px; }
.file-selection { margin-left: 8px; color: #65777d; font-size: 10px; }
.muted { margin: 8px 0; color: #7d8c91; font-size: 11px; line-height: 1.5; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; }
.section-title-row h3 { margin: 0; }
.device-log-row { padding: 9px 0; display: grid; grid-template-columns: 105px minmax(0,1fr); gap: 9px; border-bottom: 1px solid #e7ecee; }
.device-log-row:last-child { border-bottom: 0; }
.device-log-row > span { color: #7d8d92; font-size: 9px; }
.device-log-row strong { display: block; color: #334950; font-size: 10px; }
.device-log-row p { margin: 2px 0 0; color: #64767c; font-size: 10px; }
.history-error { margin: 8px 0; color: #a43930; font-size: 10px; }
.assignee-checklist { max-height: 180px; overflow: auto; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafa; }
.assignee-option { min-width: 0; padding: 9px; display: flex; align-items: center; gap: 9px; border: 1px solid #e1e8e9; border-radius: 8px; background: #fff; cursor: pointer; }
.assignee-option:has(input:checked) { border-color: #75bbae; background: #edf8f5; box-shadow: inset 0 0 0 1px #a5d5cc; }
.assignee-option input { width: 17px; height: 17px; flex: 0 0 17px; accent-color: var(--primary); }
.assignee-option span, .assignee-option strong, .assignee-option small { min-width: 0; display: block; }
.assignee-option strong { overflow: hidden; text-overflow: ellipsis; font-size: 10px; white-space: nowrap; }
.assignee-option small { margin-top: 2px; overflow: hidden; color: #7b8b90; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }

.tasks-view { grid-row: 2 / 4; min-height: 0; overflow: auto; background: #eef2f3; }
.tasks-header { padding: 22px 26px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: #fff; }
.tasks-header h2 { margin-bottom: 5px; font-size: 23px; }
.tasks-header p:last-child { margin: 0; color: #718188; font-size: 12px; }
.tasks-content { padding: 16px; display: grid; gap: 16px; }
.tasks-filters { padding: 14px; display: grid; grid-template-columns: minmax(210px,1.5fr) repeat(4,minmax(145px,1fr)) auto; gap: 10px; align-items: end; border: 1px solid #dce5e7; border-radius: 12px; background: #fff; box-shadow: 0 4px 15px rgba(16,36,45,.05); }
.tasks-filters .form-field { margin: 0; }
.tasks-filters > .button { min-height: 42px; }
.tasks-table-card { min-width: 0; overflow: hidden; border: 1px solid #dce5e7; border-radius: 12px; background: #fff; box-shadow: 0 4px 15px rgba(16,36,45,.05); }
.tasks-table-heading { min-height: 70px; padding: 16px 18px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.tasks-table-heading h3 { margin: 0; font-size: 16px; }
.tasks-table-wrap { max-height: calc(100vh - 300px); overflow: auto; }
.tasks-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.tasks-table th { position: sticky; z-index: 1; top: 0; padding: 10px; color: #65777d; background: #f5f8f8; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tasks-table td { padding: 12px 10px; border-bottom: 1px solid #e7ecee; vertical-align: middle; }
.tasks-table tbody tr { cursor: pointer; }
.tasks-table tbody tr:hover { background: #f0f8f6; }
.tasks-table td strong, .tasks-table td small { display: block; }
.tasks-table td small { margin-top: 4px; color: #7b8b90; font-size: 9px; }
.task-deadline { padding: 5px 8px; display: inline-block; border-radius: 99px; font-size: 9px; font-weight: 750; white-space: nowrap; }
.task-deadline.late { color: #a43930; background: #fde7e4; }
.task-deadline.soon { color: #8a5609; background: #fff0d2; }
.task-deadline.future { color: #16735c; background: #e2f3ee; }

.export-view { grid-row: 2 / 4; min-height: 0; overflow: auto; background: #eef2f3; }
.export-header { padding: 22px 26px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: #fff; }
.export-header h2 { margin-bottom: 5px; font-size: 23px; }
.export-header p:last-child { margin: 0; color: #718188; font-size: 12px; }
.export-layout { min-height: calc(100% - 95px); display: grid; grid-template-columns: minmax(320px, 390px) minmax(0,1fr); gap: 16px; padding: 16px; }
.export-controls, .export-preview { border: 1px solid #dce5e7; border-radius: 12px; background: #fff; box-shadow: 0 4px 15px rgba(16,36,45,.05); }
.export-controls { padding: 18px; align-self: start; }
.export-actions { margin-top: 16px; display: grid; grid-template-columns: 1fr; gap: 8px; padding-top: 16px; border-top: 1px solid #e5ebed; }
.export-preview { min-width: 0; overflow: hidden; }
.export-preview-heading { min-height: 70px; padding: 16px 18px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.export-preview-heading h3 { margin: 0; font-size: 16px; }
.export-table-wrap { max-height: calc(100vh - 235px); overflow: auto; }
.export-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.export-table th { position: sticky; z-index: 1; top: 0; padding: 10px; color: #65777d; background: #f5f8f8; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.export-table td { padding: 11px 10px; border-bottom: 1px solid #e7ecee; vertical-align: top; }
.export-table tbody tr { cursor: pointer; }
.export-table tbody tr:hover { background: #f0f8f6; }
.export-table td strong, .export-table td small { display: block; }
.export-table td strong { margin-bottom: 3px; color: #1c333c; }
.export-table td small { margin-top: 3px; color: #7b8b90; font-size: 9px; }

.modal-backdrop { position: fixed; z-index: 1300; inset: 0; background: rgba(3,18,25,.55); backdrop-filter: blur(3px); }
.modal { position: fixed; z-index: 1400; top: 50%; left: 50%; width: min(820px, calc(100vw - 30px)); max-height: min(780px, calc(100vh - 30px)); display: grid; grid-template-rows: auto minmax(0,1fr); overflow: hidden; background: #fff; border-radius: 15px; box-shadow: 0 28px 80px rgba(0,0,0,.3); transform: translate(-50%, -50%); }
.modal > header { min-height: 72px; padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-body { overflow: auto; padding: 18px; }
.modal-lead { color: #65777d; font-size: 13px; }
.empty-modal { padding: 40px; text-align: center; }
.task-row { width: 100%; padding: 12px 14px; display: grid; grid-template-columns: 120px minmax(0,1fr); gap: 2px 12px; border: 0; border-bottom: 1px solid #e6ecee; background: #fff; cursor: pointer; text-align: left; }
.task-row:hover { background: #f4f9f8; }
.task-row strong { font-size: 13px; }
.task-row small { grid-column: 2; color: #718188; }
.task-status { grid-row: 1 / span 2; align-self: center; padding: 5px 8px; border-radius: 99px; font-size: 10px; font-weight: 750; text-align: center; }
.task-status.soon { color: #8a5609; background: #fff0d2; }
.task-status.late { color: #a43930; background: #fde7e4; }
.new-user-form { margin-bottom: 18px; padding: 15px; border: 1px solid #dce6e7; border-radius: 10px; background: #f8fafa; }
.new-user-form h3 { margin-bottom: 12px; }
.account-settings-form { display: grid; gap: 18px; }
.settings-account { padding: 14px; display: flex; align-items: center; gap: 12px; border: 1px solid #dfe7e8; border-radius: 11px; background: #f8fafa; }
.settings-avatar { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; color: #fff; background: var(--primary); border-radius: 50%; font-size: 17px; font-weight: 800; }
.settings-account strong, .settings-account span { display: block; }
.settings-account strong { margin-bottom: 3px; font-size: 13px; }
.settings-account span { color: #708187; font-size: 10px; }
.settings-section { padding: 18px; display: grid; grid-template-columns: minmax(170px,.7fr) minmax(240px,1fr); gap: 24px; border: 1px solid #dfe7e8; border-radius: 11px; }
.settings-section h3 { margin: 0 0 6px; font-size: 15px; }
.settings-section p { margin: 0; color: #718188; font-size: 11px; line-height: 1.5; }
.settings-section .form-field { margin: 0; }
.field-help { margin-top: 7px; display: block; color: #819096; font-size: 9px; line-height: 1.45; }
.settings-actions { padding-top: 15px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid #e4eaec; }
.user-list { display: grid; gap: 7px; }
.user-row { padding: 10px; display: grid; grid-template-columns: minmax(170px,1fr) 155px auto auto; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 9px; }
.user-row.inactive { opacity: .55; }
.user-row strong, .user-row small { display: block; }
.user-row small { margin-top: 2px; color: #74858b; font-size: 10px; }
.user-row select { height: 38px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.log-row { padding: 11px 5px; display: grid; grid-template-columns: 125px 160px minmax(0,1fr); gap: 10px; border-bottom: 1px solid #e6ecee; align-items: baseline; }
.log-row span { color: #7d8d92; font-size: 10px; }
.log-row strong { font-size: 11px; }
.log-row p { margin: 0; color: #52666d; font-size: 11px; }
.export-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.export-card { min-height: 130px; padding: 18px; display: flex; flex-direction: column; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 11px; background: #f8fafa; cursor: pointer; text-align: left; }
.export-card:hover { border-color: #76b8ad; background: #edf8f5; }
.export-card strong { font-size: 15px; }
.export-card span { color: #6e7f85; font-size: 11px; line-height: 1.4; }

@media (max-width: 1250px) {
  .topbar { grid-template-columns: minmax(200px,1fr) auto; }
  .summary { grid-row: 2; grid-column: 1; justify-self: start; }
  .top-actions { grid-row: 2; grid-column: 2; }
  .tasks-filters { grid-template-columns: repeat(3,minmax(150px,1fr)); }
}
@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; }
  .top-actions { grid-row: 2; grid-column: 1 / -1; width: 100%; justify-self: stretch; flex-wrap: wrap; }
  .top-actions .button-top { flex: 1; padding-inline: 8px; }
  .top-actions .user-menu span { display: none; }
  .summary { grid-column: 1 / -1; grid-row: 3; width: 100%; }
  .modal { width: calc(100vw - 18px); max-height: calc(100vh - 18px); }
  .settings-section { grid-template-columns: 1fr; gap: 14px; }
  .user-row { grid-template-columns: 1fr auto; }
  .user-row select { grid-column: 1; }
  .export-grid { grid-template-columns: 1fr; }
  .export-view { grid-row: 2 / 4; }
  .tasks-view { grid-row: 2 / 4; }
  .tasks-header { padding: 18px; align-items: flex-start; }
  .tasks-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .task-search { grid-column: 1 / -1; }
  .tasks-table-wrap { max-height: none; }
  .export-header { padding: 18px; align-items: flex-start; }
  .export-layout { grid-template-columns: 1fr; }
  .export-controls { align-self: stretch; }
  .export-table-wrap { max-height: none; }
}
@media (max-width: 560px) {
  .auth-card { padding: 22px 18px; }
  .top-actions { gap: 5px; }
  .user-menu { min-width: 40px; padding: 8px; }
  .photo-gallery { grid-template-columns: 1fr; }
  .assignee-checklist, .tasks-filters { grid-template-columns: 1fr; }
  .task-search { grid-column: auto; }
  .tasks-header { display: grid; }
  .task-row { grid-template-columns: 90px minmax(0,1fr); }
  .log-row { grid-template-columns: 1fr; gap: 3px; }
  .export-header { flex-direction: column; }
  .export-header .button { width: 100%; }
  .export-layout { padding: 8px; gap: 8px; }
  .device-log-row { grid-template-columns: 1fr; gap: 3px; }
}
