/* Kronos Minimal V1
   Direção: conteúdo primeiro, hierarquia clara, menos containers e menos ruído.
   Esta camada é transitória e será absorvida pelo design system após validação da IA. */

:root {
  --k-color-bg: #f5f5f7;
  --k-color-surface: #ffffff;
  --k-color-surface-muted: #f5f5f7;
  --k-color-border: #e5e5ea;
  --k-color-text: #1d1d1f;
  --k-color-text-muted: #6e6e73;
  --k-color-primary: #1d1d1f;
  --k-color-primary-hover: #000000;
  --k-color-accent: #0071e3;
  --k-color-success: #248a3d;
  --k-color-warning: #b25000;
  --k-color-danger: #d70015;
  --k-color-info: #0071e3;

  --bg: var(--k-color-bg);
  --panel: var(--k-color-surface);
  --panel-2: var(--k-color-surface-muted);
  --panel-3: #efeff4;
  --line: var(--k-color-border);
  --line-gold: rgba(0, 113, 227, 0.24);
  --text: var(--k-color-text);
  --text-mid: #3a3a3c;
  --muted: var(--k-color-text-muted);
  --gold: var(--k-color-accent);
  --gold-light: #409cff;
  --gold-dim: rgba(0, 113, 227, 0.08);
  --navy: var(--k-color-text);
  --navy-mid: #3a3a3c;

  --k-font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", sans-serif;
  --k-font-title: var(--k-font-family);
  --font-title: var(--k-font-family);
  --font-body: var(--k-font-family);

  --k-radius-sm: 8px;
  --k-radius-md: 12px;
  --k-radius-lg: 18px;
  --k-shadow-sm: none;
  --k-shadow-md: 0 8px 30px rgba(0, 0, 0, 0.07);
  --k-shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.16);
  --k-content-max-width: 1120px;
}

html {
  background: var(--k-color-bg);
}

body {
  font-family: var(--k-font-family);
  background: var(--k-color-bg);
  color: var(--k-color-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.shell {
  width: min(var(--k-content-max-width), calc(100% - 40px));
  padding-top: 22px;
}

/* Cabeçalho: nome do produto discreto, contexto atual protagonista. */
.topbar,
.k-global-header {
  min-height: 64px;
  align-items: center;
  margin-bottom: 12px;
  background: color-mix(in srgb, var(--k-color-bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
}

.brand {
  gap: 2px;
}

.brand .eyebrow {
  color: var(--k-color-text-muted);
  font-family: var(--k-font-family);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.brand h1,
h1,
h2,
h3,
.k-page-title,
.k-card-title {
  font-family: var(--k-font-family);
  letter-spacing: -0.025em;
}

.brand h1 {
  color: var(--k-color-text);
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 700;
}

.gold {
  color: inherit !important;
}

.topbar-actions {
  gap: 8px;
}

/* Navegação principal: cinco destinos mentais, sem expor a arquitetura interna. */
.app-nav.k-minimal-primary-nav,
.k-primary-nav.k-minimal-primary-nav {
  position: sticky;
  top: 64px;
  z-index: 39;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  min-height: 48px;
  margin: 0 0 24px;
  padding: 4px;
  border: 0;
  border-radius: 14px;
  background: rgba(232, 232, 237, 0.72);
  box-shadow: none;
  backdrop-filter: saturate(180%) blur(18px);
}

.k-destination {
  min-width: 0;
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--k-color-text-muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.k-destination:hover {
  color: var(--k-color-text);
  background: rgba(255, 255, 255, 0.54);
}

.k-destination.active,
.k-destination[aria-current="page"] {
  color: var(--k-color-text);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Execução deixa de ter uma segunda navegação visível. */
#executionNav,
#executionSubnavMobile {
  display: none !important;
}

.k-minimal-exec-view[hidden] {
  display: none !important;
}

.k-minimal-exec-view {
  min-width: 0;
}

.k-today-intro {
  margin: 2px 0 18px;
}

.k-today-date {
  color: var(--k-color-text);
  font-size: 1rem;
  font-weight: 650;
}

.k-today-prompt {
  margin-top: 3px;
  color: var(--k-color-text-muted);
  font-size: 0.9rem;
}

/* Hoje V2: foco, próximo compromisso e exceções. */
.k-today-dashboard {
  max-width: 760px;
}

.k-today-section {
  margin-top: 30px;
}

.k-today-section:first-child {
  margin-top: 22px;
}

.k-today-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.k-today-section-head h2 {
  margin: 0;
  color: var(--k-color-text);
  font-size: 0.95rem;
  font-weight: 680;
  letter-spacing: -0.015em;
}

.k-today-link,
.k-today-inline-action,
.k-today-subtle-action {
  border: 0;
  background: transparent;
  color: var(--k-color-accent);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.k-today-link,
.k-today-inline-action {
  padding: 7px 8px;
  border-radius: 8px;
}

.k-today-link:hover,
.k-today-inline-action:hover {
  background: rgba(0, 113, 227, 0.08);
}

.k-today-state {
  color: var(--k-color-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.k-today-list {
  overflow: hidden;
  border: 1px solid var(--k-color-border);
  border-radius: 14px;
  background: var(--k-color-surface);
}

.k-today-row {
  width: 100%;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--k-color-border);
  background: transparent;
  color: var(--k-color-text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.k-today-row:last-child {
  border-bottom: 0;
}

.k-today-row:hover {
  background: #fafafa;
}

.k-today-row-content {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.k-today-row-content strong {
  overflow: hidden;
  color: var(--k-color-text);
  font-size: 0.91rem;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.k-today-row-content small {
  overflow: hidden;
  color: var(--k-color-text-muted);
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.k-today-focus-marker {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border: 1.5px solid #c7c7cc;
  border-radius: 50%;
  background: #fff;
}

.k-today-time {
  width: 54px;
  flex: 0 0 54px;
  color: var(--k-color-text-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.k-today-chevron {
  flex: 0 0 auto;
  color: #aeaeb2;
  font-size: 1.35rem;
  font-weight: 300;
  line-height: 1;
}

.k-today-attention-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: #aeaeb2;
}

.k-today-attention-row[data-tone="warning"] .k-today-attention-dot {
  background: var(--k-color-warning);
}

.k-today-empty,
.k-today-all-clear {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--k-color-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.64);
}

.k-today-empty--compact {
  min-height: 66px;
}

.k-today-empty p,
.k-today-all-clear p {
  margin: 0;
  color: var(--k-color-text-muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.k-today-all-clear {
  justify-content: flex-start;
  color: var(--k-color-success);
}

.k-today-all-clear span {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(36, 138, 61, 0.1);
  font-size: 0.78rem;
  font-weight: 700;
}

.k-today-subtle-action {
  margin-top: 9px;
  padding: 6px 2px;
  color: var(--k-color-text-muted);
}

.k-today-subtle-action:hover {
  color: var(--k-color-text);
}

/* O card legado mantém controles/listeners, mas não compete com a nova home. */
#kMinimalTodayView > #dailyReviewCard {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.k-operational-disclosure,
.k-history-disclosure {
  max-width: 760px;
  margin-top: 22px;
  border-top: 1px solid var(--k-color-border);
  color: var(--k-color-text-muted);
}

.k-operational-disclosure > summary,
.k-history-disclosure > summary {
  padding: 15px 2px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  list-style-position: inside;
}

.k-operational-content {
  padding: 2px 0 12px;
}

.k-operational-content .metrics {
  margin-top: 4px;
}

.k-operational-content .status-summary,
.k-operational-content .dist-bar {
  margin-top: 10px;
}

.k-history-disclosure .daily-history-card {
  margin-top: 2px;
}

/* Cards: superfícies calmas, sem decoração competitiva. */
.k-card,
.metric-card,
.daily-review-card,
.daily-history-card,
.agenda-card,
.agenda-focus-card,
.agenda-week-card,
.settings-card,
.backup-panel,
.fin-card,
.fin-coverage-card,
.fin-closing-banner {
  border-color: var(--k-color-border) !important;
  box-shadow: none !important;
}

.metric-card::after {
  display: none;
}

.metric-card:hover,
.metric-card.active {
  border-color: #d2d2d7;
  box-shadow: none;
}

.metrics {
  gap: 10px;
}

.metric-card {
  border-radius: 16px;
  padding: 16px 18px;
}

.metric-label,
.detail-label,
.agenda-kicker,
.eyebrow {
  color: var(--k-color-text-muted);
  font-family: var(--k-font-family);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.metric-count {
  color: var(--k-color-text);
  font-family: var(--k-font-family);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.status-summary {
  color: var(--k-color-text-muted);
  font-family: var(--k-font-family);
  font-size: 0.82rem;
  font-weight: 500;
}

.dist-item,
.daily-priority-pills span {
  border-color: var(--k-color-border);
  background: rgba(255, 255, 255, 0.74);
  color: var(--k-color-text-muted);
}

.daily-review-head h2,
.agenda-head h2,
.settings-card h2,
.backup-head h2 {
  color: var(--k-color-text);
  font-weight: 650;
}

.daily-review-status {
  background: #f2f2f7;
  color: var(--k-color-text-muted);
}

/* Botões e campos: controles familiares, sem peso visual desnecessário. */
.btn-primary,
.k-button--primary {
  border-color: #0071e3 !important;
  background: #0071e3 !important;
  color: #fff !important;
  font-family: var(--k-font-family);
  font-weight: 600;
}

.btn-primary:hover,
.k-button--primary:hover {
  border-color: #0077ed !important;
  background: #0077ed !important;
}

.btn-secondary,
.k-button--secondary,
.toggle-btn,
.tab,
.agenda-tab,
.finance-nav-btn,
.k-tab {
  font-family: var(--k-font-family);
  font-weight: 600;
}

.btn-secondary,
.k-button--secondary {
  border-color: #d2d2d7 !important;
  background: rgba(255, 255, 255, 0.88) !important;
  color: var(--k-color-text) !important;
}

input,
select,
textarea,
.k-input,
.k-select,
.k-textarea {
  border-color: #d2d2d7 !important;
  border-radius: 10px !important;
  background: #fff !important;
  color: var(--k-color-text) !important;
}

:where(button, a, input, select, textarea):focus-visible {
  outline: 3px solid rgba(0, 113, 227, 0.32);
  outline-offset: 2px;
}

/* Abas internas que continuam necessárias, como Financeiro. */
.k-secondary-nav {
  gap: 4px;
  border-bottom-color: var(--k-color-border);
}

.k-secondary-nav .finance-nav-btn {
  border-radius: 9px;
  color: var(--k-color-text-muted);
}

.k-secondary-nav .finance-nav-btn.active,
.k-secondary-nav .finance-nav-btn[aria-current="page"] {
  border-color: transparent;
  background: #e8e8ed;
  color: var(--k-color-text);
}

/* Ajustes: leitura de lista, não dashboard de infraestrutura. */
#settingsView {
  display: grid;
  gap: 12px;
}

#settingsView[hidden] {
  display: none !important;
}

.k-settings-intro {
  margin-bottom: 4px;
  color: var(--k-color-text-muted);
  font-size: 0.9rem;
}

.k-minimal-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.k-minimal-settings-action {
  flex: 0 0 auto;
}

/* A toolbar de tarefas perde o aspecto de painel de filtros permanente. */
.toolbar {
  border-color: var(--k-color-border);
  border-radius: 18px;
  background: #fff;
  box-shadow: none;
}

.urgency-legend {
  color: var(--k-color-text-muted);
}

/* Login coerente com a nova linguagem. */
.login-card {
  border-color: var(--k-color-border);
  border-radius: 20px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.08);
}

.login-card .eyebrow {
  color: var(--k-color-text-muted);
}

/* Mobile: tab bar inferior com cinco destinos principais. */
@media (max-width: 767px) {
  body {
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }

  .shell {
    width: min(100%, calc(100% - 28px));
    padding-top: 14px;
  }

  .topbar,
  .k-global-header {
    position: relative;
    min-height: 54px;
    margin-bottom: 10px;
    background: transparent;
    backdrop-filter: none;
  }

  .brand h1 {
    font-size: 1.7rem;
  }

  .topbar-actions {
    max-width: 58%;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .topbar-actions .btn-secondary,
  .topbar-actions .btn-primary {
    min-height: 38px;
    padding: 8px 11px;
    font-size: 0.78rem;
  }

  .app-nav.k-minimal-primary-nav,
  .k-primary-nav.k-minimal-primary-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 80;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: 66px;
    margin: 0;
    padding: 7px max(6px, env(safe-area-inset-right))
      calc(7px + env(safe-area-inset-bottom))
      max(6px, env(safe-area-inset-left));
    border-top: 1px solid rgba(0, 0, 0, 0.09);
    border-radius: 0;
    background: rgba(249, 249, 249, 0.88);
    box-shadow: none;
    backdrop-filter: saturate(180%) blur(20px);
  }

  .k-destination {
    min-height: 48px;
    padding: 5px 2px;
    border-radius: 9px;
    font-size: 0.68rem;
  }

  .k-destination.active,
  .k-destination[aria-current="page"] {
    color: #0071e3;
    background: transparent;
    box-shadow: none;
  }

  .k-today-dashboard,
  .k-operational-disclosure,
  .k-history-disclosure {
    max-width: none;
  }

  .k-today-section {
    margin-top: 26px;
  }

  .k-today-row {
    min-height: 58px;
    padding: 10px 12px;
  }

  .k-today-time {
    width: 48px;
    flex-basis: 48px;
  }

  .k-today-empty {
    align-items: flex-start;
    flex-direction: column;
  }

  .k-operational-content .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .k-minimal-settings-row {
    align-items: stretch;
    flex-direction: column;
  }

  .k-minimal-settings-action .btn-logout {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .k-today-row-content strong,
  .k-today-row-content small {
    white-space: normal;
  }

  .k-operational-content .metrics {
    grid-template-columns: 1fr 1fr;
  }

  .metric-card {
    padding: 14px;
  }

  .metric-count {
    font-size: 1.7rem;
  }
}
