@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Source+Sans+3:wght@400;600;700&display=swap');

:root {
  --bg: #eef4f8;
  --sidebar: #0f2235;
  --sidebar-2: #183149;
  --card: rgba(255, 255, 255, 0.92);
  --ink: #13263b;
  --muted: #63788f;
  --line: #d7e2ea;
  --brand: #0e7ce8;
  --brand-2: #22b7ff;
  --accent: #dff6ff;
  --success: #18805a;
  --danger: #c84040;
  --shadow: 0 18px 48px rgba(20, 43, 67, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Source Sans 3', 'Segoe UI', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(34, 183, 255, 0.12), transparent 28%),
    linear-gradient(180deg, #f5f9fc 0%, var(--bg) 100%);
}

h1,
h2,
h3,
.brand-title {
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #f3f8fb;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(34, 183, 255, 0.3);
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 0.88rem;
  color: rgba(243, 248, 251, 0.72);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  display: block;
  text-decoration: none;
  color: rgba(243, 248, 251, 0.88);
  padding: 12px 14px;
  border-radius: 12px;
  background: transparent;
  border: 1px solid transparent;
  transition: 0.18s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
  background: rgba(34, 183, 255, 0.14);
  border-color: rgba(34, 183, 255, 0.32);
  color: #fff;
}

.nav-item.muted {
  opacity: 0.45;
  cursor: default;
}

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

.sidebar-panel p {
  margin: 8px 0 0;
  line-height: 1.45;
  color: rgba(243, 248, 251, 0.82);
}

.sidebar-label,
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
}

.workspace {
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 2rem;
}

.topbar-chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(14, 124, 232, 0.08);
  color: var(--brand);
  font-weight: 700;
}

.hero {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 16px;
  align-items: stretch;
}

.hero h2 {
  margin: 8px 0 10px;
  font-size: 1.7rem;
  max-width: 760px;
}

.hero p {
  margin: 0;
  max-width: 720px;
  font-size: 1rem;
  color: var(--muted);
}

.hero-card {
  background: linear-gradient(135deg, #132b42 0%, #1e4969 100%);
  color: #fff;
  padding: 20px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.hero-card span,
.hero-card small {
  color: rgba(255, 255, 255, 0.72);
}

.hero-card strong {
  font-size: 1.25rem;
}

.content-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

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

.card h2 {
  margin: 4px 0 0;
  font-size: 1.2rem;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  font-size: 0.92rem;
  color: var(--muted);
}

input[type='text'],
input[type='number'],
input[type='password'],
input[type='url'],
input[type='email'],
select {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input[type='text']:focus,
input[type='number']:focus,
input[type='password']:focus,
input[type='url']:focus,
input[type='email']:focus,
select:focus {
  border-color: rgba(14, 124, 232, 0.55);
  box-shadow: 0 0 0 4px rgba(14, 124, 232, 0.08);
}

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

.inline-check {
  padding-top: 4px;
}

.inline-check label {
  color: var(--ink);
}

.card-preview {
  position: sticky;
  top: 24px;
}

.price-box {
  background: linear-gradient(180deg, #f7fbff 0%, #edf7ff 100%);
  border: 1px solid #d7ebfa;
  border-radius: 16px;
  padding: 14px;
}

.price-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(13, 78, 128, 0.08);
}

.price-line:last-of-type {
  border-bottom: 0;
}

.price-line span {
  color: var(--muted);
}

.price-total {
  text-align: right;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--brand);
  padding-top: 12px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.actions-stretch button {
  width: 100%;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  color: #fff;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-2) 100%);
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(14, 124, 232, 0.2);
}

button:hover {
  filter: brightness(1.02);
}

button.danger {
  background: linear-gradient(90deg, #c93d3d 0%, #e46464 100%);
  box-shadow: none;
}

button.ghost {
  background: #e9f2fa;
  color: #215071;
  box-shadow: none;
}

button.ghost:hover {
  background: #dbeaf6;
}

.card-list {
  margin-top: 18px;
}

.page-section {
  display: none;
  margin-top: 18px;
}

.page-section.is-visible {
  display: block;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 560px;
  overflow: auto;
}

.groups-list {
  padding-right: 4px;
}

.cfg-accordion {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cfg-section {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(20, 43, 67, 0.05);
}

.cfg-summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #f6fbff;
  user-select: none;
}

.cfg-summary::-webkit-details-marker {
  display: none;
}

.cfg-summary:hover {
  background: #edf5ff;
}

.cfg-summary-label .eyebrow {
  font-size: 0.72rem;
  margin-bottom: 2px;
}

.cfg-summary-label strong {
  font-size: 1rem;
  color: var(--ink);
}

.cfg-chevron {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  position: relative;
}

.cfg-chevron::before,
.cfg-chevron::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 1.5px;
  background: var(--muted);
  border-radius: 2px;
}

.cfg-chevron::before { transform: translate(-2px, 0) rotate(45deg); }
.cfg-chevron::after  { transform: translate( 2px, 0) rotate(-45deg); }

.cfg-section[open] .cfg-chevron::before { transform: translate(-2px, 0) rotate(-45deg); }
.cfg-section[open] .cfg-chevron::after  { transform: translate( 2px, 0) rotate( 45deg); }

.cfg-body {
  padding: 18px;
  border-top: 1px solid var(--line);
}

.group-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

.group-item summary {
  list-style: none;
  cursor: pointer;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #f6fbff;
}

.group-item summary::-webkit-details-marker {
  display: none;
}

.group-total {
  font-weight: 700;
  color: var(--brand);
}

.group-summary-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.group-summary-side button {
  position: relative;
  z-index: 1;
}

.group-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 500px;
  overflow-y: auto;
}

.machine-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: rgba(250, 252, 254, 0.88);
}

.machine-cost {
  text-align: right;
}

.machine-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.machine-actions button {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.86rem;
}

.machine-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.code-text {
  font-family: 'Courier New', monospace;
  background: #f5f5f5;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  display: inline-block;
  max-width: 100%;
  word-break: break-all;
}

.monitoring-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: rgba(250, 252, 254, 0.88);
}

.monitoring-detail-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(250, 252, 254, 0.88);
  margin-bottom: 12px;
}

.detail-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.detail-section h4 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 1rem;
}

.monitoring-details-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  padding: 18px;
  border-radius: 14px;
  background: #f7fafc;
  border: 1px dashed var(--line);
  color: var(--muted);
}

.summary {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  text-align: right;
}

.summary .label {
  color: var(--muted);
}

.summary .value {
  color: var(--success);
  font-weight: 800;
  font-size: 1.45rem;
}

.machine-detail {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fbfdff;
}

.machine-detail h3 {
  margin: 8px 0;
}

.detail-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detail-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}

.detail-item span {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
}

.future-box {
  margin-top: 12px;
  border-radius: 12px;
  padding: 10px 12px;
  background: #eaf5ff;
}

.future-box h4 {
  margin: 0 0 8px;
}

.future-box ul {
  margin: 0;
  padding-left: 18px;
}

.json-editor {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.95);
}

.fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  font-size: 1.8rem;
  display: grid;
  place-items: center;
  box-shadow: 0 14px 30px rgba(14, 124, 232, 0.35);
  animation: fabPulse 5s infinite;
  z-index: 30;
}

@keyframes fabPulse {
  0%,
  84% {
    transform: scale(1);
    box-shadow: 0 14px 30px rgba(14, 124, 232, 0.35);
  }

  88% {
    transform: scale(1.08);
    box-shadow: 0 0 0 10px rgba(34, 183, 255, 0.15);
  }

  92% {
    transform: scale(1);
    box-shadow: 0 14px 30px rgba(14, 124, 232, 0.35);
  }

  100% {
    transform: scale(1);
  }
}

.fab-menu {
  position: fixed;
  right: 30px;
  bottom: 100px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 31;
}

.fab-menu button {
  min-width: 120px;
}

.hidden {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 27, 43, 0.42);
  z-index: 40;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 22px 46px rgba(16, 38, 58, 0.28);
  padding: 18px;
  z-index: 41;
}

.modal h3 {
  margin-top: 0;
}

.modal-tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
  background: #fff2f2;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.modal-copy {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 1rem;
}

.modal-warning-box {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid #f0caca;
  background: linear-gradient(180deg, #fff6f6 0%, #fff 100%);
}

.modal-warning-title {
  margin-bottom: 6px;
  font-weight: 700;
  color: #8b2929;
}

.modal-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff1f1;
  color: #8f2828;
  border: 1px solid #f0caca;
}

.modal-lg {
  width: min(860px, calc(100vw - 24px));
}

.modal-price-box {
  margin-top: 12px;
}

.catalog-grid,
.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.catalog-item,
.report-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fbfdff;
}

.catalog-item h3 {
  margin: 0 0 6px;
  font-size: 1.02rem;
}

.catalog-item p,
.report-box span {
  margin: 0;
  color: var(--muted);
}

.report-box strong {
  display: block;
  margin-top: 8px;
  font-size: 1.25rem;
  color: var(--brand);
}

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

  .sidebar {
    position: relative;
    height: auto;
  }

  .hero,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .card-preview {
    position: static;
  }

  .catalog-grid,
  .report-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .workspace {
    padding: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .machine-item {
    flex-direction: column;
  }

  .machine-actions {
    justify-content: flex-start;
  }

  .fab {
    right: 16px;
    bottom: 16px;
  }

  .fab-menu {
    right: 16px;
    bottom: 84px;
  }
}

/* ── Login Screen ─────────────────────────────────────────── */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-screen.hidden {
  display: none;
}

.login-card {
  width: 360px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 8px 40px rgba(20, 43, 67, 0.14);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-card .brand-mark {
  width: 48px;
  height: 48px;
  background: var(--primary);
  color: #fff;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.login-card h2 {
  font-size: 1.25rem;
  margin: 0 0 4px;
  color: var(--ink);
}

.login-error {
  font-size: 0.82rem;
  color: #c0392b;
  padding: 6px 10px;
  background: #fef0ee;
  border-radius: 6px;
  margin: 0;
}

.login-error.hidden {
  display: none;
}

.login-card button {
  width: 100%;
}

/* ── Sidebar user ─────────────────────────────────────────── */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  margin-top: auto;
  font-size: 0.82rem;
}

.sidebar-user.hidden {
  display: none;
}

.sidebar-user span {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.sidebar-user button {
  padding: 4px 10px;
  font-size: 0.75rem;
}

/* ── Role badges ──────────────────────────────────────────── */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.role-administrador {
  background: #e3f0ff;
  color: #1565c0;
}

.role-financeiro {
  background: #e8f5e9;
  color: #2e7d32;
}

.role-usuario {
  background: #f3e5f5;
  color: #6a1b9a;
}

/* ── User list items ──────────────────────────────────────── */
.user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.user-item:last-child {
  border-bottom: none;
}

.user-item-name {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

.user-item-actions {
  display: flex;
  gap: 6px;
}

.field-hint {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
}
