:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ebe5d8;
  --text: #1b2621;
  --muted: #667069;
  --line: #d8d0c1;
  --primary: #1f4d3a;
  --primary-2: #2f7657;
  --accent: #b56f2c;
  --danger: #a83a32;
  --shadow: 0 14px 35px rgba(41, 34, 22, 0.09);
}

body.dark {
  color-scheme: dark;
  --bg: #171916;
  --surface: #20241f;
  --surface-2: #2a3029;
  --text: #f3f0e8;
  --muted: #b7bdae;
  --line: #3f473d;
  --primary: #6fc195;
  --primary-2: #95d7af;
  --accent: #dda15e;
  --danger: #ff8a7b;
  --shadow: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--surface);
  font-weight: 800;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tabs button {
  min-height: 42px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 0 14px;
}

.nav-tabs button.active,
.nav-tabs button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.workspace {
  padding: 26px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0;
}

h1, h2, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  font-size: 18px;
  margin-bottom: 0;
}

.topbar-actions,
.report-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-action,
.secondary-action,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 15px;
  font-weight: 700;
}

.primary-action {
  background: var(--primary);
  color: var(--surface);
}

.secondary-action {
  background: var(--surface-2);
  color: var(--text);
}

.icon-button {
  width: 42px;
  padding: 0;
  background: var(--surface-2);
  color: var(--text);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kpi-grid,
.dashboard-grid,
.report-grid,
.card-grid {
  display: grid;
  gap: 16px;
}

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

.metric,
.panel,
.feed-card,
.report-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr);
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header span {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-2);
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.logo-panel {
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 760px;
  margin-bottom: 18px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.logo-preview {
  display: grid;
  place-items: center;
  flex: 0 0 112px;
  width: 112px;
  height: 112px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--primary);
  font-size: 28px;
  font-weight: 800;
  overflow: hidden;
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-controls {
  min-width: 0;
}

.logo-controls p {
  color: var(--muted);
  margin: 7px 0 14px;
}

.logo-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.file-action {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 15px;
  background: var(--primary);
  color: var(--surface);
  font-weight: 700;
  cursor: pointer;
}

#logoInput {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

.form-button {
  align-self: end;
}

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

.panel-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  color: var(--muted);
  text-align: center;
}

.danger-link {
  color: var(--danger);
  background: transparent;
  font-weight: 700;
}

.alert-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.alert-item {
  border-left: 4px solid var(--accent);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
}

.alert-item strong,
.alert-item span {
  display: block;
}

.alert-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.card-grid,
.report-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.feed-card,
.report-card {
  padding: 16px;
}

.feed-card p,
.report-card p {
  color: var(--muted);
  margin-bottom: 8px;
}

.feed-card strong,
.report-card strong {
  font-size: 22px;
}

@media (max-width: 1000px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kpi-grid,
  .dashboard-grid,
  .form-grid,
  .card-grid,
  .report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .logo-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-tabs,
  .kpi-grid,
  .form-grid,
  .card-grid,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .report-actions {
    width: 100%;
  }

  .topbar-actions button,
  .report-actions button {
    flex: 1;
  }
}

@media print {
  .sidebar,
  .topbar-actions,
  form,
  .report-actions {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .workspace {
    padding: 0;
  }

  .view {
    display: block;
    page-break-after: always;
  }
}
