/*
 * FLOWS - folha unica, sem framework.
 *
 * Os valores abaixo vem do handoff de design (Fluxos de Aprovacao Mockups):
 * a paleta e a identidade institucional da JCB, usada so como acento visual.
 */

:root {
  --page:        #F6F5F2;
  --surface:     #FFFFFF;
  --border:      #E4E2DC;
  --border-soft: #F0EEE9;
  --text:        #1E2022;
  --text-muted:  #575D5E;
  --text-faint:  #9B9B9B;

  --sidebar:        #1E2022;
  --sidebar-border: #33373A;
  --sidebar-hover:  #2A2D30;
  --sidebar-text:   #D8D6D0;

  --accent:       #FCAF26;
  --accent-hover: #E89C14;

  --success:      #717539;
  --success-text: #4B4F27;
  --success-bg:   #E8EAD9;
  --warning-text: #8A5A06;
  --warning-bg:   #FDEFD3;
  --danger:       #B23A2E;
  --danger-soft:  #D9B7AE;
  --danger-bg:    #F5E1DC;

  --radius:      8px;
  --radius-card: 12px;
  --radius-pill: 20px;

  --font: -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--page);
}

a { color: var(--text-muted); text-decoration: none; }
a:hover { color: var(--text); }

/* ---------- Login ---------- */

.login-screen {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page);
  position: relative;
  padding: 24px;
}

.login-card {
  width: 400px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 8px 30px rgba(30, 32, 34, 0.06);
}

/* Espaco reservado para a marca da empresa. O logotipo da JCB e marca de
   terceiros e nao e distribuido com o software - ver README. */
.logo-slot {
  width: 180px;
  height: 56px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-faint);
  font-size: 12px;
}


/* Logotipo JCB. Altura fixa, largura pelo aspecto original (813x254) — a marca
   nao pode ser redesenhada, recolorida nem distorcida. Sobre fundo claro usa-se
   a versao escura; sobre a sidebar, a branca. */
.brand-logo {
  height: 44px;
  width: auto;
  display: block;
  margin: 0 auto 24px;
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .wordmark { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }
.login-brand .tagline { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.login-footer {
  position: absolute;
  bottom: 24px;
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- Formularios ---------- */

.field { margin-bottom: 16px; }
.field:last-of-type { margin-bottom: 24px; }

.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.input, .textarea, .select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}

.login-card .input { background: var(--page); }
.textarea { resize: vertical; }
.input:focus, .textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.field-compact { margin-bottom: 14px; }
.field-compact .label { font-size: 12.5px; }
.field-compact .input, .field-compact .textarea { padding: 10px 12px; }

/* ---------- Botoes ---------- */

.btn {
  display: inline-block;
  padding: 13px 28px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn-block { width: 100%; padding: 13px; }
.btn-primary { background: var(--accent); color: var(--text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-dark { background: var(--text); color: #fff; padding: 10px 20px; font-size: 13px; }
.btn-small { padding: 10px 18px; font-size: 13.5px; }

.btn-approve {
  padding: 9px 20px;
  background: var(--success);
  color: #fff;
  font-size: 13px;
  border-radius: 7px;
}

.btn-reject {
  padding: 9px 20px;
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  border-radius: 7px;
}

.btn[disabled], .btn:disabled { cursor: not-allowed; }
.btn-primary:disabled { background: var(--border); color: var(--text-faint); }
.btn-reject:disabled { background: var(--danger-soft); }

.btn-link {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-link:hover { color: var(--text); }

/* ---------- Layout da aplicacao ---------- */

.app { display: flex; width: 100%; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 20px;
}

.sidebar-brand .mark {
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 2px;
}

.sidebar-brand .name { font-size: 16px; font-weight: 700; letter-spacing: 0.5px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.sidebar-nav a {
  padding: 11px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  color: var(--sidebar-text);
}

.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav a.is-active { background: var(--sidebar-hover); color: #fff; }

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding-top: 16px;
  margin-top: 16px;
}

.sidebar-user { font-size: 12.5px; color: var(--sidebar-text); padding: 0 10px 10px; }
.sidebar-user .roles { color: var(--text-faint); font-size: 11.5px; margin-top: 2px; }

.sidebar-footer .signout {
  display: block;
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--text-faint);
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
}

.sidebar-footer .signout:hover { color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.topbar .screen-title { font-size: 20px; font-weight: 700; }
.topbar .meta { display: flex; align-items: center; gap: 16px; }

.bell {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--page);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.bell .count {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.topbar .who { text-align: right; }
.topbar .who .name { font-size: 13px; font-weight: 700; }
.topbar .who .role { font-size: 12px; color: var(--text-muted); }

.content { padding: 32px 40px 80px; }

/* ---------- Cartoes e tabelas ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
}

.card-flush { padding: 0; overflow: hidden; }
.card-form { padding: 28px; }

.card-title {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat .caption { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.stat .value { font-size: 30px; font-weight: 700; margin-top: 8px; }
.stat .value.is-money { font-size: 26px; }
.stat .value.is-approved { color: var(--success-text); }
.stat .value.is-rejected { color: var(--danger); }

.table-scroll { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; }

table.data thead tr { background: var(--page); }

table.data th {
  text-align: left;
  padding: 10px 20px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

table.data td {
  padding: 13px 20px;
  font-size: 13px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-soft);
}

table.data tbody tr:last-child td { border-bottom: none; }
table.data td.wrap { white-space: normal; }
table.data td.muted { color: var(--text-muted); }
table.data td.strong { font-weight: 600; }
table.data td.ref { font-weight: 600; color: var(--text-muted); }
table.data td.action { text-align: right; }

.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 60px;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
}

.badge-pending   { background: var(--warning-bg); color: var(--warning-text); }
.badge-approved  { background: var(--success-bg); color: var(--success-text); }
.badge-rejected  { background: var(--danger-bg);  color: var(--danger); }
.badge-draft     { background: var(--border);     color: var(--text-muted); }
.badge-cancelled { background: var(--border);     color: var(--text-muted); }

.badge-role {
  padding: 3px 9px;
  font-size: 11px;
  margin-right: 5px;
}

.badge-role-admin     { background: var(--text);    color: #fff; }
.badge-role-approver  { background: var(--accent);  color: var(--text); }
.badge-role-requester { background: var(--border);  color: var(--text-muted); }
.badge-role-auditor   { background: var(--success); color: #fff; }

.status-active   { color: var(--success-text); font-weight: 600; font-size: 12.5px; }
.status-inactive { color: var(--text-faint);   font-weight: 600; font-size: 12.5px; }

/* ---------- Novo pedido ---------- */

.request-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.section-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; }

.flow-type-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 28px; }

.flow-type-option {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  border: 2px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
}

.flow-type-option .name { font-size: 13.5px; font-weight: 700; }
.flow-type-option .description { font-size: 12px; color: var(--text-muted); }
.flow-type-option input { position: absolute; opacity: 0; pointer-events: none; }
.flow-type-option:has(input:checked) { border-color: var(--accent); background: #FFFBF0; }

.steps-panel .step { display: flex; gap: 10px; margin-bottom: 16px; }

.steps-panel .step .order {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--page);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.steps-panel .step.is-done .order { background: var(--success-bg); border-color: var(--success-bg); color: var(--success-text); }
.steps-panel .step.is-current .order { background: var(--accent); border-color: var(--accent); }
.steps-panel .step.is-rejected .order { background: var(--danger-bg); border-color: var(--danger-bg); color: var(--danger); }
.steps-panel .step .name { font-size: 13px; font-weight: 600; padding-top: 2px; }
.steps-panel .step .name small { display: block; font-weight: 400; color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.steps-panel .hint { font-size: 12px; color: var(--text-faint); margin-top: 8px; }

.attachment-hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

/* ---------- Fila de aprovacao ---------- */

.queue-card { margin-bottom: 14px; }

.queue-card .head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.queue-card .title { font-size: 14px; font-weight: 700; }
.queue-card .subtitle { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.queue-card .amount { font-size: 17px; font-weight: 700; }
.queue-card .date { font-size: 12px; color: var(--text-faint); }
.queue-card .decision { margin-top: 14px; }
.queue-card .decision .textarea { padding: 9px 12px; font-size: 13px; margin-bottom: 10px; }
.queue-card .actions { display: flex; gap: 10px; }

/* ---------- Administracao ---------- */

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.tabs a {
  padding: 10px 4px;
  margin-right: 20px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-faint);
  border-bottom: 2px solid transparent;
}

.tabs a.is-active { color: var(--text); border-bottom-color: var(--accent); }

.toolbar { display: flex; justify-content: flex-end; margin-bottom: 14px; }

.checkbox-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.flow-type-card { margin-bottom: 16px; }
.flow-type-card .name { font-size: 15px; font-weight: 700; }
.flow-type-card .description { font-size: 13px; color: var(--text-muted); margin-top: 4px; margin-bottom: 14px; }
.flow-type-card .chips { display: flex; gap: 10px; flex-wrap: wrap; }

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
}

.chip .order {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Detalhe da solicitacao ---------- */

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.detail-list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-list dt { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.detail-list dd { margin: 4px 0 0; font-size: 14px; font-weight: 600; }
.detail-list .full { grid-column: 1 / -1; }
.detail-list .full dd { font-weight: 400; line-height: 1.5; }

/* ---------- Mensagens ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.toast.is-alert { background: var(--danger); }

.form-errors {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 18px;
}

.form-errors ul { margin: 0; padding-left: 18px; }

.inline-alert {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 18px;
}

/* ---------- Responsivo ---------- */

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .request-layout, .detail-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; }
  .topbar, .content { padding-left: 20px; padding-right: 20px; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .detail-list { grid-template-columns: minmax(0, 1fr); }
}
