:root {
  --v8-ink: #102218;
  --v8-muted: #627267;
  --v8-green-950: #052719;
  --v8-green-900: #073923;
  --v8-green-800: #075a32;
  --v8-green-700: #087443;
  --v8-green-100: #e5f4eb;
  --v8-surface: #ffffff;
  --v8-canvas: #eef3f0;
  --v8-border: #d9e3dc;
  --v8-shadow: 0 12px 38px rgba(5, 39, 25, .08);
  --v8-shadow-hover: 0 18px 46px rgba(5, 39, 25, .12);
}

.v8-icon {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  flex: 0 0 auto;
}

.nav .ico .v8-icon {
  width: 1.1rem;
  height: 1.1rem;
}

.stat .label .v8-icon {
  width: 1.15rem;
  height: 1.15rem;
  color: var(--v8-green-700);
}

.bottom-nav .v8-icon,
.float-assist .v8-icon {
  margin: auto;
}

.eye-btn .v8-icon {
  width: 1.05rem;
  height: 1.05rem;
}

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(circle at 88% -10%, rgba(8, 116, 67, .09), transparent 28rem),
    var(--v8-canvas);
  color: var(--v8-ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; }

button {
  border-radius: 10px;
  min-height: 40px;
  box-shadow: none;
  letter-spacing: -.01em;
}

button:hover { box-shadow: 0 8px 20px rgba(7, 90, 50, .13); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(20, 142, 82, .25);
  outline-offset: 2px;
}
button:disabled { cursor: not-allowed; opacity: .56; transform: none !important; }

input, select, textarea {
  border-radius: 10px;
  border-color: var(--v8-border);
  min-height: 44px;
}

label { color: #34483b; }

.field-hint {
  color: var(--v8-muted);
  display: block;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}

.login {
  background:
    linear-gradient(125deg, rgba(5, 39, 25, .96), rgba(7, 90, 50, .88)),
    var(--v8-green-950);
}

.login:before {
  background-image:
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px);
  background-size: 44px 44px;
  content: "";
  inset: 0;
  pointer-events: none;
  position: fixed;
}

.login-card {
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 20px;
  box-shadow: 0 36px 90px rgba(0, 0, 0, .28);
  padding: 34px;
  position: relative;
}

.login-card .logo {
  border-radius: 16px;
  box-shadow: none;
}

.login-card h1 {
  color: var(--v8-green-950);
  font-size: 30px;
  letter-spacing: -1.1px;
}

.version-label { color: #76847b; }

.database-check {
  background: #f4f7f5;
  border-color: var(--v8-border);
}

.shell { grid-template-columns: 280px minmax(0, 1fr); }

.sidebar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .035), transparent 28%),
    var(--v8-green-950);
  border-right: 1px solid rgba(255, 255, 255, .07);
  padding: 20px 16px;
}

.sidebrand {
  border-bottom-color: rgba(255, 255, 255, .1);
  padding: 4px 6px 18px;
}

.sidebrand .logo { background: rgba(255, 255, 255, .11); }
.sidebrand small { color: #a9cdb8; font-weight: 600; }

.nav { gap: 5px; }
.nav button {
  border-radius: 10px;
  color: #cfe4d7;
  min-height: 45px;
  padding: 8px 10px;
}
.nav button:hover, .nav button.active {
  background: rgba(255, 255, 255, .1);
  box-shadow: none;
}
.nav button.active { color: #fff; }
.nav button.active:before {
  background: #58ca8e;
  border-radius: 3px;
  content: "";
  height: 22px;
  margin-left: -10px;
  width: 3px;
}
.nav .ico {
  background: transparent;
  border-radius: 8px;
  font-size: 16px;
  width: 28px;
}

.main { padding: 24px clamp(18px, 3vw, 42px) 48px; }

.topbar {
  align-items: center;
  backdrop-filter: blur(16px);
  background: rgba(238, 243, 240, .88);
  border-bottom: 1px solid rgba(197, 212, 202, .75);
  margin: -24px calc(clamp(18px, 3vw, 42px) * -1) 24px;
  padding: 20px clamp(18px, 3vw, 42px) 16px;
  position: sticky;
  top: 0;
  z-index: 25;
}

.title h2 { font-size: 27px; letter-spacing: -1px; }
.title p { font-size: 14px; }
.top-actions { justify-content: flex-end; }

.sr-only {
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}
.global-search { min-width: min(270px, 28vw); }
.global-search input {
  background: rgba(255, 255, 255, .9);
  min-height: 40px;
}
.global-result {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  width: 100%;
}
.global-result small { color: var(--v8-muted); font-weight: 600; }

.notification-button {
  align-items: center;
  display: inline-flex;
  gap: 7px;
  position: relative;
}
.notification-button > span { color: #d79000; font-size: 9px; }
.notification-count {
  align-items: center;
  background: #b42318;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 10px;
  height: 20px;
  justify-content: center;
  min-width: 20px;
  padding: 0 5px;
  position: absolute;
  right: -7px;
  top: -8px;
}

.hero, .panel, .stat, .item {
  border-color: var(--v8-border);
  box-shadow: var(--v8-shadow);
}

.hero {
  border-left: 0;
  border-radius: 16px;
  overflow: hidden;
  padding: 22px 24px;
  position: relative;
}
.hero:before {
  background: var(--v8-green-700);
  content: "";
  inset: 0 auto 0 0;
  position: absolute;
  width: 4px;
}

.panel, .stat, .item { border-radius: 14px; }
.panel { padding: 20px; }
.panel h3 { color: #152a1e; letter-spacing: -.35px; }
.stat {
  min-height: 128px;
  padding: 19px;
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat:hover { box-shadow: var(--v8-shadow-hover); transform: translateY(-2px); }
.stat strong { font-variant-numeric: tabular-nums; }

.item {
  border-left: 3px solid #9bc7ac;
  box-shadow: 0 4px 16px rgba(5, 39, 25, .045);
}
.item:hover { border-left-color: var(--v8-green-700); }

.badge { border-radius: 8px; font-weight: 750; }
.actions { align-items: center; }

.table-wrap { border-radius: 11px; }
table { font-variant-numeric: tabular-nums; }
th {
  background: #edf5f0;
  color: #263d2f;
  font-size: 11px;
  letter-spacing: .035em;
  text-transform: uppercase;
}
tbody tr:nth-child(even) { background: #fafcfb; }
tbody tr:hover { background: #eff7f2; }

.report-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--v8-border);
  display: flex;
  justify-content: space-between;
  margin: -2px 0 16px;
  padding-bottom: 13px;
}
.report-header h3 { margin: 4px 0 0; }
.report-kicker {
  color: var(--v8-green-700);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.delivery-items-builder {
  background: #f7faf8;
  border: 1px solid var(--v8-border);
  border-radius: 12px;
  display: grid;
  gap: 10px;
  padding: 14px;
}
.delivery-items-builder > header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}
.delivery-items-builder > header h4 { margin: 0; }
.delivery-extra-row {
  align-items: end;
  background: #fff;
  border: 1px solid var(--v8-border);
  border-radius: 10px;
  display: grid;
  gap: 9px;
  grid-template-columns: minmax(180px, 1fr) 110px 130px auto;
  padding: 10px;
}
.delivery-extra-row button { min-width: 42px; padding: 8px; }

.permission-matrix {
  border: 1px solid var(--v8-border);
  border-radius: 12px;
  margin-top: 14px;
  overflow: hidden;
}
.permission-matrix > header {
  background: #edf5f0;
  padding: 11px 13px;
}
.permission-matrix > header strong { display: block; }
.permission-matrix-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 8px;
}
.permission-group {
  border-bottom: 1px solid #edf1ee;
  display: grid;
  gap: 7px;
  padding: 11px;
}
.permission-group strong { color: #294033; font-size: 12px; }
.permission-options { display: flex; flex-wrap: wrap; gap: 6px; }
.permission-options label {
  align-items: center;
  background: #f7faf8;
  border: 1px solid var(--v8-border);
  border-radius: 7px;
  display: flex;
  font-size: 11px;
  gap: 5px;
  padding: 6px 8px;
}
.permission-options input { min-height: auto; width: auto; }

.v8-dialog { width: min(720px, calc(100% - 24px)); }
.v8-dialog .dialog-card { padding: 22px; }
.v8-dialog-form { display: grid; gap: 12px; }

.notification-list { display: grid; gap: 9px; max-height: 60dvh; overflow: auto; }
.system-load-issue {
  display: grid;
  gap: 4px;
  margin: -2px 0 18px;
  padding: 14px 16px;
  border: 1px solid #f3b8b1;
  border-left: 5px solid #b42318;
  border-radius: 16px;
  background: #fff4f2;
  color: #7a271f;
  box-shadow: 0 8px 24px rgba(180,35,24,.08);
}
.system-load-issue strong { font-size: 14px; }
.system-load-issue span { font-size: 13px; line-height: 1.45; }
.system-load-issue small { font-size: 11px; color: #9d2017; }
.notification-entry {
  border: 1px solid var(--v8-border);
  border-left: 4px solid #da9b16;
  border-radius: 10px;
  padding: 11px 13px;
}
.notification-entry.danger { border-left-color: #b42318; }
.notification-entry h4 { margin: 0 0 4px; }
.notification-entry p { color: var(--v8-muted); margin: 0; }

.readonly-profile {
  background: #fff6dc;
  border: 1px solid #f0d48a;
  border-radius: 10px;
  color: #795200;
  font-size: 12px;
  font-weight: 750;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.open-visit-option { font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
  .main { padding: 14px 12px 126px; }
  .topbar {
    margin: -14px -12px 18px;
    padding: 14px 12px;
    position: relative;
  }
  .top-actions { display: flex; }
  .permission-matrix-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .login-card { padding: 25px 20px; }
  .top-actions .badge { flex: 1; justify-content: center; }
  .top-actions button { flex: 1 1 44%; }
  .global-search { flex: 1 1 100%; min-width: 100%; }
  .delivery-extra-row { grid-template-columns: 1fr 1fr; }
  .delivery-extra-row label:first-child { grid-column: 1 / -1; }
  .report-header { display: grid; gap: 7px; }
  .panel { padding: 16px; }
}

@media print {
  @page { margin: 12mm; size: A4 landscape; }
  body.print-report { background: #fff !important; color: #111; }
  body.print-report #login,
  body.print-report .sidebar,
  body.print-report .topbar,
  body.print-report .bottom-nav,
  body.print-report .float-assist,
  body.print-report .page,
  body.print-report dialog,
  body.print-report .toast-region,
  body.print-report .connection-banner { display: none !important; }
  body.print-report #app {
    display: block !important;
    min-height: auto;
  }
  body.print-report .main { padding: 0 !important; }
  body.print-report #relatorios {
    display: block !important;
  }
  body.print-report #relatorios > .panel:first-child { display: none !important; }
  body.print-report .report-output {
    border: 0 !important;
    box-shadow: none !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  body.print-report .report-output .table-wrap {
    border: 0;
    overflow: visible;
  }
  body.print-report .report-output table { font-size: 9px; }
  body.print-report .report-output th,
  body.print-report .report-output td { padding: 5px 6px; }
  body.print-report .report-header { display: flex !important; }
}
