:root {
  --navy: #14303F; --navy2: #1C4456; --blue: #226E93; --sky: #3D85C6; --ice: #8EC5E2;
  --bg: #F3F6F9; --card: #fff; --ink: #2F343A; --text: #4A535C; --mute: #6B7480; --line: #DDE4EA;
  --up: #17803f; --down: #b42318;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Montserrat', system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
button, input, select { font: inherit; color: inherit; }

.brand { font-weight: 800; font-size: 20px; color: #fff; white-space: nowrap; }
.brand span { font-weight: 500; color: var(--ice); font-size: 15px; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--navy); padding: 16px; }
.login-card { background: #fff; border-radius: 14px; padding: 36px 32px; width: 100%; max-width: 380px; }
.login-card .brand { color: var(--navy); margin-bottom: 26px; }
.login-card .brand span { color: var(--blue); }
.login-card h1 { font-size: 24px; }
.login-card p { color: var(--text); margin: 8px 0 18px; }
.login-card input { width: 100%; border: 1.5px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.login-card .btn { width: 100%; }
.login-msg { margin-top: 14px; color: var(--text); font-size: 13.5px; }

/* topo */
.top { background: var(--navy); color: #fff; display: flex; align-items: flex-end; gap: 24px; padding: 14px 24px; flex-wrap: wrap; }
.top .brand { align-self: center; }
.top-controls { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; flex: 1; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ice); }
.field select, .field input { background: var(--navy2); border: 1px solid #2c5a70; color: #fff; border-radius: 7px; padding: 8px 10px; min-width: 0; }
#accSel { min-width: 230px; max-width: 320px; }
.field .row { display: flex; gap: 6px; }
.field input[type=date] { color-scheme: dark; }
.check { display: flex; gap: 7px; align-items: center; font-size: 13px; color: #C8D5DD; padding-bottom: 8px; cursor: pointer; }
.top-right { display: flex; gap: 16px; align-items: center; margin-left: auto; padding-bottom: 8px; }
.updated { font-size: 12px; color: #A9BBC6; }
.link { color: #fff; font-weight: 600; text-decoration: none; font-size: 13px; }

/* filtros */
.filters { display: flex; gap: 10px; align-items: center; padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
.search { border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 220px; }
.period { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-left: 12px; border-left: 1.5px solid var(--line); }
.period .plabel { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--mute); }
.period select, .period input[type=date] { border: 1.5px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; color: var(--ink); }
.period input[type=date] { color-scheme: light; }
.period .ate { color: var(--mute); font-size: 13px; }
.filters .check { color: var(--text); padding-bottom: 0; }
.ms { position: relative; }
.ms > button { border: 1.5px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 12px; cursor: pointer; display: flex; gap: 8px; align-items: center; max-width: 320px; }
.ms > button b { font-weight: 700; }
.ms > button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.ms .drop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(20,48,63,.15); width: min(440px, 92vw); padding: 10px; }
.ms .drop > input { width: 100%; border: 1.5px solid var(--line); border-radius: 7px; padding: 7px 10px; margin-bottom: 8px; }
.ms .opts { max-height: 300px; overflow: auto; }
.ms .opt { display: flex; gap: 10px; align-items: flex-start; padding: 7px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; text-align: left; line-height: 1.35; }
.ms .opt input { flex: none; width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--blue); cursor: pointer; }
.ms .opt span { flex: 1; min-width: 0; word-break: break-word; }
.ms .opt:hover { background: var(--bg); }
.ms .opt small { color: var(--mute); display: block; }
.ms .acts { display: flex; justify-content: space-between; margin-top: 8px; }

.btn { border: 0; border-radius: 8px; padding: 11px 18px; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.ghost { background: #fff; border: 1.5px solid var(--line); color: var(--ink); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.link { background: none; color: var(--blue); padding: 4px 6px; }

.wrap { padding: 20px 24px 40px; max-width: 1500px; margin: 0 auto; }
.loading { background: #fff; border-radius: 10px; padding: 14px 18px; margin-bottom: 14px; color: var(--text); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border-radius: 10px; padding: 14px 16px; border: 1px solid var(--line); }
.kpi .l { font-size: 11.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--mute); }
.kpi .v { font-size: 22px; font-weight: 800; margin-top: 6px; white-space: nowrap; }
.kpi .d { font-size: 12.5px; font-weight: 700; margin-top: 4px; }
.kpi .d.up { color: var(--up); } .kpi .d.down { color: var(--down); } .kpi .d.flat { color: var(--mute); }
.kpi .d small { color: var(--mute); font-weight: 500; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-top: 16px; padding: 16px 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel h2 { font-size: 16px; }
.chart-ctl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chart-ctl select { border: 1.5px solid var(--line); border-radius: 7px; padding: 6px 8px; background: #fff; }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 12px; cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--navy); color: #fff; }
.chart-box { position: relative; height: 300px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; font-weight: 700; color: var(--mute); cursor: pointer; }
.tabs button.on { background: var(--bg); color: var(--navy); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: right; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--mute); padding: 9px 10px; border-bottom: 1.5px solid var(--line); cursor: pointer; white-space: nowrap; user-select: none; }
th:first-child, td:first-child { text-align: left; }
th.sorted { color: var(--navy); }
td { text-align: right; padding: 9px 10px; border-bottom: 1px solid #EEF2F5; white-space: nowrap; font-variant-numeric: tabular-nums; }
td:first-child { white-space: normal; min-width: 240px; max-width: 460px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #F7FAFC; }
tr.sel td { background: #EAF3F9; }
tr.total td { font-weight: 800; border-top: 1.5px solid var(--line); background: #FAFBFC; }
.name small { display: block; color: var(--mute); font-size: 11.5px; margin-top: 2px; }
.pill { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 10px; margin-left: 6px; vertical-align: middle; }
.pill.on { background: #DDF3E5; color: #17803f; } .pill.off { background: #EEF1F4; color: var(--mute); }
.thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; float: left; margin-right: 12px; background: var(--bg); position: relative; transition: transform .15s ease, box-shadow .15s ease; transform-origin: left center; }
.thumb-link { display: block; flex: none; }
.adcell { display: flex; gap: 12px; align-items: flex-start; }
.adcell .thumb { float: none; margin: 0; flex: none; }
.adtxt { min-width: 0; }
#hoverPrev { position: fixed; z-index: 50; width: 280px; height: 280px; object-fit: contain; background: #fff; border-radius: 10px; box-shadow: 0 12px 40px rgba(20,48,63,.35); pointer-events: none; display: none; }
.pv { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--blue); text-decoration: none; }
.pv:hover { text-decoration: underline; }
.share { display: inline-block; height: 8px; background: var(--sky); border-radius: 4px; vertical-align: middle; margin-right: 6px; }
.hint { color: var(--mute); font-size: 12px; margin-top: 10px; }

@media (max-width: 720px) {
  .top { padding: 12px 16px; gap: 12px; }
  .top-controls { gap: 10px; }
  #accSel { min-width: 0; width: 100%; max-width: none; }
  .top-controls .field { flex: 1 1 100%; }
  .top-right { margin-left: 0; }
  .filters { padding: 10px 16px; position: static; }
  .search { min-width: 0; flex: 1 1 100%; }
  .period { padding-left: 0; border-left: 0; flex: 1 1 100%; }
  .period select { flex: 1 1 100%; }
  .period input[type=date] { flex: 1 1 0; min-width: 0; }
  .wrap { padding: 14px 16px 30px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi .v { font-size: 18px; }
  .chart-box { height: 240px; }
}
