:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-alt: #f9fbfa;
  --border: #dfe7e4;
  --border-strong: #c8d5d0;
  --ink: #132523;
  --ink-muted: #526764;
  --ink-soft: #758a87;

  --primary: #006960;
  --primary-hover: #00544d;
  --primary-soft: #e4f5f2;
  --primary-ink: #004d46;

  --accent-coral: #d95d47;
  --accent-coral-soft: #fdece9;
  --accent-amber: #c27803;
  --accent-amber-soft: #fef5e2;
  --accent-green: #146c43;
  --accent-green-soft: #dff4e8;
  --accent-blue: #1565a8;
  --accent-blue-soft: #e6f1fb;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(19, 37, 35, 0.05);
  --shadow-md: 0 6px 20px rgba(19, 37, 35, 0.07);
  --shadow-lg: 0 18px 42px rgba(19, 37, 35, 0.14);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--primary-soft);
  color: var(--primary-ink);
  padding: 2px 6px;
  border-radius: 5px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  font-size: 13px;
  padding: 7px 12px;
}

.btn-xs {
  font-size: 12px;
  padding: 5px 9px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 105, 96, 0.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  background: var(--surface-alt);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: var(--primary-soft);
  color: var(--primary-ink);
  border-color: transparent;
}

.btn-ghost:hover {
  background: #d2ece8;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--accent-coral);
  border-color: transparent;
}

.btn-danger-ghost:hover {
  background: var(--accent-coral-soft);
}

/* Login Screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 18%, rgba(0, 105, 96, 0.08), transparent 45%),
    radial-gradient(circle at 88% 82%, rgba(217, 93, 71, 0.07), transparent 40%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.login-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
}

.field input,
.field select,
.field textarea,
.date-input,
.inline-select select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.date-input:focus,
.inline-select select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 105, 96, 0.12);
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-muted);
  cursor: pointer;
  margin-top: 6px;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.form-error {
  background: var(--accent-coral-soft);
  color: #9f2d1b;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1420px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.topbar-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.topbar-brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-tag {
  font-size: 11px;
  color: var(--ink-muted);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
}

.nav-link {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-muted);
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--ink);
  background: var(--bg);
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary-ink);
}

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

/* Alert Banner */
.alert-banner {
  max-width: 1420px;
  margin: 14px auto 0;
  padding: 10px 16px;
  background: var(--accent-amber-soft);
  border: 1px solid #f0d394;
  border-radius: var(--radius-sm);
  color: #7c4d03;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Main Content */
.main-content {
  max-width: 1420px;
  margin: 0 auto;
  padding: 22px 20px 80px;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.page-subtitle {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--ink-muted);
}

.toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-muted);
  font-weight: 600;
}

.inline-select select {
  width: auto;
  padding: 6px 10px;
  font-size: 13px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.card-head h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-meta {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
}

.card-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--ink-muted);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.kpi-value-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.kpi-detail {
  font-size: 12.5px;
  color: var(--ink-muted);
  line-height: 1.45;
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.badge-green {
  background: var(--accent-green-soft);
  color: var(--accent-green);
}

.badge-coral {
  background: var(--accent-coral-soft);
  color: #a63420;
}

.badge-amber {
  background: var(--accent-amber-soft);
  color: #8c5500;
}

.badge-teal {
  background: var(--primary-soft);
  color: var(--primary-ink);
}

.badge-blue {
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
}

.badge-neutral {
  background: #edf1f0;
  color: var(--ink-muted);
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.chart-card {
  display: flex;
  flex-direction: column;
}

.chart-wrap {
  position: relative;
  height: 270px;
  width: 100%;
}

/* Tables */
.table-card {
  margin-bottom: 20px;
  padding: 18px 0 6px;
}

.table-card .card-head {
  padding: 0 20px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
  background: var(--surface-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th.num {
  text-align: right;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #f7faf9;
}

.data-table tbody tr.clickable-row {
  cursor: pointer;
}

.data-table tfoot td {
  padding: 10px 12px;
  font-weight: 700;
  background: var(--surface-alt);
  border-top: 2px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
}

.data-table tfoot tr.target-row td {
  font-weight: 600;
  color: var(--ink-muted);
  background: #fdfefd;
}

.detail-cell {
  max-width: 340px;
  font-size: 12.5px;
  color: var(--ink-muted);
  line-height: 1.38;
}

.desc-main {
  font-weight: 600;
  color: var(--ink);
}

.desc-sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
  max-width: 440px;
}

.actions-col {
  text-align: right;
  white-space: nowrap;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Diário Date Nav & Progress */
.date-nav-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-nav-bar .date-input {
  width: auto;
  padding: 6px 10px;
  font-weight: 600;
}

.date-pills-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.date-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.date-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.date-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.daily-progress-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.meter-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meter-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}

.meter-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
}

.meter-val {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.meter-track {
  height: 7px;
  background: #e6ecea;
  border-radius: 999px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.25s ease;
}

.meter-fill.warn {
  background: var(--accent-amber);
}

.meter-fill.danger {
  background: var(--accent-coral);
}

.meter-fill.water {
  background: var(--accent-blue);
}

.meter-sub {
  font-size: 11.5px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.filter-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-btn {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--ink-muted);
  padding: 5px 11px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.pill-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-ink);
}

.meal-toolbar {
  padding-bottom: 4px;
}

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--ink-muted);
}

/* Config Grid */
.config-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 18px;
  align-items: start;
}

.config-side-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.field-span-2 {
  grid-column: span 2;
}

.field-divider {
  grid-column: span 2;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary-ink);
}

.form-actions-span {
  grid-column: span 2;
  padding-top: 8px;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.file-upload-btn {
  cursor: pointer;
}

.presets-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.presets-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 29, 27, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-height: 92vh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-lg { max-width: 720px; }
.modal-md { max-width: 600px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--ink);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
}

.preset-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--primary-soft);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.preset-bar label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary-ink);
}

.preset-bar select {
  flex: 1;
  min-width: 220px;
  padding: 7px 10px;
  border: 1px solid #b5ded7;
  border-radius: 6px;
  font-size: 13px;
  background: #ffffff;
}

.details-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface-alt);
}

.details-box summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-ink);
  cursor: pointer;
}

.inner-grid {
  margin-top: 12px;
}

/* Google Drive Photo Preview */
.photo-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.photo-form-preview {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  gap: 12px;
}

.photo-form-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.photo-stage {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  padding: 10px;
  gap: 10px;
}

.photo-stage img {
  max-width: 100%;
  max-height: 440px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.photo-stage iframe {
  width: 100%;
  height: 420px;
  border: none;
  border-radius: var(--radius-sm);
}

.photo-modal-desc {
  margin: 0 0 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--ink);
  color: #ffffff;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: fadeSlideUp 0.18s ease;
}

.toast.error {
  background: #a63420;
}

.toast.success {
  background: var(--primary);
}

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

/* Mobile Nav */
.mobile-nav {
  display: none;
}

@media (max-width: 1080px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .daily-progress-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
  .config-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .main-nav {
    display: none;
  }
  .topbar-actions .btn-ghost {
    display: none;
  }
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px 4px;
  }
  .mobile-nav-btn {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-muted);
    padding: 8px 4px;
    border-radius: 8px;
    cursor: pointer;
  }
  .mobile-nav-btn.active {
    color: var(--primary-ink);
    background: var(--primary-soft);
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .daily-progress-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .field-span-2, .field-divider, .form-actions-span {
    grid-column: span 1;
  }
  .toast-container {
    bottom: 76px;
    right: 14px;
    left: 14px;
  }
}
