:root {
  --ink: #1c1c1c;
  --muted: #5c5c5c;
  --line: #d5d5d5;
  --head: #8d8d8d;
  --head-ink: #fff;
  --gold: #f3d56a;
  --gold-deep: #e6c14a;
  --paper: #fff;
  --select: #d6ebf8;
  --total: #ececec;
  --danger: #8d1d1d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px 10px;
  color: var(--ink);
  background: #f7f7f5;
  font: 13px/1.35 "Segoe UI", Tahoma, sans-serif;
  overflow: hidden;
}

.top {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  text-decoration: none;
}

.brand img {
  height: 76px;
  width: auto;
  display: block;
}

h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.app-nav {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.app-nav a {
  color: #333;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  background: #ececec;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.app-nav a.is-current {
  background: #1c2430;
  color: #fff;
}

.session[hidden] { display: none; }

.session {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.session button {
  border: 0;
  background: transparent;
  color: #6d2a28;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

body.login-page {
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f4f1ea;
}

.login-card {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 28px;
  background: #fff;
  border: 1px solid #e4e0d8;
  border-radius: 16px;
}

.login-logo {
  width: min(260px, 100%);
  height: auto;
  display: block;
  margin: 0 auto 4px;
}

.login-card h1 {
  margin: 8px 0 0;
  font-size: 26px;
  letter-spacing: 0;
  text-transform: none;
}

.login-lead {
  margin: 0 0 6px;
  color: var(--muted);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.login-field input {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font: 14px/1.3 "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
}

.login-card button {
  height: 40px;
  margin-top: 4px;
  border: 0;
  border-radius: 999px;
  background: #16324f;
  color: #fff;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.login-card button:disabled { opacity: 0.6; cursor: wait; }

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 132px;
  flex: 1 1 132px;
}

.field span,
.kpi span,
.panel-head h2,
.panel h2 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field span { color: #fff; }

.field {
  background: #6f6f6f;
  color: #fff;
  border-radius: 8px;
  padding: 6px 8px 8px;
}

select, input[type="search"] {
  height: 28px;
  border: 0;
  border-radius: 4px;
  padding: 0 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.kpis {
  display: flex;
  gap: 8px;
  flex: 2 1 360px;
}

.kpi {
  flex: 1;
  background: var(--gold);
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
  padding: 6px 12px 8px;
}

.kpi strong {
  display: block;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.status {
  margin: 0;
  padding: 8px 10px;
  background: #fff4f4;
  color: var(--danger);
  border: 1px solid #eccaca;
  border-radius: 6px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel.grow { flex: 1; min-height: 0; }

.panel-head, .panel h2 {
  margin: 0;
  background: var(--head);
  color: var(--head-ink);
  padding: 6px 10px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 { padding: 0; background: transparent; }

.panel-head input { width: min(320px, 40vw); }

.scroll {
  overflow: auto;
  flex: 1;
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th, td {
  padding: 4px 8px;
  border-bottom: 1px solid #eee;
  text-align: left;
  white-space: nowrap;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #f6e7a8;
  z-index: 1;
  cursor: pointer;
  font-weight: 700;
}

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

tbody tr { cursor: pointer; }
tbody tr:hover { background: #f4f8fb; }
tbody tr.selected { background: var(--select); }

tfoot td {
  position: sticky;
  bottom: 0;
  background: var(--total);
  font-weight: 700;
}

.details {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: minmax(118px, 18vh) minmax(108px, 15vh);
  flex: 0 0 auto;
  gap: 8px;
}

#box-fv { grid-column: 1 / 4; grid-row: 1; }
#box-fc { grid-column: 4 / 7; grid-row: 1; }
#box-pv { grid-column: 1 / 3; grid-row: 2; }
#box-dc { grid-column: 3 / 5; grid-row: 2; }
#box-dp { grid-column: 5 / 7; grid-row: 2; }

#box-fc th:nth-child(3),
#box-fc td:nth-child(3),
#fv-body td:last-child,
#ot-body td:nth-child(4),
#ot-body td:nth-child(5) {
  white-space: normal;
}

@media (max-width: 820px) {
  body { height: auto; overflow: auto; }
  .brand img { height: 58px; }
  .details {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }
  #box-fv, #box-fc, #box-pv, #box-dc, #box-dp {
    grid-column: auto;
    grid-row: auto;
    min-height: 220px;
  }
  .panel.grow { min-height: 420px; }
}
