/* Sistema Dora · UI interna sóbria, mobile-first. Tokens do brandbook v1.2. */
@font-face { font-family: 'Gloock'; src: url('/fonts/Gloock-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Hanken Grotesk'; src: url('/fonts/HankenGrotesk-Variavel.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }

:root {
  --cacau: #3B1F17;
  --ganache: #6E3F2C;
  --creme: #F7EEDF;
  --rosa: #F2C4C0;
  --caramelo: #B98A5E;
  --branco: #FFFDF9;
  --linha: #E6D8C3;
  --texto: #3B1F17;
  --texto-2: #6E3F2C;
  --muted: #8A6A5C;
  --ok: #2F6B3F;
  --ok-bg: #E3F0E3;
  --warn: #8A5A00;
  --warn-bg: #FBEFD2;
  --danger: #9B2C21;
  --danger-bg: #F8DEDA;
  --info-bg: #EFE6D8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(59, 31, 23, .08), 0 4px 14px rgba(59, 31, 23, .05);
  --font-ui: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-title: 'Gloock', Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-ui); font-size: 16px; line-height: 1.45; color: var(--texto); background: var(--creme); }
a { color: var(--ganache); }
a:hover { color: var(--cacau); }
h1, h2 { font-family: var(--font-title); font-weight: 400; color: var(--cacau); margin: 0 0 .5rem; line-height: 1.15; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 .75rem; }
.icon { flex: none; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hint { display: block; font-size: .8rem; color: var(--muted); margin-top: .2rem; font-weight: 400; }
.mt { margin-top: 1rem; }
.right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; }
.grow { flex: 1 1 auto; }
.pre { white-space: pre-wrap; }
.warn-text { color: var(--warn); }
.danger-text { color: var(--danger); font-weight: 600; }
.rose-text { color: var(--ganache); font-weight: 600; }
code, .code { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.code { display: block; background: var(--cacau); color: var(--creme); padding: .75rem; border-radius: 8px; overflow-x: auto; white-space: pre; }

/* Shell ---------------------------------------------------------------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; background: var(--branco); border-bottom: 1px solid var(--linha); }
.topbar-brand img { display: block; height: 32px; width: auto; }
.topbar-title { font-weight: 600; color: var(--texto-2); font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { padding: 1rem 1rem 6rem; max-width: 1100px; }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--cacau); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem 0 .55rem; color: #E9D9C4; text-decoration: none; font-size: .72rem; font-weight: 600; }
.bottomnav a.active { color: var(--rosa); }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 240px 1fr; }
  .sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; background: var(--cacau); color: var(--creme); padding: 1.25rem .75rem; overflow-y: auto; }
  .sidebar .brand { padding: 0 .5rem 1rem; }
  .sidebar .brand img { width: 170px; height: auto; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar nav a { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; border-radius: 8px; color: #EADBC6; text-decoration: none; font-weight: 500; font-size: .95rem; }
  .sidebar nav a:hover { background: rgba(247, 238, 223, .08); color: var(--creme); }
  .sidebar nav a.active { background: var(--ganache); color: var(--creme); }
  .sidebar-user { margin-top: auto; padding: 1rem .75rem 0; border-top: 1px solid rgba(247, 238, 223, .15); display: flex; justify-content: space-between; align-items: center; font-size: .9rem; }
  .sidebar-user .link { color: var(--rosa); }
  .topbar { display: none; }
  .bottomnav { display: none; }
  .main { padding: 2rem 2.5rem 3rem; }
  h1 { font-size: 2rem; }
}

/* Auth ------------------------------------------------------------------ */
.bare-main { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 380px; background: var(--branco); border-radius: 16px; padding: 1.75rem 1.5rem; box-shadow: var(--shadow); text-align: center; }
.auth-logo { width: 170px; height: auto; margin: 0 auto .5rem; display: block; }
.auth-title { font-size: 1.4rem; margin-bottom: 1rem; }
.auth-card form { text-align: left; }

/* Componentes -------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin-bottom: .1rem; }
.page-head p { margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.card { background: var(--branco); border: 1px solid var(--linha); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; gap: .75rem; margin-bottom: .5rem; }
.big-num { font-size: 1.25rem; font-family: var(--font-title); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1rem; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.1; }
.btn.primary { background: var(--cacau); color: var(--creme); }
.btn.primary:hover { background: var(--ganache); color: var(--creme); }
.btn.secondary { background: var(--branco); color: var(--cacau); border-color: var(--linha); }
.btn.secondary:hover { border-color: var(--caramelo); }
.btn.danger { background: var(--branco); color: var(--danger); border-color: #E7B7B0; }
.btn.small { min-height: 34px; padding: .3rem .7rem; font-size: .875rem; }
.btn.block { width: 100%; }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; display: inline-flex; gap: .3rem; align-items: center; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.chips.tight { margin: .35rem 0 0; }
.chip { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--info-bg); color: var(--texto-2); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.rose { background: var(--rosa); color: var(--cacau); }
.chip.muted { background: #EEE7DC; color: var(--muted); }
.chip.example { background: #FFF3B0; color: #6B5300; letter-spacing: .03em; }

.flash { padding: .7rem .9rem; border-radius: 10px; margin: 0 0 1rem; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.flash.erro { background: var(--danger-bg); color: var(--danger); }

.issues { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.issue { padding: .6rem .8rem; border-radius: 10px; background: var(--info-bg); border-left: 4px solid var(--caramelo); font-size: .93rem; }
.issue.block { background: var(--danger-bg); border-color: var(--danger); color: #5E1A13; }
.issue.warn { background: var(--warn-bg); border-color: #C99222; color: #5A3B00; }
.issue a { color: inherit; }
p.issue { margin: .5rem 0; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin: 0 0 1rem; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--branco); border: 1px solid var(--linha); border-radius: var(--radius); padding: .7rem .8rem; display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-family: var(--font-title); font-size: 1.3rem; color: var(--cacau); overflow-wrap: anywhere; }
.stat-hint { font-size: .78rem; color: var(--muted); }
.stat.warn { border-color: #E5C27A; background: var(--warn-bg); }
.stat.ok .stat-value { color: var(--ok); }

.list { display: flex; flex-direction: column; gap: .5rem; }
.row-card { display: flex; justify-content: space-between; gap: .75rem; padding: .8rem .9rem; background: var(--branco); border: 1px solid var(--linha); border-radius: var(--radius); text-decoration: none; color: inherit; }
.row-card:hover { border-color: var(--caramelo); color: inherit; }
.row-main { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; text-align: right; flex: none; }
.score { font-weight: 700; color: var(--muted); font-size: .85rem; }
.score.good { color: var(--ok); }
.empty { padding: 1.5rem 1rem; text-align: center; color: var(--muted); background: var(--branco); border: 1px dashed var(--linha); border-radius: var(--radius); }
.simple-list { list-style: none; margin: 0; padding: 0; }
.simple-list li { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; padding: .55rem 0; border-bottom: 1px solid var(--linha); }
.simple-list li:last-child { border-bottom: 0; }
ul.simple-list.card { padding: .25rem 1rem; }

.tabs { display: flex; gap: .3rem; overflow-x: auto; margin: 0 0 .75rem; padding-bottom: 2px; }
.tabs a { padding: .4rem .75rem; border-radius: 999px; text-decoration: none; color: var(--texto-2); background: var(--branco); border: 1px solid var(--linha); font-size: .875rem; font-weight: 600; white-space: nowrap; }
.tabs a.active { background: var(--cacau); color: var(--creme); border-color: var(--cacau); }
.filters { margin: 0 0 .75rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { flex: 1; }

.dl { display: grid; grid-template-columns: minmax(110px, 35%) 1fr; gap: .4rem .75rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .875rem; }
.dl dd { margin: 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .5rem .55rem; border-bottom: 1px solid var(--linha); text-align: left; white-space: nowrap; }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table.result td { white-space: normal; }
.table.result tr.subtotal td { font-weight: 700; border-top: 2px solid var(--linha); }
.table.result tr.total td { font-weight: 800; font-size: 1.05rem; background: var(--creme); }
.table.compact th, .table.compact td { padding: .3rem .4rem; }
.row-warn td { background: var(--warn-bg); }
.row-muted td { color: var(--muted); }

.bar { position: relative; height: 14px; background: #EEE3D2; border-radius: 999px; overflow: hidden; margin: .5rem 0; }
.bar span { display: block; height: 100%; background: var(--ganache); }
.bar span.warn { background: #C99222; }
.bar i { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--cacau); }

/* Formulários ------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: .85rem; max-width: 760px; }
.form.wide { max-width: 1000px; }
.stack { display: flex; flex-direction: column; gap: .85rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; color: var(--texto-2); }
input, select, textarea { font: inherit; font-size: 16px; color: var(--texto); background: var(--branco); border: 1px solid #D9C7AE; border-radius: 10px; padding: .6rem .7rem; min-height: 44px; width: 100%; font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(242, 196, 192, .8); border-color: var(--ganache); }
input.big { font-size: 1.4rem; font-weight: 700; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--cacau); flex: none; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
label.check.center { align-self: end; min-height: 44px; }
fieldset { border: 1px solid var(--linha); border-radius: var(--radius); padding: .75rem .9rem 1rem; margin: 0; background: var(--branco); }
legend { font-weight: 700; color: var(--cacau); padding: 0 .35rem; }
fieldset.override { border-color: var(--danger); background: #FFF6F4; }
.checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem .75rem; }
.checks.two { grid-template-columns: 1fr 1fr; margin-top: .6rem; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: .85rem; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.form-actions.sticky { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--creme) 70%, transparent); padding: .75rem 0 .25rem; z-index: 5; }
@media (min-width: 900px) { .form-actions.sticky { bottom: 0; } .form-actions.sticky .btn.block { width: auto; min-width: 240px; } }
.inline { display: inline-flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin: 0; }
.inline input[type=date], .inline input[type=month] { width: auto; }
.inline-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-top: .5rem; }
.inline-form label { flex: 1 1 140px; }
.inline-form label.grow { flex: 3 1 200px; }
.inline-form .btn { flex: 0 0 auto; }
.context-box { display: flex; flex-direction: column; gap: .2rem; padding: .7rem .85rem; border-radius: 10px; background: var(--info-bg); font-size: .92rem; }
.price-preview { padding: .7rem .85rem; border-radius: 10px; background: var(--cacau); color: var(--creme); font-weight: 600; }
.price-preview strong { color: var(--rosa); font-size: 1.15rem; }
.settings-grid { display: grid; grid-template-columns: 1fr; gap: .9rem; }
@media (min-width: 700px) { .settings-grid { grid-template-columns: 1fr 1fr; } }
.setting em.changed { color: var(--warn); font-style: normal; font-weight: 500; font-size: .8rem; }

/* Hoje / Rota ---------------------------------------------------------------- */
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 0 0 1rem; }
@media (min-width: 900px) { .quick { grid-template-columns: repeat(4, 1fr); } }
.quick-card { display: flex; flex-direction: column; gap: .1rem; padding: .9rem; background: var(--branco); border: 1px solid var(--linha); border-radius: var(--radius); text-decoration: none; color: var(--texto); box-shadow: var(--shadow); }
.quick-card.primary { background: var(--cacau); color: var(--creme); border-color: var(--cacau); }
.quick-card.primary .small { color: var(--rosa); }
.quick-n { font-family: var(--font-title); font-size: 1.5rem; line-height: 1.1; overflow-wrap: anywhere; }
.route-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin: 0 0 1rem; }
.route-summary > div { background: var(--branco); border: 1px solid var(--linha); border-radius: var(--radius); padding: .6rem .7rem; display: flex; flex-direction: column; min-width: 0; }
.route-summary .stat-value { font-size: 1.15rem; }
.stops { display: flex; flex-direction: column; gap: .75rem; }
.stop { background: var(--branco); border: 1px solid var(--linha); border-radius: var(--radius); padding: .85rem; box-shadow: var(--shadow); }
.stop.done { opacity: .7; }
.stop.suspended { border-color: var(--danger); }
.stop header { display: flex; gap: .6rem; align-items: flex-start; }
.stop-n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--rosa); color: var(--cacau); display: grid; place-items: center; font-weight: 800; font-size: .9rem; }
.stop-name { font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--cacau); }
.stop-facts { margin: .6rem 0; padding-left: 1.1rem; font-size: .93rem; display: flex; flex-direction: column; gap: .2rem; }
.stop-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.stop-actions .btn.primary { flex: 1 1 auto; }
.receivable { display: flex; flex-direction: column; gap: .5rem; padding: .75rem 0; border-top: 1px solid var(--linha); }
@media (min-width: 900px) { .receivable { flex-direction: row; justify-content: space-between; align-items: flex-end; } .receivable .pay-form { margin: 0; flex-wrap: nowrap; } .receivable .pay-form label { flex: 0 0 120px; } }

.funnel { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin: 0 0 .5rem; }
@media (min-width: 700px) { .funnel { grid-template-columns: repeat(6, 1fr); } }
.funnel-step { display: flex; flex-direction: column; align-items: center; padding: .5rem; background: var(--branco); border: 1px solid var(--linha); border-radius: 10px; text-decoration: none; color: var(--texto-2); font-size: .8rem; font-weight: 600; }
.funnel-step.active { border-color: var(--cacau); background: var(--rosa); color: var(--cacau); }
.funnel-n { font-family: var(--font-title); font-size: 1.3rem; color: var(--cacau); }

.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.menu-item { display: flex; align-items: center; gap: .6rem; padding: .9rem; background: var(--branco); border: 1px solid var(--linha); border-radius: var(--radius); text-decoration: none; color: var(--cacau); font-weight: 600; }

details summary { cursor: pointer; font-weight: 600; color: var(--texto-2); }
