:root {
  --green-dark: #0b4f2a;
  --green-main: #67b346;
  --green-light: #e7f3e9;
  --orange: #f07a18;
  --white: #ffffff;
  --gray-50: #f5f5f5;
  --gray-100: #eef5f0;
  --gray-200: #d8dfdb;
  --gray-500: #5f6f64;
  --gray-medium: #6b6e72;
  --gray-medium-dark: #52555a;
  --gray-900: #14261d;
  --red-600: #dc2626;
  --red-50: #fef2f2;
  --shadow-soft: 0 12px 36px rgba(11, 79, 42, 0.12);
  --shadow-card: 0 8px 24px rgba(9, 39, 23, 0.1);
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --transition: 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  font-family: "Poppins", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--gray-900);
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: linear-gradient(150deg, #eef5f0 0%, #f8faf9 40%, #f1f7f2 100%);
}

body {
  display: flex;
  flex-direction: column;
}

#app { flex: 1; display: flex; flex-direction: column; }

.container {
  width: min(1280px, 94vw);
  margin-inline: auto;
}

.page { padding: 18px 0 40px; }

h1, h2, h3, h4 {
  font-family: "Montserrat", sans-serif;
  margin: 0;
  line-height: 1.2;
}

p { margin: 0 0 12px; }

a { color: inherit; text-decoration: none; }

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(115deg, #e5e7eb, #d1d5db);
  color: var(--gray-900);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.topbar a { color: var(--gray-900); }
.topbar-actions .btn-ghost { color: var(--gray-900); }
.topbar-actions .btn-ghost:hover { background: rgba(0,0,0,0.06); }

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
}

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

.topbar-logo img { height: 34px; width: auto; }

.topbar-title {
  font-family: "Montserrat", sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.1;
}

.topbar-subtitle {
  font-size: 0.72rem;
  opacity: 0.92;
  font-weight: 400;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 13px 22px;
  font-family: "Montserrat", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  text-align: center;
  min-height: 50px;
  touch-action: manipulation;
}

.btn:active { transform: scale(0.98); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(115deg, var(--green-dark), var(--green-main));
  color: white;
  box-shadow: var(--shadow-soft);
}

.btn-orange {
  background: var(--orange);
  color: white;
  box-shadow: 0 8px 20px rgba(240, 122, 24, 0.28);
}

.btn-danger {
  background: var(--red-600);
  color: white;
}

.btn-white {
  background: rgba(255, 255, 255, 0.95);
  color: var(--green-dark);
  border: 1px solid var(--gray-200);
}

.btn-ghost {
  background: transparent;
  color: var(--green-dark);
  border: 1px solid transparent;
}

.btn-block { width: 100%; }

.btn-lg {
  padding: 18px 26px;
  font-size: 1.08rem;
  min-height: 60px;
}

.btn-icon { padding: 12px; min-height: 46px; min-width: 46px; }

/* Cards */
.card {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 18px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* Formulários */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: 12px;
  padding: 13px 14px;
  font-family: inherit;
  font-size: 1rem;
  background: white;
  color: var(--gray-900);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-main);
  box-shadow: 0 0 0 3px rgba(103, 179, 70, 0.14);
}

textarea { min-height: 120px; resize: vertical; }

select { appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%235f6f64' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }

input[type="file"] { padding: 10px; }

.error-text { color: var(--red-600); font-size: 0.8rem; margin-top: 4px; }

/* Login */
.login-page { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }

.login-box {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 34px 24px;
  text-align: center;
}

.login-logo { height: 90px; width: auto; margin-bottom: 10px; }

.login-head { margin-bottom: 22px; }

.login-head h1 {
  color: var(--green-dark);
  font-size: 1.4rem;
  font-weight: 800;
}

.login-head p { color: var(--gray-500); font-size: 0.9rem; margin: 0; }

.login-version {
  font-size: 0.72rem;
  color: var(--gray-500);
  margin-top: 22px;
}

/* Dashboard / Status cards */
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.status-card {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  transition: transform var(--transition);
}

.status-card:active { transform: scale(0.98); }

.status-card .count {
  font-family: "Montserrat", sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--green-dark);
}

.status-card .label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Lista de chamados */
.ticket-list { display: flex; flex-direction: column; gap: 12px; }

.ticket-card {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  border-left: 5px solid var(--green-main);
}

.ticket-card:active { transform: scale(0.99); }

.ticket-card.priority-URGENTE { border-left-color: var(--red-600); }
.ticket-card.priority-ALTA { border-left-color: var(--orange); }
.ticket-card.priority-NORMAL { border-left-color: var(--green-main); }
.ticket-card.priority-BAIXA { border-left-color: var(--gray-200); }

.ticket-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ticket-number { font-family: "Montserrat", sans-serif; font-weight: 800; color: var(--green-dark); font-size: 0.95rem; }
.ticket-status { font-size: 0.7rem; font-weight: 700; padding: 4px 8px; border-radius: var(--radius-pill); background: var(--green-light); color: var(--green-dark); white-space: nowrap; }

.ticket-title { font-weight: 600; font-size: 0.95rem; }
.ticket-meta { font-size: 0.78rem; color: var(--gray-500); }

.priority-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 6px;
}

.priority-badge.URGENTE { background: var(--red-50); color: var(--red-600); }
.priority-badge.ALTA { background: #fff7ed; color: #c2410c; }
.priority-badge.NORMAL { background: #f0fdf4; color: #15803d; }
.priority-badge.BAIXA { background: #f8fafc; color: #475569; }

/* Detalhe do chamado */
.detail-section { margin-bottom: 20px; }
.detail-section h2 { font-size: 0.84rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }

.timeline { border-left: 2px solid var(--gray-200); margin-left: 8px; padding-left: 14px; }
.timeline-item { position: relative; padding-bottom: 14px; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green-main);
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--green-main);
}
.timeline-time { font-size: 0.72rem; color: var(--gray-500); }
.timeline-text { font-size: 0.9rem; }
.timeline-user { font-size: 0.75rem; color: var(--gray-500); }

/* Botões de ação grandes */
.action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--gray-200);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px rgba(0,0,0,0.06);
  z-index: 40;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}

.action-bar .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.with-action-bar { padding-bottom: 100px; }

/* Toast */
#toast-area {
  position: fixed;
  top: 14px;
  right: 14px;
  left: 14px;
  z-index: 100;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  pointer-events: auto;
  background: var(--gray-900);
  color: white;
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  font-size: 0.9rem;
  animation: slideIn 0.25s ease;
}

.toast.success { background: var(--green-dark); }
.toast.error { background: var(--red-600); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modal simples */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 38, 29, 0.55);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  padding: 22px 18px;
  animation: modalUp 0.2s ease;
}

@keyframes modalUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Signature pad */
.signature-pad {
  width: 100%;
  height: 220px;
  border: 2px dashed var(--gray-200);
  border-radius: 12px;
  background: white;
  touch-action: none;
}

/* Tabela */
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--gray-200); }
th { color: var(--gray-500); font-weight: 700; text-transform: uppercase; font-size: 0.7rem; }

/* Utilitários */
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.text-orange { color: var(--orange); }
.text-red { color: var(--red-600); }
.font-bold { font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.skeleton { background: #e0e7e3; border-radius: 10px; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Desktop */
@media (min-width: 1024px) {
  .status-grid { grid-template-columns: repeat(4, 1fr); }
  .modal-overlay { align-items: center; }
  .modal { width: 520px; max-height: 80vh; }
  .action-bar { position: static; box-shadow: none; border-top: 0; padding: 0; }
  .with-action-bar { padding-bottom: 20px; }
}

@media print {
  .topbar, .action-bar, #toast-area { display: none !important; }
}
