:root {
  --navy: #273170;
  --cyan: #16bdd7;
  --green: #78bd43;
  --ink: #172033;
  --muted: #647085;
  --line: #d9e2ea;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --warn: #d98519;
  --danger: #c64242;
  --ok: #21865b;
  color-scheme: light;
}

* { box-sizing: border-box; }

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

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

.sidebar {
  background: #192052;
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 4px 18px;
  border-bottom: 1px solid rgba(255,255,255,.16);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--cyan), var(--green));
  color: #fff;
  font-weight: 900;
  font-size: 24px;
}

.brand strong, .brand span { display: block; }
.brand span { color: rgba(255,255,255,.66); font-size: 13px; margin-top: 2px; }

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

.nav-item {
  height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: rgba(255,255,255,.76);
  text-align: left;
}

.nav-item.active, .nav-item:hover {
  background: rgba(255,255,255,.11);
  color: #fff;
}

.sidebar-card {
  margin-top: auto;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255,255,255,.07);
}

.sidebar-card span, .sidebar-card small { color: rgba(255,255,255,.68); display: block; }
.sidebar-card strong { display: block; margin: 5px 0 8px; }
.demo-button { width: 100%; min-height: 36px; margin-top: 12px; border: 1px solid rgba(255,255,255,.22); border-radius: 8px; background: rgba(255,255,255,.1); color: #fff; font-weight: 800; }

main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 88px;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; }
h2 { font-size: 20px; margin-bottom: 12px; }
h3 { font-size: 15px; margin-bottom: 8px; }

.actions { display: flex; align-items: center; gap: 10px; }
select, input, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
}

.primary, .ghost, .icon-btn {
  border-radius: 8px;
  min-height: 40px;
  border: 1px solid transparent;
}

.primary {
  background: var(--navy);
  color: #fff;
  padding: 0 14px;
  font-weight: 800;
}

.ghost {
  background: #fff;
  color: var(--navy);
  border-color: var(--line);
  padding: 0 12px;
}

.content { padding: 24px 28px 36px; }

.owner-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}
.owner-intro h2 { font-size: 24px; margin: 0 0 4px; }
.owner-subtitle { color: var(--muted); margin: 0; }
.attention-grid { display: grid; gap: 10px; margin-bottom: 16px; }
.attention-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--cyan);
  border-radius: 8px;
}
.attention-item.danger { border-left-color: var(--danger); }
.attention-item.warn { border-left-color: var(--warn); }
.attention-item.ok { border-left-color: var(--ok); }
.attention-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #e8f8fb; color: #087d90; font-weight: 900; }
.attention-item.danger .attention-icon { background: #fde9e9; color: var(--danger); }
.attention-item.warn .attention-icon { background: #fff2df; color: var(--warn); }
.attention-copy strong { display: block; }
.attention-copy p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.quick-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.quick-action { min-height: 96px; padding: 13px; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); }
.quick-action:hover { border-color: var(--cyan); box-shadow: 0 8px 20px rgba(22,189,215,.1); }
.quick-action span { display: block; color: var(--cyan); font-size: 22px; font-weight: 900; margin-bottom: 7px; }
.quick-action strong, .quick-action small { display: block; }
.quick-action small { color: var(--muted); margin-top: 3px; }
.unit-health { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.health-item { min-height: 64px; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 12px; text-align: left; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.health-item span:nth-child(2), .health-item strong, .health-item small { display: block; }
.health-item small { color: var(--muted); margin-top: 2px; }
.health-item b { color: var(--navy); }
.health-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.health-dot.ok { background: var(--ok); }
.health-dot.warn { background: var(--warn); }
.health-dot.danger { background: var(--danger); }
.daily-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.daily-card { min-height: 220px; }
.checklist { display: grid; gap: 2px; }
.check-item { grid-template-columns: 22px minmax(0, 1fr); align-items: center; gap: 9px; min-height: 42px; color: var(--ink); border-bottom: 1px solid #edf1f4; }
.check-item:last-child { border-bottom: 0; }
.check-item input { width: 18px; height: 18px; min-height: 0; accent-color: var(--green); }
.check-item span, .check-item strong, .check-item small { display: block; }
.check-item small { color: var(--muted); margin-top: 2px; }
.timeline { display: grid; }
.timeline-item { display: grid; grid-template-columns: 44px 10px minmax(0, 1fr); gap: 9px; min-height: 38px; align-items: start; }
.timeline-item time { color: var(--muted); font-size: 12px; padding-top: 2px; }
.timeline-item > span { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px #e8f8fb; }
.timeline-item p { margin: 0; color: var(--muted); font-size: 13px; }
.timeline-item p strong { color: var(--ink); display: block; margin-bottom: 2px; }

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.cols-2 { grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); align-items: start; }
.cols-3 { grid-template-columns: repeat(3, minmax(220px, 1fr)); }

.card, .metric, .table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(30,44,72,.05);
}

.metric { padding: 16px; min-height: 112px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 30px; margin-top: 8px; }
.metric small { color: var(--muted); }

.card { padding: 18px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0; background: #fbfcfd; }
tr:last-child td { border-bottom: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #eef3f7;
  color: var(--muted);
  white-space: nowrap;
}

.pill.ok { background: #e7f6ef; color: var(--ok); }
.pill.warn { background: #fff2df; color: var(--warn); }
.pill.danger { background: #fde9e9; color: var(--danger); }
.pill.info { background: #e8f8fb; color: #087d90; }

.unit-card { min-height: 210px; display: flex; flex-direction: column; gap: 10px; }
.unit-card p { color: var(--muted); margin-bottom: 2px; }
.unit-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: auto; }
.unit-stats div { background: #f5f8fb; border-radius: 8px; padding: 10px; }
.unit-stats strong { display: block; }
.unit-stats span { color: var(--muted); font-size: 12px; }
.unit-map-link { margin-top: 4px; }

.map-page { display: grid; gap: 16px; min-width: 0; }
.map-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.map-toolbar h2 { font-size: 24px; margin-bottom: 4px; }
.map-toolbar p:last-child { margin: 0; color: var(--muted); }
.unit-segments { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow-x: auto; }
.segment { min-height: 34px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); white-space: nowrap; }
.segment.active { background: var(--navy); color: #fff; font-weight: 800; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; min-width: 0; }
.floor-shell, .machine-panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 30px rgba(30,44,72,.05); }
.floor-shell { padding: 16px; min-width: 0; }
.floor-head { min-height: 34px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; color: var(--muted); font-size: 13px; }
.floor-plan { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 390px; overflow: hidden; margin-top: 12px; border: 5px solid #26304c; background: #f8fafb; }
.floor-grid { position: absolute; inset: 0; background-image: linear-gradient(#dfe6eb 1px, transparent 1px), linear-gradient(90deg, #dfe6eb 1px, transparent 1px); background-size: 28px 28px; opacity: .55; }
.map-zone { position: absolute; z-index: 1; display: grid; place-items: center; border: 1px dashed #9cacb9; border-radius: 6px; color: #536274; background: rgba(255,255,255,.82); font-size: 12px; font-weight: 800; }
.map-zone.folding { background: rgba(120,189,67,.12); border-color: rgba(74,139,35,.55); }
.map-zone.waiting { background: rgba(22,189,215,.1); border-color: rgba(8,125,144,.45); }
.map-zone.kiosk { background: rgba(39,49,112,.1); border-color: rgba(39,49,112,.45); }
.map-zone.entrance { background: rgba(255,255,255,.9); }
.map-machine { position: absolute; z-index: 3; width: 96px; height: 74px; display: grid; grid-template-columns: 34px minmax(0, 1fr); grid-template-rows: 1fr 1fr; align-items: center; gap: 0 6px; padding: 8px; border: 2px solid var(--ok); border-radius: 8px; background: #fff; color: var(--ink); box-shadow: 0 8px 18px rgba(24,35,58,.12); }
.map-machine > span { grid-row: 1 / 3; width: 32px; height: 32px; display: grid; place-items: center; border: 3px solid var(--ok); border-radius: 50%; color: var(--ok); font-weight: 900; }
.map-machine strong { align-self: end; font-size: 12px; }
.map-machine small { align-self: start; color: var(--muted); font-size: 10px; }
.map-machine.atencao { border-color: var(--warn); }
.map-machine.atencao > span { border-color: var(--warn); color: var(--warn); }
.map-machine.parada { border-color: var(--danger); background: #fff8f8; }
.map-machine.parada > span { border-color: var(--danger); color: var(--danger); }
.map-machine.selected { outline: 3px solid rgba(22,189,215,.28); outline-offset: 3px; }
.map-door { position: absolute; z-index: 2; bottom: -5px; left: 44%; width: 12%; height: 14px; border-top: 5px solid var(--cyan); }
.map-legend { display: flex; gap: 16px; padding-top: 12px; color: var(--muted); font-size: 12px; }
.map-legend span { display: flex; align-items: center; gap: 6px; }
.map-legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.map-legend i.ok { background: var(--ok); }
.map-legend i.warn { background: var(--warn); }
.map-legend i.danger { background: var(--danger); }
.machine-panel { padding: 18px; }
.machine-hero { width: 84px; height: 84px; margin-bottom: 18px; display: grid; place-items: center; border: 4px solid var(--ok); border-radius: 50%; background: #f4fbf7; color: var(--ok); }
.machine-hero span { font-size: 34px; font-weight: 900; }
.machine-hero.atencao { border-color: var(--warn); color: var(--warn); background: #fff9ef; }
.machine-hero.parada { border-color: var(--danger); color: var(--danger); background: #fff6f6; }
.machine-panel > p { color: var(--muted); }
.machine-panel .eyebrow { color: var(--cyan); }
.machine-facts { display: grid; gap: 0; margin: 16px 0; }
.machine-facts div { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 42px; border-bottom: 1px solid #edf1f4; }
.machine-facts dt { color: var(--muted); font-size: 13px; }
.machine-facts dd { margin: 0; font-weight: 800; text-align: right; }
.machine-panel .wide + .wide { margin-top: 8px; }
.map-note { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.map-note p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

.list { display: grid; gap: 10px; }
.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.list-item p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.bar {
  height: 10px;
  background: #e8eef3;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.bar i { display: block; height: 100%; background: var(--cyan); border-radius: inherit; }
.bar.low i { background: var(--danger); }
.bar.mid i { background: var(--warn); }

.composer {
  display: grid;
  gap: 10px;
}
.message-preview {
  min-height: 128px;
  background: #eef9fb;
  border: 1px solid #c9edf3;
  border-radius: 8px;
  padding: 14px;
  white-space: pre-wrap;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(520px, calc(100vw - 32px));
  box-shadow: 0 28px 90px rgba(18,28,54,.28);
}
dialog::backdrop { background: rgba(12,18,36,.45); }
form { padding: 18px; display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; color: var(--ink); }
.icon-btn { width: 36px; background: #f2f5f8; border-color: var(--line); }
.wide { width: 100%; }

.report {
  line-height: 1.55;
  color: #30394b;
}
.report strong { color: var(--ink); }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(360px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 8px; background: #172033; color: #fff; font-weight: 800; opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

.control-page .owner-intro { margin-bottom: 18px; }
.control-card { min-height: 210px; }
.balance-main { display: grid; gap: 4px; padding: 10px 0 16px; }
.balance-main span, .balance-main small, .balance-stats span { color: var(--muted); font-size: 12px; }
.balance-main strong { color: var(--ink); font-size: 30px; letter-spacing: 0; }
.balance-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; border-top: 1px solid var(--line); padding: 14px 0; margin-bottom: 12px; }
.balance-stats div { display: grid; gap: 3px; }
.balance-stats strong { font-size: 15px; }
.control-status { color: var(--ink); font-weight: 700; margin: 16px 0 4px; }
.control-card > small { color: var(--muted); }
@media (max-width: 620px) { .balance-stats { gap: 6px; } .balance-stats strong { font-size: 13px; } }

@media (max-width: 980px) {
  body { grid-template-columns: 72px 1fr; }
  .brand div:not(.brand-mark), .nav-item span, .sidebar-card { display: none; }
  .sidebar { padding: 16px 10px; }
  .nav-item { justify-content: center; padding: 0; }
  .brand { justify-content: center; padding-bottom: 14px; }
  .cols-2, .cols-3, .kpis, .quick-actions, .unit-health, .daily-grid, .map-layout { grid-template-columns: minmax(0, 1fr); }
  .machine-panel { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 0 16px; }
  .machine-panel .machine-hero { grid-row: 1 / 5; }
  .machine-panel .machine-facts, .machine-panel .wide, .machine-panel .map-note { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  body { display: block; padding-bottom: 70px; }
  main { max-width: 100vw; overflow-x: hidden; }
  .sidebar { position: fixed; inset: auto 0 0 0; z-index: 15; min-height: 66px; height: 66px; flex-direction: row; overflow-x: auto; padding: 6px 8px; box-shadow: 0 -8px 24px rgba(20,27,58,.18); }
  .brand, .sidebar-card { display: none; }
  nav { display: flex; width: max-content; gap: 2px; }
  .nav-item { width: 72px; height: 54px; flex: 0 0 72px; padding: 5px 4px; flex-direction: column; justify-content: center; gap: 2px; font-size: 18px; }
  .nav-item span { display: block; max-width: 68px; overflow: hidden; text-overflow: ellipsis; font-size: 9px; white-space: nowrap; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 18px; }
  .actions { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 42px; }
  .actions select { width: 100%; min-width: 0; }
  .actions .primary { grid-column: 1 / -1; justify-self: start; }
  .content { width: 100%; min-width: 0; padding: 18px; }
  .owner-intro { align-items: flex-start; flex-direction: column; }
  .attention-item { grid-template-columns: 34px minmax(0, 1fr); }
  .attention-action { grid-column: 2; justify-self: start; }
  .map-toolbar { align-items: flex-start; flex-direction: column; }
  .map-page, .map-toolbar, .map-layout, .floor-shell, .machine-panel { width: calc(100vw - 36px); max-width: calc(100vw - 36px); }
  .unit-segments { width: 100%; max-width: 100%; }
  .floor-plan { min-height: 330px; aspect-ratio: 4 / 5; }
  .floor-shell, .floor-plan { width: 100%; max-width: 100%; }
  .floor-shell { overflow: hidden; }
  .floor-head { align-items: flex-start; flex-direction: column; }
  .map-machine { width: 82px; height: 66px; grid-template-columns: 28px minmax(0, 1fr); padding: 6px; }
  .map-machine > span { width: 27px; height: 27px; }
  .machine-panel { display: block; }
  .machine-panel .machine-hero { margin-bottom: 16px; }
  .toast { right: 16px; bottom: 82px; }
  .table-wrap table { min-width: 720px; }
  th, td { padding: 11px 10px; }
}
