:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #d9e0ec;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --blue: #2563eb;
  --amber: #b45309;
  --green: #15803d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 22px 28px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.header-logo {
  width: 132px;
  height: auto;
  object-fit: contain;
  flex: 0 0 auto;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 28px; }
h2 { margin-bottom: 4px; font-size: 22px; }
p { color: var(--muted); }

button, .file-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  min-height: 40px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

button:hover, .file-button:hover { border-color: #aab7c9; }
button.primary { background: var(--brand); color: #fff; border-color: var(--brand); }

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-button input { display: none; }

.header-actions, .row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab.active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

main { padding: 22px 28px 34px; }

.panel { display: none; }
.panel.active { display: block; }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: .03em;
}

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
}

.kpi:nth-child(1) strong { color: var(--blue); }
.kpi:nth-child(2) strong { color: var(--brand); }
.kpi:nth-child(3) strong { color: var(--amber); }
.kpi:nth-child(4) strong { color: var(--green); }

.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.tool-surface, .report-preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: auto;
}

.market-summary-surface {
  margin-bottom: 12px;
}

.compact-table table {
  min-width: 900px;
}

.compact-table th, .compact-table td {
  padding: 8px 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 12px;
  color: #344054;
  background: #f8fafc;
  text-transform: uppercase;
}

td input, td select, .report-controls input, .report-controls select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
}

.inline-email {
  width: min(320px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
}

textarea {
  min-height: 150px;
  margin-bottom: 10px;
  resize: vertical;
}

.report-controls {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.report-controls label {
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.report-controls input, .report-controls select {
  display: block;
  margin-top: 5px;
  text-transform: none;
  font-weight: 400;
  color: var(--ink);
}

.market-controls {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(180px, 1fr) minmax(220px, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.log-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.market-controls label, .log-controls label {
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.market-controls input, .market-controls select, .log-controls select {
  display: block;
  width: 100%;
  margin-top: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  text-transform: none;
  font-weight: 400;
  color: var(--ink);
  background: #fff;
}

.market-kpis {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
}

.time-zone-kpis {
  grid-template-columns: repeat(7, minmax(145px, 1fr));
}

.time-zone-kpis .kpi {
  padding: 12px;
}

.time-zone-kpis .kpi strong {
  font-size: 26px;
}

.log-kpis {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
}

.report-kpis {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
}

.status-line {
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.report-actions { margin-bottom: 12px; }

.report-preview {
  min-height: 320px;
  overflow: auto;
}

.report-preview h3 { margin-bottom: 6px; }
.report-preview .meta { color: var(--muted); margin-bottom: 14px; }

.bar-cell {
  display: grid;
  grid-template-columns: minmax(36px, 70px) 1fr minmax(34px, auto);
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #e6ebf3;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--brand);
}

.compact-list {
  display: grid;
  gap: 8px;
}

.compact-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.steps {
  margin-bottom: 0;
  color: #344054;
  line-height: 1.7;
}

.pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #166534;
  font-size: 12px;
  font-weight: 700;
}

.logo-cell {
  min-width: 150px;
}

.logo-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.logo-preview img {
  max-width: 72px;
  max-height: 38px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 3px;
}

.mini-file-button {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}

.link-button {
  border: 0;
  min-height: 0;
  padding: 0;
  color: var(--blue);
  background: transparent;
}

.report-logo {
  max-width: 150px;
  max-height: 72px;
  object-fit: contain;
  display: block;
  margin-bottom: 10px;
}

.summary-logo {
  max-width: 70px;
  max-height: 34px;
  object-fit: contain;
}

.empty {
  padding: 16px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .app-header, .section-heading { flex-direction: column; align-items: stretch; }
  .header-brand { align-items: flex-start; }
  .kpis, .workspace-grid, .report-controls, .market-controls, .log-controls { grid-template-columns: 1fr; }
  main { padding: 16px; }
  .tabs { padding: 12px 16px; }
}

@media print {
  body { background: #fff; }
  .app-header, .tabs, .section-heading, .report-controls, .report-actions { display: none !important; }
  main { padding: 0; }
  .panel { display: none !important; }
  #reports { display: block !important; }
  .report-preview { border: 0; padding: 0; }
}
