:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #687586;
  --line: #d8dee8;
  --nav: #16324f;
  --nav-active: #246b5f;
  --accent: #2f6fbb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  background: var(--nav);
  color: #fff;
  padding: 18px 14px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  margin: 2px 8px 20px;
}

nav {
  display: grid;
  gap: 4px;
}

.nav-link {
  display: block;
  color: #dce7f3;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
  font-weight: 600;
}

.nav-link:hover,
.nav-link.active {
  background: var(--nav-active);
  color: #fff;
}

.nav-link-secondary {
  margin-top: 10px;
  color: #b8c9dc;
}

.nav-user {
  margin: 12px 0 4px;
  padding: 9px 12px;
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 8px;
  color: rgb(255 255 255 / 78%);
  font-size: 12px;
  font-weight: 800;
}

.content {
  margin-left: 220px;
  padding: 24px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 26px;
}

h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

h3 {
  margin: 16px 0 10px;
  font-size: 15px;
}

.subtle,
.metric-detail {
  color: var(--muted);
}

.thumb-link {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #f0f3f6;
  text-decoration: none;
}

.thumb-link img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.thumb-placeholder {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

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

.metric {
  padding: 14px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-value {
  font-size: 25px;
  font-weight: 750;
  margin: 8px 0 4px;
}

.panel {
  padding: 16px;
  margin-bottom: 16px;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

input,
select {
  width: min(360px, 100%);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
}

.date-picker-input {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

.date-picker {
  position: absolute;
  z-index: 20;
  width: 292px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgb(18 34 52 / 16%);
}

.date-picker-header {
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.date-picker-title,
.date-picker-nav,
.date-picker-cell {
  border: 1px solid transparent;
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 8px;
  font: inherit;
  font-weight: 750;
}

.date-picker-title:hover,
.date-picker-nav:hover,
.date-picker-cell:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.date-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.week-grid {
  margin-bottom: 4px;
}

.month-grid,
.year-grid {
  grid-template-columns: repeat(3, 1fr);
}

.date-picker-week {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  padding: 4px 0;
}

.date-picker-cell {
  min-width: 0;
  min-height: 36px;
  cursor: pointer;
}

.date-picker-cell.wide {
  min-height: 42px;
}

.date-picker-cell.muted {
  color: #9aa5b2;
}

.date-picker-cell.today {
  border-color: #9fc7b9;
}

.date-picker-cell.selected {
  background: var(--accent);
  color: #fff;
}

.date-picker-cell.selected:hover {
  color: #fff;
}

.filter-bar {
  flex-wrap: wrap;
  align-items: end;
}

.filter-bar label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-weight: 700;
}

.filter-bar input,
.filter-bar select {
  width: 190px;
}

.filter-note {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.4;
}

.report-filter {
  margin-bottom: 14px;
}

.stack-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: end;
}

.stack-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.stack-form button {
  width: fit-content;
}

.confirm-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.notice {
  border: 1px solid #9fc7b9;
  background: #edf8f4;
  color: #1f6659;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.notice-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

input[type="file"],
input[type="checkbox"] {
  width: auto;
}

button,
.button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 9px 12px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

.button.ghost {
  color: var(--accent);
  background: #fff;
}

.button.disabled {
  border-color: var(--line);
  background: #eef2f6;
  color: var(--muted);
  cursor: default;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  margin: 8px 0 12px;
}

.page-size-form,
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.page-size-form label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.page-size-form select {
  width: auto;
}

.small-button {
  padding: 7px 9px;
  font-size: 12px;
}

.small-button.danger {
  border-color: #b73535;
  background: #b73535;
}

.inline-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.inline-link:hover {
  text-decoration: underline;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  margin: 14px 0 16px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--ink) !important;
  font-weight: 700;
}

.checkbox-row input {
  margin: 0;
  flex: 0 0 auto;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.image-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.image-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #f0f3f6;
  display: block;
}

.image-meta {
  padding: 10px;
  display: grid;
  gap: 6px;
}

.image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-form {
  display: inline;
}

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

.row-actions .inline-form {
  display: inline-flex;
}

.transfer-form {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.transfer-lines {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.transfer-line {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(120px, 180px) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.transfer-line label {
  margin: 0;
}

.transfer-remove[hidden] {
  display: none;
}

.badge {
  display: inline-block;
  width: fit-content;
  border-radius: 999px;
  background: #d9efe9;
  color: #1f6659;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 8px;
}

.label-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.label-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  padding: 12px;
  min-width: 0;
}

.qr-box {
  width: 112px;
  height: 112px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  display: grid;
  place-items: center;
}

.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-missing {
  color: var(--muted);
  font-weight: 700;
}

.label-info {
  min-width: 0;
  display: grid;
  gap: 7px;
  align-content: start;
}

.label-info span,
.label-info code {
  overflow-wrap: anywhere;
}

.label-info code {
  background: #f0f3f6;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 12px;
}

.label-actions {
  margin-top: 4px;
}

.chart-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.45fr) minmax(320px, 1fr);
  gap: 12px;
  align-items: start;
}

.chart-grid > div {
  min-width: 0;
}

.chart-grid > div:first-child {
  grid-column: 1 / -1;
}

.chart-card,
.bar-chart {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.chart-title {
  font-size: 14px;
  font-weight: 850;
}

.chart-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart-legend {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 0;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.swatch.revenue {
  background: #2f6fbb;
}

.swatch.cost {
  background: #8d98a7;
}

.swatch.profit {
  background: #246b5f;
}

.chart-svg {
  max-width: none;
  height: 300px;
  display: block;
}

.chart-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.chart-axis {
  stroke: #cfd7e2;
  stroke-width: 2;
}

.chart-gridline {
  stroke: #edf2f7;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-line.revenue {
  stroke: #2f6fbb;
}

.chart-line.profit {
  stroke: #246b5f;
}

.chart-bar {
  shape-rendering: geometricPrecision;
}

.chart-bar.revenue {
  fill: #2f6fbb;
}

.chart-bar.cost {
  fill: #8d98a7;
}

.chart-bar.profit {
  fill: #246b5f;
}

.chart-bar:hover {
  filter: brightness(0.92);
}

.chart-svg text,
.chart-y-label,
.chart-x-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.chart-dot {
  stroke: #fff;
  stroke-width: 2;
}

.chart-dot.revenue {
  fill: #2f6fbb;
}

.chart-dot.profit {
  fill: #246b5f;
}

.bar-chart {
  display: grid;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(130px, 1.6fr) minmax(92px, auto);
  gap: 8px;
  align-items: center;
}

.bar-label {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 750;
}

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

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: #2f6fbb;
}

.bar-fill.negative {
  background: #b73535;
}

.bar-value {
  color: var(--muted);
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  background: #edf2f7;
  color: #23364a;
  font-size: 12px;
  text-transform: uppercase;
}

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

.empty {
  color: var(--muted);
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
  background: #edf1f5;
}

.login-shell {
  width: min(100%, 380px);
}

.login-panel {
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 34px rgb(18 34 52 / 8%);
}

.login-panel h1 {
  font-size: 24px;
}

.login-panel p {
  margin: 0;
  color: var(--muted);
}

.login-panel label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.login-panel input {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.login-panel button {
  width: 100%;
}

.form-error {
  padding: 10px 12px;
  border: 1px solid #f0b8b8;
  border-radius: 6px;
  background: #fff1f1;
  color: #9a2525;
  font-weight: 700;
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .content {
    margin-left: 0;
    padding: 16px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .page-header {
    align-items: start;
    flex-direction: column;
    gap: 6px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .label-card {
    grid-template-columns: 96px 1fr;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .bar-value {
    text-align: left;
  }

  .transfer-line {
    grid-template-columns: 1fr;
  }

  .qr-box {
    width: 96px;
    height: 96px;
  }
}
