@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=JetBrains+Mono:wght@400;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f5f3ef;
  --surface:  #ffffff;
  --surface2: #f0ede7;
  --border:   #e0dbd2;
  --border2:  #ccc8be;
  --text:     #111111;
  --text2:    #555;
  --text3:    #999;
  --accent:   #111111;
  --yellow:   #f5c400;
  --green:    #1a8a3c;
  --green-bg: #e8f5ed;
  --red:      #c0392b;
  --red-bg:   #fdecea;
  --radius:   10px;
  --shadow:   0 2px 12px rgba(0,0,0,0.07);
}

html { font-size: 16px; }

body {
  font-family: 'Syne', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-y: auto;
}

/* ── PÁGINA DE LOGIN ────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 48px 44px;
  width: 420px;
  box-shadow: var(--shadow);
}

.login-logo {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.login-logo span { color: var(--yellow); background: var(--text); padding: 0 6px; border-radius: 4px; }

.login-sub {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 36px;
  font-weight: 400;
  letter-spacing: 0.5px;
}

.login-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 6px;
  display: block;
}

.login-input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: 'JetBrains Mono', monospace;
  background: var(--surface2);
  color: var(--text);
  margin-bottom: 16px;
  transition: border-color .15s, background .15s;
}

.login-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.login-btn {
  width: 100%;
  padding: 16px;
  background: var(--text);
  color: var(--yellow);
  border: none;
  border-radius: var(--radius);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: .15s;
  margin-top: 4px;
}

.login-btn:hover { background: #2a2a2a; }

.login-error {
  background: var(--red-bg);
  border: 1px solid #f5c0bc;
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}

.login-error.show { display: block; }

/* ── LAYOUT PRINCIPAL ───────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 28px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 0 24px 28px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 20px;
}

.sidebar-brand-name {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.sidebar-brand-name em {
  color: var(--yellow);
  font-style: normal;
}

.sidebar-brand-role {
  font-size: 11px;
  color: rgba(255,255,255,.4);
  letter-spacing: 1px;
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 0 12px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 8px;
  color: rgba(255,255,255,.55);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: .15s;
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item .nav-icon { font-size: 16px; width: 20px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(245,196,0,.15); color: var(--yellow); }

.sidebar-logout {
  padding: 0 12px;
  margin-top: 8px;
}

.sidebar-logout button {
  width: 100%;
  padding: 11px 14px;
  background: none;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  color: rgba(255,255,255,.4);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  transition: .15s;
}

.sidebar-logout button:hover { border-color: var(--red); color: #ff6b6b; }

/* Conteúdo principal */
.main-content {
  flex: 1;
  padding: 32px 36px;
  overflow-y: auto;
  min-width: 0;
}

/* ── CABEÇALHO DA SEÇÃO ─────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.section-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.section-subtitle {
  font-size: 13px;
  color: var(--text3);
  margin-top: 2px;
}

/* Status pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.status-pill.online  { background: var(--green-bg); color: var(--green); }
.status-pill.offline { background: var(--red-bg); color: var(--red); }
.status-pill::before { content: '●'; font-size: 8px; }

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 8px;
}

.card-value {
  font-size: 32px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -1px;
}

.card-value.green { color: var(--green); }
.card-value.red   { color: var(--red); }

/* Grid de métricas */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color .15s, transform .15s;
}

.metric-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.metric-card::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: var(--yellow); }

.metric-label { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text3); margin-bottom: 10px; }
.metric-value { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 700; color: var(--text); }
.metric-sub   { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* ── BOTÕES ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  border: none;
  transition: .15s;
}

.btn-primary {
  background: var(--text);
  color: var(--yellow);
}
.btn-primary:hover { background: #333; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border2);
}
.btn-outline:hover { border-color: var(--text); background: var(--surface2); }

.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover { background: #a93226; }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #156f30; }

.btn-lg { padding: 18px 28px; font-size: 15px; letter-spacing: 2px; }
.btn-sm { padding: 8px 14px; font-size: 11px; }

.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Botão gigante GERAR TICKET */
.btn-gerar {
  width: 100%;
  padding: 28px;
  background: var(--text);
  color: var(--yellow);
  border: none;
  border-radius: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
  cursor: pointer;
  transition: .15s;
  position: relative;
  overflow: hidden;
}

.btn-gerar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: var(--yellow);
  transform: scaleX(0);
  transition: transform .3s;
}

.btn-gerar:hover { background: #1a1a1a; }
.btn-gerar:hover::after { transform: scaleX(1); }
.btn-gerar:active { transform: scale(.99); }

/* ── TABELAS ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; }

thead th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
  padding: 10px 16px;
  background: var(--surface2);
  border-bottom: 1.5px solid var(--border);
  text-align: left;
}

tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }

.codigo-cell {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 3px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.badge-livre  { background: var(--green-bg); color: var(--green); }
.badge-usado  { background: var(--red-bg);   color: var(--red); }

/* ── INPUTS ─────────────────────────────────────────────────── */
input, select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: 'Syne', sans-serif;
  background: var(--surface2);
  color: var(--text);
  transition: .15s;
  margin-bottom: 12px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--text);
  background: #fff;
}

label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 6px;
  display: block;
}

/* ── MODAL ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 440px;
  max-width: 96vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  animation: slideUp .2s ease;
}

@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.3px;
  margin-bottom: 4px;
}

.modal-sub { font-size: 13px; color: var(--text3); margin-bottom: 24px; }

.modal-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ── PREVIEW TICKET ─────────────────────────────────────────── */
.ticket-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ticket-preview-overlay.hidden { display: none; }

.ticket-card {
  background: #fff;
  border-radius: 18px;
  padding: 36px 40px;
  width: 320px;
  text-align: center;
  border: 2px solid var(--text);
  box-shadow: 0 24px 64px rgba(0,0,0,.22);
  animation: slideUp .2s ease;
}

.ticket-posto   { font-size: 11px; font-weight: 700; letter-spacing: 2px; color: var(--text3); margin-bottom: 4px; }
.ticket-codigo  { font-family: 'JetBrains Mono', monospace; font-size: 40px; font-weight: 700; letter-spacing: 6px; color: var(--text); margin: 12px 0; }
.ticket-canvas  { margin: 16px auto; display: block; }
.ticket-data    { font-size: 12px; color: var(--text3); margin-bottom: 24px; }
.ticket-actions { display: flex; gap: 10px; }

/* ── TOAST ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 16px 28px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  transition: bottom .4s cubic-bezier(.34,1.56,.64,1);
  z-index: 1100;
  white-space: nowrap;
}

.toast.show { bottom: 36px; }

.toast-icon {
  width: 26px; height: 26px;
  background: var(--yellow);
  color: var(--text);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; flex-shrink: 0;
}

.toast-title { font-size: 13px; font-weight: 700; }
.toast-body  { font-size: 12px; color: rgba(255,255,255,.6); }

/* ── PAGINAÇÃO ─────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; justify-content: flex-end; margin-top: 16px; }

.page-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: .15s;
  display: flex; align-items: center; justify-content: center;
}

.page-btn:hover { border-color: var(--text); }
.page-btn.active { background: var(--text); color: var(--yellow); border-color: var(--text); }

/* ── IoT ───────────────────────────────────────────────────── */
.iot-status-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1.5px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ── ÁREA DE IMPRESSÃO ─────────────────────────────────────── */
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area {
    display: block !important;
    width: 80mm;
    padding: 8mm;
    font-family: 'JetBrains Mono', monospace;
    text-align: center;
  }
  .p-nome  { font-size: 14pt; font-weight: 700; margin-bottom: 4px; }
  .p-sub   { font-size: 9pt; color: #666; margin-bottom: 10px; }
  .p-linha { border-top: 1px dashed #aaa; margin: 8px 0; }
  .p-cod   { font-size: 30pt; font-weight: 700; letter-spacing: 5px; margin: 8px 0; }
  .p-qr    { display: block; margin: 10px auto; }
  .p-info  { font-size: 9pt; color: #555; margin-top: 6px; }
}

/* ── RESPONSIVO ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 20px 16px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}