/* =================================================================
 * Office Hub — Camada de temas (Design System Grupo Diagonal)
 * Dois temas alternáveis via [data-theme] no <html>:
 *   dark  = tema legado do Office Hub (verde floresta escuro)  [default]
 *   light = padrão oficial da empresa (base clara, tipografia Inter)
 * Todo o CSS (base + features) usa SÓ as vars abaixo — trocar o
 * data-theme reveste o app inteiro. Tints/glows usam color-mix() p/
 * seguirem o tema sem duplicar hex. O tema é escolhido nos parâmetros
 * (Central Administrativa → Visual) e persiste em branding.tema.
 * ================================================================= */

/* Constantes de layout (independentes de tema). */
:root {
  --sidebar-w: 205px;
  --header-h: 52px;
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
}

/* ── Tema ESCURO (legado Office Hub) — padrão ─────────────────────── */
:root,
[data-theme="dark"] {
  /* Fundo / superfícies */
  --bg:            #011810;
  --bg-elevated:   #042014;
  --surface:       #063018;
  --surface-hover: #0B3D22;
  --bg-chrome:     #031A0E;   /* topbar / sidebar / header / footer */

  /* Bordas */
  --border:        #0F5035;
  --border-strong: #196044;

  /* Texto */
  --text:          #E8F5EE;
  --text-muted:    #79B59A;
  --text-subtle:   #4A7B60;

  /* Acentos */
  --accent:        #077233;
  --accent-hover:  #0A9040;
  --accent-pressed:#065C28;
  --accent-glow:   rgba(7, 114, 51, 0.22);
  --on-accent:     #FFFFFF;

  --mint:  #4DB695;
  --danger: #E05252;

  /* Tipografia */
  --font-sans:    "Albert Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Albert Sans", var(--font-sans);

  /* Elevação e texturas */
  --shadow-md: 0 12px 32px rgba(0,0,0,0.40);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.50);
  --zebra:     rgba(255,255,255,0.025);
  --grid-dot:  rgba(255,255,255,0.035);
}

/* ── Tema CLARO (padrão oficial Grupo Diagonal) ───────────────────── */
/* Tokens do design system (tela "001 Colors"): futuregreen #002818,
 * hopegreen #01AA81, neutral (cinzas), error #BF2818. Base clara, Inter. */
[data-theme="light"] {
  --bg:            #F7F8F8;   /* neutral-200 */
  --bg-elevated:   #FBFCFC;   /* neutral-100 */
  --surface:       #FFFFFF;
  --surface-hover: #EEF1F0;   /* neutral-300 */
  --bg-chrome:     #FBFCFC;   /* neutral-100 */

  --border:        #DDE3E1;   /* neutral-400 / border-lightest */
  --border-strong: #B0BCB7;   /* futuregreen-300 / border-light */

  --text:          #002818;   /* futuregreen-400 / text-primary */
  --text-muted:    #4C4E4D;   /* neutral-700 / text-secondary */
  --text-subtle:   #9FA2A1;   /* neutral-600 / text-tertiary */

  --accent:        #002818;   /* bg-brand-primary-main */
  --accent-hover:  #001E12;   /* futuregreen-500 */
  --accent-pressed:#00120B;   /* futuregreen-600 */
  --accent-glow:   rgba(0,40,24,0.16);
  --on-accent:     #FBFCFC;   /* text-on-color */

  --mint:  #01AA81;   /* hopegreen-400 / destaque + sucesso */
  --danger:#BF2818;   /* error-main */

  --font-sans:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Inter", var(--font-sans);

  --shadow-md: 0 4px 16px rgba(27,27,27,0.12);   /* elevation-medium */
  --shadow-lg: 0 16px 40px rgba(27,27,27,0.18);  /* elevation-large */
  --zebra:     rgba(0,40,24,0.025);
  --grid-dot:  rgba(0,40,24,0.05);
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Utilitário ─────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Login ──────────────────────────────────────────────────────── */
.login-fullpage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}
body:not(.logged-out) .login-fullpage { display: none; }
body.logged-out .app-shell            { display: none !important; }
body.logged-out .module-select-page   { display: none !important; }

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 32px 28px;
}
.login-brand {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.login-brand .wordmark {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  display: block;
}
.login-brand .wordmark span { color: var(--mint); }
.login-brand .tool-name {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  color: var(--text-subtle);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.login-card h2 {
  margin-bottom: 18px;
  font-size: 15px;
  font-weight: 600;
}

/* ── Formulário (login) ─────────────────────────────────────────── */
.field { display: flex; flex-direction: column; margin-bottom: 14px; }
.field label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
input[type="text"],
input[type="password"],
input[type="number"] {
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]::placeholder,
input[type="password"]::placeholder { color: var(--text-subtle); }
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Botões ─────────────────────────────────────────────────────── */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  padding: 9px 18px;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
button:hover  { background: var(--accent-hover); border-color: var(--accent-hover); }
button:active { background: var(--accent-pressed); transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-strong);
  font-weight: 500;
}
button.ghost:hover { background: var(--surface-hover); color: var(--text); border-color: var(--text-subtle); }

button.small { padding: 5px 13px; font-size: 12px; }

/* ── Mensagem de erro ────────────────────────────────────────────── */
.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* ── Seletor de módulos ─────────────────────────────────────────── */
.module-select-page {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}
body:not(.logged-out).view-modules .module-select-page { display: flex; }
body:not(.logged-out).view-modules .app-shell          { display: none !important; }

.modsel-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-chrome);
  flex-shrink: 0;
}
.modsel-brand .wordmark {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.modsel-brand .wordmark span { color: var(--mint); }
.modsel-brand .tool-name {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: var(--text-subtle);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.modsel-user {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.modsel-user strong { color: var(--text); font-weight: 600; }

.modsel-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}
.modsel-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-align: center;
}
.modsel-subtitle {
  margin: 8px 0 40px;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(200px, 270px));
  gap: 22px;
  width: 100%;
  max-width: 900px;
}
@media (max-width: 800px) {
  .module-grid { grid-template-columns: 1fr; max-width: 340px; }
}

.module-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 24px 22px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-family: inherit;
  cursor: default;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  text-align: left;
}
.module-card.clickable { cursor: pointer; }
.module-card.clickable:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.module-card.clickable:active { transform: translateY(-1px); }
.module-card.disabled { opacity: 0.55; }

.module-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  background: var(--accent-glow);
  color: var(--mint);
  margin-bottom: 16px;
}
.module-card.disabled .module-icon { background: var(--surface-hover); color: var(--text-subtle); }
.module-icon svg { width: 24px; height: 24px; }

.module-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.module-desc {
  margin-top: 5px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted);
  flex: 1;
}
.module-status {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid;
}
.module-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-ativo {
  color: var(--mint);
  background: color-mix(in srgb, var(--mint) 14%, transparent);
  border-color: color-mix(in srgb, var(--mint) 34%, transparent);
}
.status-soon {
  color: var(--text-subtle);
  background: var(--surface-hover);
  border-color: var(--border);
}

/* ── Rodapé compartilhado ───────────────────────────────────────── */
.modsel-footer,
.main-footer {
  flex-shrink: 0;
  padding: 9px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-chrome);
  text-align: center;
  font-size: 11px;
  color: var(--text-subtle);
  letter-spacing: 0.04em;
}
.modsel-footer strong,
.main-footer strong { color: var(--mint); font-weight: 600; }

/* ── App shell ──────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Filtros (sidebar) ──────────────────────────────────────────── */
.filter-sidebar {
  background: var(--bg-chrome);
  border-right: 1px solid var(--border);
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
}

.filter-brand {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.filter-brand .wordmark {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.filter-brand .wordmark span { color: var(--mint); }
.filter-brand .tool-name {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  color: var(--text-subtle);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.filter-section { margin-bottom: 14px; }
.filter-section-label {
  font-size: 10px;
  color: var(--text-subtle);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

/* Botões de período (ano / mês) */
.year-group  { display: flex; gap: 4px; flex-wrap: wrap; }
.month-grid  { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }

.period-btn {
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: var(--r-sm);
  cursor: pointer;
  letter-spacing: 0;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.period-btn:hover  { background: var(--surface-hover); color: var(--text); }
.period-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* De-Até */
.deate-row { display: flex; align-items: center; gap: 8px; }
.deate-row input {
  width: 52px;
  padding: 5px 7px;
  font-size: 12px;
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  text-align: center;
}
.deate-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.deate-sep { color: var(--text-subtle); font-size: 11px; }

/* Selects e texto de filtro */
.filter-select,
.filter-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  appearance: none;
  -webkit-appearance: none;
}
.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.filter-input::placeholder { color: var(--text-subtle); }

.filter-select-wrap { position: relative; }
.filter-select-wrap::after {
  content: '▾';
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  font-size: 10px;
  pointer-events: none;
}

.filter-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.filter-footer .user-line { padding: 0 2px; }
.filter-footer strong { color: var(--text); font-weight: 500; }

/* ── Área principal ─────────────────────────────────────────────── */
.main-area {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.main-header {
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--bg-chrome);
  flex-shrink: 0;
  gap: 16px;
}
.main-header h1 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  flex: 1;
  text-align: center;
  letter-spacing: -0.01em;
  color: var(--text);
}

.tab-btn {
  padding: 5px 16px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--on-accent);
  border-radius: var(--r-sm);
  letter-spacing: 0.04em;
}
.tab-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.header-actions { display: flex; gap: 8px; align-items: center; }
.count-badge { font-size: 11px; color: var(--text-subtle); white-space: nowrap; }

/* ── Tabela scrollável ──────────────────────────────────────────── */
.table-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  min-height: 0;
}
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
  background: var(--surface);
}
th, td {
  text-align: left;
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-elevated);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
th.th-sort { cursor: pointer; user-select: none; }
th.th-sort:hover { color: var(--text); }
.sort-arrow { font-size: 9px; color: var(--mint); }

tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: none; }

/* Células específicas */
td.td-req  { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
td.td-data { white-space: nowrap; color: var(--text-muted); font-variant-numeric: tabular-nums; }
td.td-cod  { white-space: nowrap; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
td.td-desc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
td.td-und  { white-space: nowrap; text-align: center; color: var(--text-muted); font-size: 12px; }
td.td-qtd  { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
td.td-user { white-space: nowrap; font-size: 12px; color: var(--text-muted); }
td.td-hist { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-muted); }

/* Zebra por grupo de requisição */
tr.req-alt            { background: var(--zebra); }
tr.req-alt:hover      { background: var(--surface-hover); }

/* Estados da tabela (loading / erro / vazio) */
.state-row td {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 13px;
  border-bottom: none;
}
.state-row.error-row td { color: var(--danger); }

/* ── Status badge ───────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid;
}
/* A Faturar */
.status-faturar {
  background: rgba(77, 182, 149, 0.12);
  color: var(--mint);
  border-color: rgba(77, 182, 149, 0.30);
}
/* Faturado */
.status-faturado {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent-hover);
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
}
/* Outros */
.status-outro {
  background: var(--surface-hover);
  color: var(--text-muted);
  border-color: var(--border-strong);
}
