@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --navy: #0d2137;
  --navy-mid: #15304d;
  --navy-light: #1c4066;
  --teal: #009688;
  --teal-hover: #00796b;
  --teal-pale: #e0f2f1;
  --red: #c62828;
  --bg: #f0f2f5;
  --surface: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #5a6478;
  --text-muted: #9aa4b2;
  --line: #e2e6ec;
  --ok: #2e7d32;
  --warn: #e65100;
  --bad: #c62828;
  --blue: #1565c0;
  --elevation-1: 0 1px 3px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.03);
  --elevation-2: 0 4px 16px rgba(0,0,0,.06);
  --elevation-3: 0 12px 40px rgba(0,0,0,.12);
  --r: 8px;
  --r-lg: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ====== LOGIN ====== */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 50%, var(--teal) 100%);
  padding: 20px;
}

.login-box {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  text-align: center;
}

.login-box .logo { width: 180px; margin-bottom: 8px; }
.login-box h2 { color: var(--navy); margin-bottom: 4px; font-size: 1.2rem; font-weight: 700; }
.login-box .subtitle { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 28px; }

.form-group { margin-bottom: 14px; text-align: left; }
.form-group label {
  display: block; font-weight: 600; margin-bottom: 6px;
  font-size: 0.8rem; color: var(--text-primary); letter-spacing: .01em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  font-size: 16px; /* prevents zoom on iOS */
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  background: #fff;
  color: var(--text-primary);
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,150,136,.1);
}

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

.error-msg { color: var(--bad); font-size: 0.82rem; margin-top: 8px; display: none; }

/* ====== BUTTONS ====== */
.btn {
  padding: 10px 18px;
  border: none;
  border-radius: var(--r);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 40px;
}
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-hover); }
.login-box .btn-primary { width: 100%; padding: 13px; font-size: 0.95rem; }

.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-mid); }

.btn-success { background: var(--ok); color: #fff; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-warning { background: var(--warn); color: #fff; }

.btn-sm { padding: 7px 14px; font-size: 0.76rem; min-height: 34px; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--text-primary);
}
.btn-outline:hover { background: var(--bg); border-color: var(--text-muted); }

/* ====== APP LAYOUT ====== */
.app-container { display: none; }

/* Top Bar */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 120;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

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

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--r);
  -webkit-tap-highlight-color: transparent;
}
.menu-toggle svg { width: 22px; height: 22px; }
.menu-toggle:active { background: rgba(255,255,255,.1); }

.topbar-logo { height: 30px; filter: brightness(0) invert(1); }

.topbar-title {
  color: rgba(255,255,255,.8);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: .02em;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }

.topbar-user { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 0.82rem; }

.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--teal);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; color: #fff;
  flex-shrink: 0;
}

.topbar-user-info { line-height: 1.3; }
.topbar-user-role { font-size: 0.7rem; color: rgba(255,255,255,.5); }

.topbar-logout {
  background: none;
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.7);
  padding: 6px 14px;
  border-radius: var(--r);
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
  transition: .15s;
  -webkit-tap-highlight-color: transparent;
}
.topbar-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 56px;
  width: 220px;
  height: calc(100vh - 56px);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: .15s;
  font-size: 0.84rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  margin: 1px 0;
  -webkit-tap-highlight-color: transparent;
}

.nav-item:hover { background: var(--bg); color: var(--text-primary); }

.nav-item.active {
  background: var(--teal-pale);
  color: var(--teal-hover);
  border-left-color: var(--teal);
  font-weight: 600;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 2.2; }

/* Main Content */
.main-content {
  margin-left: 220px;
  margin-top: 56px;
  padding: 24px 28px;
  min-height: calc(100vh - 56px);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
}

/* ====== STATS GRID ====== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--elevation-1);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: box-shadow .15s, transform .15s;
}
.stat-card:hover { box-shadow: var(--elevation-2); transform: translateY(-1px); }

.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }

.stat-total .stat-icon { background: var(--teal-pale); color: var(--teal); }
.stat-pending .stat-icon { background: #fff8e1; color: #f9a825; }
.stat-progress .stat-icon { background: #e3f2fd; color: #1976d2; }
.stat-done .stat-icon { background: #e8f5e9; color: #2e7d32; }
.stat-urgent .stat-icon { background: #ffebee; color: #c62828; }

.stat-info h3 { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.stat-info p {
  font-size: 0.7rem; color: var(--text-muted); margin-top: 2px;
  text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
}

/* ====== CARD ====== */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--elevation-1);
  border: 1px solid var(--line);
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 { font-size: 0.86rem; font-weight: 600; color: var(--text-primary); }

.card-body { padding: 0; }

/* ====== FILTERS ====== */
.filters {
  padding: 12px 18px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  align-items: center;
  background: #fafbfc;
}

.filters input, .filters select {
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  background: #fff;
  min-height: 36px;
}
.filters input:focus, .filters select:focus { border-color: var(--teal); }

/* ====== TABLE ====== */
table { width: 100%; border-collapse: collapse; }

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  font-size: 0.84rem;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

tbody tr:hover { background: #f8fafb; }

/* ====== BADGES ====== */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-pendente { background: #fef3c7; color: #92400e; }
.badge-em_andamento { background: #dbeafe; color: #1e40af; }
.badge-concluido { background: #d1fae5; color: #065f46; }
.badge-cancelado { background: #fee2e2; color: #991b1b; }

.badge-baixa { background: #d1fae5; color: #065f46; }
.badge-normal { background: #fef3c7; color: #92400e; }
.badge-alta { background: #fed7aa; color: #9a3412; }
.badge-urgente { background: #fee2e2; color: #991b1b; }

.badge-admin { background: #ede9fe; color: #5b21b6; }
.badge-gestor { background: #dbeafe; color: #1e40af; }
.badge-usuario { background: #f3f4f6; color: #4b5563; }
.badge-manutencao { background: #fef3c7; color: #92400e; }

.actions-cell { display: flex; gap: 4px; flex-wrap: nowrap; }

/* ====== MOBILE CARD LIST ====== */
.mobile-card-list {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

.m-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  box-shadow: var(--elevation-1);
}

.m-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.m-card-id {
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--navy);
}

.m-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 0.82rem;
}

.m-card-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.m-card-value {
  color: var(--text-primary);
  font-size: 0.84rem;
}

.m-card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 6px 0 10px;
  line-height: 1.4;
}

.m-card-actions {
  display: flex;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid #f3f4f6;
}

.m-card-actions .btn { flex: 1; font-size: 0.76rem; }

/* ====== SWIPE-TO-CONCLUDE MOBILE ====== */
.m-card-swipe-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  margin-bottom: 0;
}

.m-card-swipe-wrapper .m-card {
  position: relative;
  z-index: 2;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  touch-action: pan-y;
  will-change: transform;
}

.m-card-swipe-wrapper .m-card.swiping {
  transition: none;
}

.swipe-action {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
  border-radius: 0 var(--r-lg) var(--r-lg) 0;
  gap: 4px;
}

.swipe-action-complete {
  background: linear-gradient(135deg, #2e7d32, #43a047);
  color: #fff;
}

.swipe-action svg {
  width: 28px;
  height: 28px;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .2s, transform .2s;
}

.swipe-action span {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity .2s;
}

.m-card-swipe-wrapper.revealing .swipe-action svg,
.m-card-swipe-wrapper.revealing .swipe-action span {
  opacity: 1;
  transform: scale(1);
}

/* Quick-conclude button on each mobile card */
.m-card-conclude-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  margin-top: 10px;
  background: linear-gradient(135deg, #2e7d32, #43a047);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform .12s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 48px;
  box-shadow: 0 2px 8px rgba(46,125,50,.25);
}

.m-card-conclude-btn:active {
  transform: scale(.96);
}

.m-card-conclude-btn svg {
  width: 20px;
  height: 20px;
}

/* Swipe hint indicator */
.swipe-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

.swipe-hint svg {
  width: 14px;
  height: 14px;
  animation: swipeHintAnim 2s ease-in-out infinite;
}

@keyframes swipeHintAnim {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-6px); }
}

/* ====== CONCLUSION BOTTOM-SHEET ====== */
.conclude-sheet {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1100;
}

.conclude-sheet.active {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.conclude-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13,33,55,.5);
  backdrop-filter: blur(3px);
  animation: fadeIn .2s ease;
}

.conclude-sheet-content {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 0;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  animation: sheetSlideUp .3s cubic-bezier(.32,.72,0,1);
  -webkit-overflow-scrolling: touch;
}

@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.conclude-sheet-handle {
  width: 36px;
  height: 4px;
  background: #d1d5db;
  border-radius: 2px;
  margin: 10px auto 0;
}

.conclude-sheet-header {
  padding: 16px 20px 12px;
  text-align: center;
}

.conclude-sheet-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.conclude-sheet-header .sheet-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.conclude-sheet-info {
  margin: 0 20px 16px;
  padding: 14px;
  background: var(--teal-pale);
  border-radius: var(--r);
  border-left: 4px solid var(--teal);
}

.conclude-sheet-info .info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 4px;
}
.conclude-sheet-info .info-row:last-child { margin-bottom: 0; }
.conclude-sheet-info .info-label { color: var(--text-secondary); font-weight: 500; }
.conclude-sheet-info .info-value { color: var(--text-primary); font-weight: 600; }

.conclude-sheet-form {
  padding: 0 20px 16px;
}

.conclude-sheet-form .form-group { margin-bottom: 14px; }

.conclude-sheet-actions {
  padding: 0 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-conclude-big {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #2e7d32, #43a047);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-height: 56px;
  box-shadow: 0 4px 16px rgba(46,125,50,.3);
  transition: transform .12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-conclude-big:active { transform: scale(.97); }

.btn-conclude-big svg { width: 22px; height: 22px; }

.btn-conclude-cancel {
  width: 100%;
  padding: 14px;
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

/* ====== SUCCESS ANIMATION ====== */
.conclude-success-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(46,125,50,.92);
  z-index: 1200;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  animation: fadeIn .3s ease;
}

.conclude-success-overlay.active { display: flex; }

.success-check {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: successPop .4s cubic-bezier(.175,.885,.32,1.275) forwards;
}

.success-check svg {
  width: 44px;
  height: 44px;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: checkDraw .5s .2s ease forwards;
}

.success-text {
  margin-top: 20px;
  font-size: 1.2rem;
  font-weight: 700;
  opacity: 0;
  animation: fadeInUp .4s .3s ease forwards;
}

.success-subtext {
  margin-top: 6px;
  font-size: 0.88rem;
  opacity: 0;
  animation: fadeInUp .4s .45s ease forwards;
}

@keyframes successPop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes checkDraw {
  to { stroke-dashoffset: 0; }
}

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

/* ====== MODALS ====== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13,33,55,.45);
  backdrop-filter: blur(3px);
  z-index: 1000;
  justify-content: center;
  align-items: flex-end;
  padding: 0;
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  width: 100%;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: var(--elevation-3);
  -webkit-overflow-scrolling: touch;
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-header h3 { color: var(--text-primary); font-size: 1rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  line-height: 1;
  border-radius: var(--r);
  transition: .12s;
  -webkit-tap-highlight-color: transparent;
}
.modal-close:hover { background: var(--bg); color: var(--text-primary); }

.modal-body { padding: 20px; }
.modal-info { margin-bottom: 16px; color: var(--text-secondary); font-size: 0.88rem; }

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding-bottom: calc(14px + var(--safe-bottom));
}

/* ====== DETAIL VIEW ====== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-item label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 2px;
}

.detail-item span {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.detail-desc {
  background: #f8f9fa;
  padding: 12px;
  border-radius: var(--r);
  margin-top: 4px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.detail-obs {
  background: #fffbeb;
  padding: 12px;
  border-radius: var(--r);
  margin-top: 4px;
  font-size: 0.88rem;
  line-height: 1.5;
  border-left: 3px solid #f9a825;
}

/* ====== TIMELINE ====== */
.timeline { padding: 12px 0; }
.timeline-title {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}
.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--teal);
  margin-top: 6px;
  flex-shrink: 0;
}

.timeline-content { flex: 1; }
.timeline-content .action { font-weight: 600; font-size: 0.84rem; color: var(--text-primary); }
.timeline-content .details { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }
.timeline-content .meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; }

/* ====== USER CARDS ====== */
.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #f3f4f6;
  gap: 10px;
}
.user-card:last-child { border-bottom: none; }
.user-card .user-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }

.user-card .avatar {
  width: 38px; height: 38px;
  border-radius: var(--r);
  background: var(--navy);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.84rem;
  flex-shrink: 0;
}

.user-card .name { font-weight: 600; font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .role { font-size: 0.74rem; color: var(--text-muted); }

.user-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

/* ====== CONFIG CARDS ====== */
.config-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--elevation-1);
  border: 1px solid var(--line);
  margin-bottom: 14px;
  overflow: hidden;
}

.config-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.config-card-header svg { color: var(--text-secondary); flex-shrink: 0; }
.config-card-header h3 { font-size: 0.88rem; font-weight: 600; }

.config-card-body { padding: 18px; }

.config-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 12px;
}

/* ====== WHATSAPP STATUS ====== */
.wa-status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--r);
  font-size: 0.84rem;
  font-weight: 500;
  margin-bottom: 14px;
}

.wa-status-bar.online { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.wa-status-bar.offline { background: #fff3e0; color: #e65100; border: 1px solid #ffe0b2; }

.wa-status-bar .indicator {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.wa-status-bar.online .indicator { background: #2e7d32; }
.wa-status-bar.offline .indicator { background: #e65100; }

.wa-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.qr-area {
  text-align: center;
  margin: 14px 0;
  padding: 20px;
  background: #f8fafb;
  border-radius: var(--r);
  border: 1.5px dashed var(--line);
}

.qr-title { font-weight: 600; font-size: 0.84rem; color: var(--navy); margin-bottom: 10px; }
.qr-image { max-width: 260px; width: 100%; border-radius: var(--r); }
.qr-hint { margin-top: 10px; font-size: 0.74rem; color: var(--text-muted); }

/* ====== TOAST ====== */
.toast-container {
  position: fixed;
  top: 64px;
  right: 16px;
  left: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 11px 18px;
  border-radius: var(--r);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: var(--elevation-2);
  animation: toastIn .25s ease;
  max-width: 360px;
  pointer-events: auto;
}

.toast.success { background: var(--ok); }
.toast.error { background: var(--bad); }
.toast.warning { background: var(--warn); }
.toast.info { background: var(--blue); }

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

/* ====== PAGINATION ====== */
.pagination {
  padding: 14px 18px;
  display: flex;
  justify-content: center;
  gap: 4px;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  transition: .12s;
  min-height: 34px;
  min-width: 34px;
}
.pagination button:hover { background: var(--bg); }
.pagination button.active { background: var(--teal); color: #fff; border-color: var(--teal); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ====== SECTIONS ====== */
.page-section { display: none; }
.page-section.active { display: block; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state p { font-size: 0.9rem; }

/* ====== BOTTOM NAV (mobile) ====== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 110;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s;
  font-size: 0.62rem;
  font-weight: 500;
  gap: 2px;
  position: relative;
}

.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--teal); }
.bottom-nav-item.active span { font-weight: 700; }

.fab-item { padding: 0; }
.fab {
  width: 48px; height: 48px;
  background: var(--teal);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,150,136,.3);
  margin-top: -14px;
}
.fab svg { width: 22px; height: 22px; }

/* Loading */
.spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== DESKTOP (default) ====== */
.desktop-only { display: block; }

/* ====== RESPONSIVE ====== */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  /* Show mobile elements */
  .menu-toggle { display: block; }
  .bottom-nav { display: flex; justify-content: space-around; align-items: flex-end; }
  .desktop-only { display: none !important; }
  .mobile-card-list { display: flex; }

  /* Hide sidebar by default */
  .sidebar { transform: translateX(-100%); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open ~ .sidebar-overlay,
  .sidebar-overlay.active { display: block; }

  /* Main content */
  .main-content {
    margin-left: 0;
    padding: 16px 14px;
    margin-top: 56px;
    padding-bottom: calc(80px + var(--safe-bottom));
  }

  .page-header { margin-bottom: 14px; }
  .page-header h1 { font-size: 1.1rem; }

  /* Stats grid - 2+3 layout */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-icon svg { width: 17px; height: 17px; }
  .stat-info h3 { font-size: 1.2rem; }
  .stat-info p { font-size: 0.64rem; }

  /* Make last stat-card (urgentes) span full width if odd */
  .stats-grid .stat-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  /* Filters */
  .filters {
    flex-direction: column;
    padding: 12px 14px;
  }
  .filters input, .filters select { width: 100%; }

  /* Modals - bottom sheet style */
  .modal-overlay { align-items: flex-end; }
  .modal { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; }
  .modal-lg { max-height: 95vh; max-height: 95dvh; }
  .form-row { grid-template-columns: 1fr; }

  /* User cards */
  .user-card { flex-wrap: wrap; padding: 12px 14px; }
  .user-card-actions { width: 100%; margin-top: 8px; }

  /* Toast */
  .toast-container { top: 64px; left: 12px; right: 12px; align-items: stretch; }
  .toast { max-width: 100%; }

  /* Topbar adjustments */
  .topbar { padding: 0 12px; }
  .topbar-title { display: none; }
  .topbar-user-info { display: none; }
}

@media (max-width: 380px) {
  .login-box { padding: 28px 20px; }
  .stats-grid { gap: 6px; }
  .stat-card { padding: 10px; }
  .stat-info h3 { font-size: 1rem; }
  .m-card { padding: 12px; }
  .m-card-conclude-btn { min-height: 44px; font-size: 0.82rem; padding: 10px; }
}

/* Handle landscape on mobile */
@media (max-height: 500px) and (max-width: 768px) {
  .modal { max-height: 98vh; }
}
