/* =====================================================================
   SmartMach — Portal de Apontamentos
   Tokens no :root. Para mudar cores ou espaçamentos, edite só esta seção.
   ===================================================================== */

@font-face { font-family: "Inter"; src: url("../fonts/Inter-Regular.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-Medium.woff") format("woff"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-SemiBold.woff") format("woff"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter Display"; src: url("../fonts/InterDisplay-SemiBold.woff") format("woff"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter Display"; src: url("../fonts/InterDisplay-Bold.woff") format("woff"); font-weight: 700; font-display: swap; }

:root {
  /* Cores */
  --navy: #0F2740;          /* painel SmartMach */
  --navy-2: #173755;
  --navy-3: #24486b;
  --steel: #EDF0F3;         /* fundo */
  --surface: #FFFFFF;
  --line: #D9DFE6;
  --line-soft: #E8ECF0;
  --ink: #18222E;
  --ink-2: #3A4757;
  --muted: #5F6D7C;
  --signal: #F5B700;        /* amarelo de segurança (EPI) */
  --signal-ink: #3D2E00;
  --signal-soft: #FFF4CC;

  --ok: #1E7F55;   --ok-soft: #E1F3EA;
  --warn: #8A5A00; --warn-soft: #FFF1CF;
  --bad: #B3392B;  --bad-soft: #FBE7E4;
  --idle: #5F6D7C; --idle-soft: #EBEEF1;

  /* Tipografia */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Inter Display", var(--font);
  --t-xs: 12px; --t-sm: 13px; --t-md: 15px; --t-lg: 18px; --t-xl: 24px; --t-2xl: 32px;

  /* Forma */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --sidebar: 236px;
  --focus: 0 0 0 3px rgba(245, 183, 0, .55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--steel); color: var(--ink);
  font: 400 var(--t-md)/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; margin: 0; line-height: 1.2; }
h1 { font-size: var(--t-xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); }
p { margin: 0; }
a { color: var(--navy-3); }
.num, td.num, .metric b { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
#view:focus, #view:focus-visible { box-shadow: none; }

/* ---------------------------------------------------------------- botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 var(--t-sm)/1 var(--font); padding: 11px 16px; border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--surface); color: var(--ink); border-color: var(--line);
}
.btn:hover { border-color: #b9c3ce; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--signal); color: var(--signal-ink); border-color: #DDA400; }
.btn-primary:hover { background: #FFC21A; border-color: #C99500; }
.btn-dark { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-dark:hover { background: var(--navy-2); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--line-soft); border-color: transparent; }
.btn-sm { padding: 7px 11px; font-size: var(--t-xs); }

/* ---------------------------------------------------------------- formulários */
label { display: grid; gap: 6px; align-content: start; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
input, select, textarea {
  width: 100%; font: 400 var(--t-md)/1.4 var(--font); color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #C99500; box-shadow: var(--focus); }
textarea { min-height: 96px; resize: vertical; }
.hint { font-size: var(--t-xs); font-weight: 400; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.field-status { font-size: var(--t-xs); font-weight: 600; min-height: 16px; }
.field-status.ok { color: var(--ok); }
.field-status.bad { color: var(--bad); }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); background: var(--surface); }
.login-brand { background: var(--navy); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.login-brand .wordmark { color: #fff; }
.login-claim h1 { font-size: clamp(30px, 3.6vw, 46px); font-weight: 700; letter-spacing: -.025em; line-height: 1.08; max-width: 15ch; }
.login-claim p { color: #B7C7D8; margin-top: 16px; max-width: 42ch; }
.login-meter { margin-top: 36px; max-width: 560px; }
.login-meter .meter-strip { height: 46px; }
.login-meter .meter-legend { color: #B7C7D8; }
.login-foot { font-size: var(--t-xs); color: #8FA5BB; }
.login-form { display: grid; place-items: center; padding: 40px 24px; }
.login-form form { width: min(380px, 100%); display: grid; gap: 18px; }
.login-form .error { color: var(--bad); font-size: var(--t-sm); min-height: 20px; }

/* ---------------------------------------------------------------- marca */
.wordmark { display: inline-flex; align-items: center; gap: 10px; font: 700 18px/1 var(--font-display); letter-spacing: .02em; color: #fff; text-decoration: none; }
.wordmark svg { flex: none; }

/* ---------------------------------------------------------------- estrutura */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--navy); color: #D3DEEA;
  display: flex; flex-direction: column; padding: 22px 14px 16px; z-index: 30;
}
.sidebar .wordmark { padding: 0 8px 22px; }
.nav { display: grid; gap: 2px; }
.nav-group { margin: 18px 10px 6px; font-size: var(--t-xs); color: #8DA3BA; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-radius: var(--r-sm); color: #D3DEEA; text-decoration: none; font-size: var(--t-sm); font-weight: 500;
}
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a[aria-current="page"] { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 var(--signal); }
.nav .count { background: var(--signal); color: var(--signal-ink); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; }
.sidebar-user { margin-top: auto; border-top: 1px solid var(--navy-3); padding: 14px 8px 0; display: grid; gap: 10px; }
.sidebar-user .who { font-size: var(--t-sm); color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .role { font-size: var(--t-xs); color: #8DA3BA; }
.sidebar-user .row { display: flex; gap: 6px; }
.sidebar-user .btn { flex: 1; background: transparent; color: #D3DEEA; border-color: var(--navy-3); }
.sidebar-user .btn:hover { background: var(--navy-2); color: #fff; }

.topbar { display: none; }
.main { margin-left: var(--sidebar); padding: 28px 32px 56px; max-width: calc(1320px + var(--sidebar)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--muted); font-size: var(--t-sm); margin-top: 4px; }

/* ---------------------------------------------------------------- blocos */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; }
.panel + .panel { margin-top: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head p { color: var(--muted); font-size: var(--t-sm); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-2 > .panel + .panel { margin-top: 0; }
.stack { display: grid; gap: 18px; align-content: start; }
.stack > .panel + .panel { margin-top: 0; }
.grid-2 + .grid-2, .panel + .grid-2, .grid-2 + .panel { margin-top: 18px; }

/* Métricas: faixa única com divisórias, não cartões soltos */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 18px; }
.metric { padding: 16px 20px; border-left: 1px solid var(--line-soft); }
.metric:first-child { border-left: 0; }
.metric span { font-size: var(--t-sm); color: var(--muted); }
.metric b { display: block; font: 600 var(--t-2xl)/1.1 var(--font-display); letter-spacing: -.02em; margin-top: 6px; }
.metric small { display: block; font-size: var(--t-xs); color: var(--muted); margin-top: 2px; }

/* Avisos de fila (gestor) */
.queue { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.queue a {
  flex: 1 1 260px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--signal-soft); border: 1px solid #F1D57A; border-radius: var(--r-md); padding: 12px 16px;
  color: var(--signal-ink); text-decoration: none; font-weight: 600; font-size: var(--t-sm);
}
.queue a:hover { border-color: #DDA400; }
.queue a b { font: 700 22px/1 var(--font-display); }
.queue a.clear { background: var(--surface); border-color: var(--line); color: var(--muted); font-weight: 500; }

/* ---------------------------------------------------------------- tabela */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: var(--t-xs); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: #F6F8FA; }
td .sub.cnpj { white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: var(--t-xs); margin-top: 2px; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }
.panel > .hint { margin-top: 14px; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type="search"] { max-width: 320px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: 500 var(--t-xs)/1 var(--font); padding: 8px 12px; border-radius: 30px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------------------------------------------------------------- selos de status */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); font-weight: 600; padding: 3px 9px; border-radius: 30px; white-space: nowrap; background: var(--idle-soft); color: var(--idle); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.aprovado { background: var(--ok-soft); color: var(--ok); }
.badge.pendente { background: var(--warn-soft); color: var(--warn); }
.badge.vencido, .badge.recusado { background: var(--bad-soft); color: var(--bad); }
.role-tag { font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); background: var(--line-soft); padding: 3px 8px; border-radius: var(--r-sm); }
.role-tag.admin { background: var(--navy); color: #fff; }

/* =====================================================================
   Régua de proteção — o elemento central: cada traço é um dia.
   Traço escuro = dia corrido, amarelo = dia restante, tracejado = renovação possível.
   ===================================================================== */
.meter { display: grid; gap: 8px; }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.meter-days { font: 700 34px/1 var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.meter-days small { font: 500 var(--t-sm) var(--font); color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.meter-strip { display: flex; gap: 3px; height: 34px; align-items: stretch; }
.meter-strip i { flex: 1; border-radius: 2px; background: var(--signal); }
.meter-strip i.past { background: #2B4562; }
.meter-strip i.gap { flex: 0 0 8px; background: transparent; }
.meter-strip i.ext { background: transparent; border: 1px dashed #A9B6C4; }
.meter-strip i.ext.granted { background: var(--signal); border: 0; }
.meter-strip i.ext.granted.past { background: #2B4562; }
.meter-strip i.dead { background: #CBD3DC; }
.meter-legend { display: flex; justify-content: space-between; gap: 12px; font-size: var(--t-xs); color: var(--muted); flex-wrap: wrap; }
.meter.off .meter-days { color: var(--muted); }

/* Versão compacta para tabelas */
.mini { display: inline-grid; gap: 4px; min-width: 96px; }
.mini b { font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
.mini .bar { height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; display: flex; }
.mini .bar i { background: var(--signal); }
.mini.low b { color: var(--bad); }
.mini.low .bar i { background: var(--bad); }

/* ---------------------------------------------------------------- funil */
.funnel { display: grid; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 32px; gap: 10px; align-items: center; font-size: var(--t-sm); }
.funnel-row .track { height: 10px; background: var(--line-soft); border-radius: 5px; overflow: hidden; }
.funnel-row .track i { display: block; height: 100%; background: var(--navy-3); border-radius: 5px; }
.funnel-row b { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- listas */
.list { display: grid; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); text-decoration: none; color: inherit; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover .title { text-decoration: underline; }
.list-item .title { font-weight: 600; font-size: var(--t-sm); }
.list-item .meta { color: var(--muted); font-size: var(--t-xs); margin-top: 2px; }
.date-chip { flex: none; text-align: center; width: 48px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px 0; }
.date-chip b { display: block; font: 700 18px/1.1 var(--font-display); }
.date-chip span { font-size: 11px; color: var(--muted); }

/* ---------------------------------------------------------------- detalhe */
.detail-head { margin-bottom: 18px; display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.detail-head h1 { font-size: 28px; letter-spacing: -.02em; }
.detail-head .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: var(--t-sm); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 22px 0 18px; overflow-x: auto; }
.tab { font: 600 var(--t-sm)/1 var(--font); padding: 12px 14px; border: 0; background: none; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--signal); }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 24px; }
.facts dt { font-size: var(--t-xs); color: var(--muted); }
.facts dd { margin: 3px 0 0; font-size: var(--t-sm); font-weight: 500; overflow-wrap: anywhere; }
.facts .span-all { grid-column: 1 / -1; }
.facts .span-all dd { font-weight: 400; white-space: pre-wrap; max-width: 75ch; }
.timeline { display: grid; gap: 0; }
.tl-item { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 14px; padding-bottom: 18px; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--line-soft); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--navy-3); background: var(--surface); margin-top: 3px; }
.tl-item .meta { font-size: var(--t-xs); color: var(--muted); }
.tl-item p { font-size: var(--t-sm); margin-top: 4px; white-space: pre-wrap; }
.callout { border-left: 3px solid var(--signal); background: var(--signal-soft); padding: 12px 14px; border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: var(--t-sm); color: var(--signal-ink); }
.callout.info { border-color: var(--navy-3); background: #EEF3F8; color: var(--ink-2); }
.callout.bad { border-color: var(--bad); background: var(--bad-soft); color: #6E2219; }
h2.block { margin-bottom: 14px; }
.callout.spaced { margin-top: 18px; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- modal e aviso */
dialog.modal { border: 0; padding: 0; border-radius: var(--r-lg); width: min(520px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(15, 39, 64, .28); color: var(--ink); }
dialog.modal::backdrop { background: rgba(15, 39, 64, .45); }
.modal form { padding: 22px; display: grid; gap: 16px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.modal .secret { font: 600 20px/1.3 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; background: var(--steel); border: 1px dashed var(--line); padding: 12px 14px; border-radius: var(--r-sm); text-align: center; letter-spacing: .04em; user-select: all; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 60; max-width: 380px; background: var(--navy); color: #fff; padding: 13px 16px; border-radius: var(--r-md); font-size: var(--t-sm); box-shadow: 0 10px 30px rgba(15, 39, 64, .3); }
.toast.bad { background: #7A2318; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- celular / tablet */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; width: 270px; }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { position: fixed; inset: 0; background: rgba(15, 39, 64, .45); z-index: 25; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 20; align-items: center; justify-content: space-between; background: var(--navy); padding: 10px 16px; }
  .topbar .btn { background: transparent; color: #fff; border-color: var(--navy-3); }
  .main { margin-left: 0; padding: 20px 16px 48px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(3) { border-left: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-brand { padding: 32px 24px; }
  .login-claim h1 { font-size: 30px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .metric b { font-size: 26px; }
  .funnel-row { grid-template-columns: 100px minmax(0, 1fr) 28px; }
  .facts { grid-template-columns: minmax(0, 1fr); }
  .meter-strip { gap: 2px; }
}
@media (prefers-reduced-motion: no-preference) {
  .login-meter .meter-strip i { animation: tick-in .5s ease both; animation-delay: calc(var(--i) * 28ms); }
  @keyframes tick-in { from { transform: scaleY(.2); opacity: 0; } to { transform: none; opacity: 1; } }
}
