:root {
  color-scheme: dark;
  --bg: #071016;
  --panel: #101b23;
  --panel-2: #15232e;
  --deep-blue: #071724;
  --deep-blue-2: #0b2133;
  --line: #29404f;
  --text: #f3f7fb;
  --muted: #9eb4c4;
  --blue: #43a0f7;
  --green: #38c777;
  --yellow: #e3b341;
  --red: #f06464;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
  background: var(--deep-blue);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

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

button {
  min-height: 44px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

button.ghost,
button.tiny {
  background: transparent;
  border-color: var(--line);
}

.hamb {
  width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--deep-blue-2);
  color: var(--text);
  font-size: 23px;
  line-height: 1;
}

button.tiny {
  min-height: 30px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 11px;
  opacity: .55;
}

.app {
  min-height: 100vh;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
}

.screen {
  display: none;
  max-width: 720px;
  margin: 0 auto;
}

.screen.active {
  display: block;
}

[data-screen="guardias"].active {
  min-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 36px 4px 22px;
}

.brand span,
.top span,
.dash-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1, h2 {
  margin: 4px 0;
  letter-spacing: 0;
}

h1 { font-size: 38px; }
h2 { font-size: 24px; }
p { color: var(--muted); }

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b151d;
  color: var(--text);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

small[data-message] {
  min-height: 16px;
  color: var(--muted);
  font-weight: 700;
}

small[data-message].error { color: var(--red); }
small[data-message].ok { color: var(--green); }

.top,
.dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.module-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.module-grid button {
  min-height: 120px;
  background: var(--panel-2);
}

.actions,
.incident-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tools-panel[hidden] {
  display: none;
}

.side-drawer[hidden] {
  display: none;
}

.side-drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 100%;
  border: 0;
  border-radius: 0;
  background: rgba(0, 0, 0, .48);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(320px, 86vw);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-left: 1px solid var(--line);
  background: #081522;
  padding: 18px;
  box-shadow: -18px 0 44px rgba(0, 0, 0, .42);
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.drawer-head span,
.drawer-section span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.drawer-head strong {
  display: block;
  margin-top: 3px;
  font-size: 22px;
}

.drawer-close {
  width: 42px;
  min-height: 42px;
  border-color: var(--line);
  background: transparent;
  color: var(--text);
  font-size: 28px;
}

.drawer-section {
  display: grid;
  gap: 8px;
}

.drawer-section .actions,
.drawer-section {
  overflow: visible;
}

.drawer-section .actions {
  display: grid;
  margin: 0;
  padding: 0;
}

.drawer-section button,
.drawer-logout {
  width: 100%;
  justify-content: flex-start;
  border-color: var(--line);
  background: var(--panel-2);
  text-align: left;
}

.drawer-logout {
  margin-top: auto;
  border-color: rgba(240, 100, 100, .55);
  background: rgba(240, 100, 100, .08);
  color: #ff9a9a;
}

.incident-bar button {
  min-width: max-content;
  background: var(--panel-2);
}

.incident-bar {
  display: block;
  overflow: visible;
  padding-bottom: 0;
}

.incident-bar button {
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(56, 199, 119, .55);
  border-radius: 14px;
  background: rgba(56, 199, 119, .08);
  color: var(--green);
}

.incident-bar button:before {
  content: "+ ";
}

.list {
  display: grid;
  gap: 10px;
  padding-bottom: 16px;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.round-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 12px;
  background: rgba(56, 199, 119, .10);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.round-card:active {
  transform: scale(.99);
}

.round-card.ontime {
  border-left-color: var(--green);
}

.round-card.pending {
  border-left-color: var(--green);
  background: rgba(56, 199, 119, .08);
}

.round-card.warn {
  border-left-color: var(--yellow);
  background: rgba(227, 179, 65, .10);
}

.round-card.expired {
  border-left-color: var(--red);
  background: rgba(240, 100, 100, .10);
}

.round-card.missed {
  border-left-color: var(--red);
  background: rgba(240, 100, 100, .16);
  cursor: default;
}

.round-card strong {
  font-size: 19px;
}

.round-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.round-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.pill.warn { color: var(--yellow); border-color: rgba(227, 179, 65, .45); }
.pill.ok { color: var(--green); border-color: rgba(56, 199, 119, .45); }
.pill.blue { color: var(--blue); border-color: rgba(67, 160, 247, .5); }
.pill.red { color: var(--red); border-color: rgba(240, 100, 100, .5); }

.card-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.card-actions button:last-child {
  background: transparent;
  border-color: var(--line);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.point-camera {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #020507;
  aspect-ratio: 4 / 3;
}

.point-camera video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.point-row {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, .03);
}

.point-row button {
  justify-self: end;
  width: auto;
  min-height: 36px;
  padding: 0 12px;
}

.points-list-wrap {
  margin-top: 12px;
}

.top.compact {
  margin-bottom: 10px;
}

.camera-box {
  position: relative;
  overflow: hidden;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #020507;
}

video {
  display: block;
  width: 100%;
  min-height: 280px;
  object-fit: cover;
}

.scan-frame {
  position: absolute;
  inset: 22%;
  border: 3px solid var(--green);
  border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .28);
  pointer-events: none;
}

.scan-form {
  margin-top: 12px;
}

@media (max-width: 520px) {
  .app { padding: 12px; }
  .module-grid { grid-template-columns: 1fr; }
  .top, .dash-head { align-items: flex-start; }
  h1 { font-size: 34px; }
  h2 { font-size: 22px; }
}
