:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --surface: #eef4f5;
  --ink: #142321;
  --muted: #667674;
  --line: #dce5e5;
  --panel: #ffffff;
  --accent: #0b7285;
  --accent-strong: #084e5c;
  --accent-soft: #e6f4f6;
  --gold: #b7791f;
  --gold-soft: #fff4df;
  --good: #087f5b;
  --bad: #c92a2a;
  --warn: #9a6700;
  --shadow: 0 18px 42px rgba(20, 35, 33, 0.08);
  --shadow-soft: 0 8px 22px rgba(20, 35, 33, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(11, 114, 133, 0.08), rgba(255, 255, 255, 0) 260px),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 860px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 18px 34px;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: calc(100vh - 48px);
  display: grid;
  align-content: center;
  gap: 28px;
}

.brand-block {
  display: grid;
  gap: 10px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.brand-block p:last-child {
  color: var(--muted);
}

.login-panel,
.filter-bar,
.detail-tools,
.metric-card,
.supplier-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.login-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

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

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fbfdfd;
  color: var(--ink);
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 111, 131, 0.12);
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(11, 114, 133, 0.16);
}

.ghost-button,
.link-button,
.tab {
  background: transparent;
  color: var(--ink);
  box-shadow: none;
}

.ghost-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.link-button {
  min-height: 32px;
  color: var(--accent-strong);
  padding: 0;
}

.form-error,
.status-text {
  color: var(--bad);
  min-height: 20px;
  font-size: 13px;
}

.dashboard-view {
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 4px 0 2px;
}

.topbar h1 {
  font-size: 30px;
  margin-top: 3px;
}

.period-text {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.period-actions {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 1.4fr 0.8fr;
  gap: 8px;
  align-items: stretch;
}

.quick-button,
.month-compact {
  min-height: 38px;
  border: 1px solid rgba(220, 229, 229, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
  box-shadow: none;
}

.quick-button {
  padding: 0 10px;
}

.quick-button.active {
  border-color: rgba(11, 114, 133, 0.26);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.month-compact {
  position: relative;
  display: grid;
  align-items: center;
  padding: 0 10px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
}

.month-compact input {
  position: absolute;
  inset: 0;
  opacity: 0;
  min-height: 100%;
  cursor: pointer;
}

.filter-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
}

.search-field {
  grid-column: 1 / -1;
}

.month-field {
  grid-column: 1 / -1;
}

.detail-tools {
  padding: 14px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid rgba(220, 229, 229, 0.7);
}

.tab {
  min-height: 38px;
  color: var(--muted);
  border-radius: 6px;
}

.tab.active {
  background: #fff;
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
}

.panel {
  display: grid;
  gap: 16px;
}

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

.metric-card {
  display: grid;
  grid-template-columns: minmax(86px, auto) 1fr;
  align-items: baseline;
  gap: 8px 12px;
  min-width: 0;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.metric-card:nth-child(2)::before {
  background: var(--gold);
}

.metric-card span,
.supplier-meta,
.supplier-card small,
.section-head span {
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  color: #0f2928;
  font-size: 25px;
  line-height: 1.05;
  justify-self: end;
  text-align: right;
  overflow-wrap: anywhere;
}

.metric-card small {
  grid-column: 1 / -1;
  justify-self: end;
  text-align: right;
}

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

.supplier-list {
  display: grid;
  gap: 10px;
}

.supplier-card {
  padding: 16px;
  display: grid;
  gap: 12px;
  border-color: rgba(220, 229, 229, 0.9);
}

.supplier-row {
  display: grid;
  grid-template-columns: 34px minmax(120px, 1.45fr) repeat(3, minmax(86px, 1fr));
  align-items: center;
  gap: 10px;
}

.supplier-row > div {
  min-width: 0;
}

.supplier-row strong {
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.rank-badge {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-align: center;
  font-size: 17px;
  font-weight: 800;
}

.supplier-card:nth-child(1) .rank-badge {
  background: var(--gold-soft);
  color: var(--gold);
}

.supplier-row > div:not(:first-child) {
  display: grid;
  gap: 4px;
  padding: 8px;
  background: #f7faf9;
  border-radius: 8px;
  justify-items: center;
  text-align: center;
}

.supplier-row > div:not(:first-child) strong {
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.up {
  color: var(--good);
}

.down {
  color: var(--bad);
}

.flat {
  color: var(--warn);
}

@media (max-width: 640px) {
  .app-shell {
    padding: max(18px, env(safe-area-inset-top)) 12px 24px;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 17px;
  }

  .topbar {
    align-items: stretch;
    gap: 12px;
  }

  .topbar h1 {
    font-size: 27px;
  }

  .period-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .quick-button,
  .month-compact {
    min-height: 36px;
    padding-left: 7px;
    padding-right: 7px;
    font-size: 13px;
  }

  .ghost-button {
    flex: 0 0 auto;
  }

  .metric-grid,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .search-field,
  .month-field {
    grid-column: auto;
  }

  .filter-bar,
  .detail-tools,
  .metric-card,
  .supplier-card {
    padding: 14px;
  }

  .login-panel {
    padding: 16px;
  }

  .metric-card strong {
    font-size: 22px;
  }

  .section-head {
    align-items: flex-start;
  }

  .supplier-row {
    grid-template-columns: 26px minmax(74px, 1.16fr) repeat(3, minmax(54px, 0.86fr));
    gap: 6px;
  }

  .supplier-row strong {
    font-size: 14px;
  }

  .supplier-row > div:not(:first-child) {
    padding: 6px 5px;
  }

  .supplier-row > div:not(:first-child) strong {
    font-size: 12px;
    text-align: center;
  }

  .supplier-card small {
    font-size: 10px;
  }

  .rank-badge {
    width: 24px;
    height: 24px;
    font-size: 15px;
  }
}

@media (max-width: 360px) {
  .topbar {
    flex-direction: column;
  }

  .ghost-button {
    width: 100%;
  }

  .tabs {
    gap: 4px;
  }
}
