:root {
  /* Apple System Colors & Variables */
  --bg: #F5F5F7; /* Apple System Gray 6 (Light) */
  --card: rgba(255, 255, 255, 0.85); /* Translucent White */
  --text: #1D1D1F; /* Apple Text Black */
  --muted: #86868B; /* Apple Text Gray */
  --primary: #0071E3; /* Apple System Blue */
  --brand: #8a3ffc;
  --border: #D2D2D7; /* Apple System Gray 4 */
  --accent: #F5F5F7;
  --input-bg: rgba(118, 118, 128, 0.12); /* Apple Field Gray */
  --focus-ring: rgba(0, 113, 227, 0.4);
}
* { box-sizing: border-box; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
html, body { height: 100% }
.hidden { display: none !important }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.47059;
  letter-spacing: -0.022em;
}
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px; /* Apple headers are often compact or 44px-50px */
  padding: 0 24px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.header-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  height: 100%;
  text-decoration: none;
  background: linear-gradient(90deg, #ff6b6b, #feca57, #ff9ff3, #54a0ff, #5dfc96, #ff6b6b);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: brandHue 6s linear infinite;
}
.top-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: auto;
  white-space: nowrap;
}
.top-nav.hidden { display: none }
.top-nav-item {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  transition: background 0.1s, color 0.1s;
}
.top-nav-item:hover {
  background: rgba(0, 113, 227, 0.12);
  color: var(--primary);
}
.brand-img {
  height: 28px;
  width: auto;
  display: inline-block;
}
.brand-logo {
  height: 28px;
  width: 28px;
  margin-right: 8px;
  vertical-align: middle;
  display: inline-block;
  flex: 0 0 auto;
}
@keyframes brandHue {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}
.hamburger {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
}
.menu-panel {
  position: absolute;
  right: 16px;
  top: 60px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  padding: 8px;
  width: 260px;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 100;
  transform-origin: top right;
  animation: menuEnter 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.menu-panel.hidden { display: none }
.menu-group { 
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.menu-group:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.menu-title { 
  font-size: 11px; 
  font-weight: 600;
  color: var(--muted); 
  margin: 8px 12px 4px;
  text-transform: uppercase;
}
.menu-item {
  display: block;
  text-decoration: none;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  transition: background 0.1s;
}
.menu-item:hover { 
  background: var(--primary); 
  color: #fff; 
}
.menu-item:active {
  background: #0062c3; /* Darker blue */
}
.checkbox-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.2s;
  cursor: pointer;
}
.checkbox-group label:hover {
  background: #f9f9fa;
}
.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
}
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
  margin: 2px 6px 2px 0;
}
.badge-primary { background: rgba(0, 113, 227, 0.12); color: var(--primary) }
.badge-warn { background: rgba(255, 149, 0, 0.16); color: #b85c00 }
.badge-success { background: rgba(52, 199, 89, 0.16); color: #1f7a37 }
main#app {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
}
body.has-cliente-bottom-nav main#app {
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.82);
  border-top: 1px solid rgba(0,0,0,0.08);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--muted);
  min-height: 56px;
  transition: background 0.12s ease, color 0.12s ease;
}
.bottom-nav-item:active {
  background: rgba(0, 113, 227, 0.10);
}
.bottom-nav-item.active {
  color: var(--primary);
  background: rgba(0, 113, 227, 0.10);
}
.bottom-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.bottom-nav-label {
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.keyboard-open .bottom-nav {
  display: none !important;
}
@media (min-width: 768px) {
  body.has-cliente-bottom-nav main#app {
    padding-bottom: 0;
  }
  .bottom-nav {
    display: none !important;
  }
}
@media (max-width: 767px) {
  #topNavCliente {
    display: none !important;
  }
}
.view.hidden { display: none }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.03);
}
h2, h3 { margin: 0 0 12px 0 }
.h2-mark { margin-right: 8px; color: var(--muted); font-weight: 600; letter-spacing: 0.5px }
.icon-link { margin-left: 8px; color: var(--muted); text-decoration: none; vertical-align: middle }
.icon-link:hover { color: var(--primary) }
.icon-link svg { display: inline-block }
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 6px }
.field.full { grid-column: 1 / -1 }
label { font-size: 12px; color: var(--muted) }
input, select {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}
textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  resize: vertical;
}
.divider {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--border);
  margin: 6px 0 2px 0;
}
.radio-group { display: flex; gap: 12px; flex-wrap: wrap }
.radio-group label { display: inline-flex; align-items: center; gap: 8px }
.input-with-actions { display: flex; gap: 8px; align-items: center }
.input-with-actions input { flex: 1 }
.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.preset-actions { justify-content: flex-start; flex-wrap: wrap }
.form-actions { justify-content: flex-end; flex-wrap: wrap }
.btn {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 0 14px;
  color: var(--text);
  cursor: pointer;
}
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px }
.btn-group { display: flex; flex-wrap: wrap; gap: 6px }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn[disabled] { opacity: .5; cursor: not-allowed }
.table-wrap {
  overflow: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
/* Tables - iOS/macOS Style */
.table-wrap {
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
thead tr { 
  background: #fafafa; 
}
th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.02em;
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  color: var(--text);
  transition: background 0.1s;
}
tr:last-child td {
  border-bottom: none;
}
tbody tr:hover td {
  background: var(--accent);
}
td .btn {
  height: 28px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: 14px;
}

/* Summaries & Filters */
.summary {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.total { font-weight: 600; font-size: 16px; }
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.filters { display: flex; gap: 8px; }
.filters select { width: 160px }
.filters input { width: 200px }
#view-home .filters { margin-bottom: 16px }
.muted { color: var(--muted) }

/* KPIs - Widget Style */
.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.kpi {
  border: none;
  border-radius: 18px;
  padding: 24px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  transition: transform 0.2s;
}
.kpi:hover { transform: translateY(-2px); }
.kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kpi-value {
  margin-top: 0;
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.table-total-row { background: var(--accent) }
.table-total-row td { font-weight: 600; border-top: 2px solid var(--primary) }

/* Modal - Sheet Style */
.modal.hidden { display: none }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 999;
  transition: opacity 0.2s;
}
.modal .modal-content {
  max-width: 700px;
  width: 100%;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: none;
  padding: 32px;
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.drawer {
  justify-content: flex-end;
}
.modal.drawer .modal-content {
  max-width: 520px;
  height: min(90vh, 760px);
  overflow: auto;
  border-radius: 24px 0 0 24px;
  animation: drawerSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes drawerSlideIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes modalSlideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Loading Spinner - iOS Style */
.loading-overlay.hidden { display: none }
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(5px);
  z-index: 1000;
  pointer-events: none;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0,0,0,0.1);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg) }
}

/* Estilos específicos para a tela de Login Apple-style */
#view-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}
#view-login .card {
  width: 100%;
  max-width: 440px;
  padding: 40px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}
#view-login h2 {
  text-align: center;
  margin-bottom: 32px;
  font-size: 28px;
}
#view-login h2 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
#view-login .h2-logo {
  height: 44px;
  width: auto;
  margin: 0 auto;
  vertical-align: middle;
}
#view-login .h2-label {
  font-size: 18px;
  font-weight: 600;
  color: var(--muted);
  vertical-align: middle;
}
#view-login .form-grid {
  grid-template-columns: 1fr;
  gap: 14px;
}
#view-login .field {
  gap: 8px;
}
#view-login label {
  font-size: 13px;
}
#view-login input {
  height: 44px;
  font-size: 16px;
}
#view-login .actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
#view-login .btn.primary {
  width: 100%;
  margin-top: 8px;
  height: 44px;
  font-size: 16px;
}
/* Responsividade */
@media (max-width: 900px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 600px) {
  .kpis {
    grid-template-columns: 1fr;
  }
  .list-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .filters select,
  .filters input {
    width: 100%;
  }
  .summary {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
