:root {
  --bg: #f7f9f8;
  --surface: #ffffff;
  --surface-2: #eef5f2;
  --text: #1c2522;
  --muted: #66746f;
  --line: #dce5e1;
  --teal: #0f8f7c;
  --teal-dark: #087365;
  --green: #178a4f;
  --red: #c94343;
  --amber: #bc7a16;
  --shadow: 0 12px 30px rgba(29, 48, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

a {
  text-decoration: none;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(120deg, rgba(15, 143, 124, 0.08), transparent 38%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  gap: 16px;
}

.login-brand {
  color: var(--text);
  margin-bottom: 6px;
}

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

.sidebar {
  background: #14231f;
  color: #f4fbf8;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 750;
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: white;
  font-weight: 800;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #bcd0ca;
  text-align: left;
  padding: 11px 12px;
  cursor: pointer;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.side-note {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #bcd0ca;
  font-size: 13px;
  line-height: 1.55;
}

.main {
  min-width: 0;
  padding: 22px;
}

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

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
}

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

.toolbar.slim {
  gap: 8px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px 11px;
  min-height: 40px;
  color: var(--text);
}

textarea {
  resize: vertical;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  min-height: 40px;
  padding: 9px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
}

a.btn {
  text-decoration: none;
}

.btn.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.btn.primary:hover {
  background: var(--teal-dark);
}

.btn:hover {
  border-color: #b8c8c2;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

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

.kpi .label {
  color: var(--muted);
  font-size: 12px;
}

.kpi .value {
  margin-top: 7px;
  font-size: 24px;
  font-weight: 780;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  background: #fbfcfc;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  min-width: 58px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.status.paid {
  color: var(--green);
  background: #e8f6ee;
}

.status.unpaid {
  color: var(--red);
  background: #faeceb;
}

.status.partial {
  color: var(--amber);
  background: #fff3dc;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 30px 14px;
}

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

.list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
}

.amount {
  font-weight: 750;
}

.danger {
  color: var(--red);
}

.ok {
  color: var(--green);
}

.warning {
  color: var(--amber);
}

.forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-body {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wide {
  grid-column: 1 / -1;
}

.csv-box {
  min-height: 170px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #14231f;
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.hidden {
  display: none;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-direction: row;
    align-items: center;
    padding: 12px;
    gap: 12px;
  }

  .nav {
    display: flex;
    overflow: auto;
  }

  .side-note {
    display: none;
  }

  .kpis {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .grid,
  .forms {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 14px;
  }

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

  .toolbar,
  .toolbar .field,
  .toolbar input,
  .toolbar button {
    width: 100%;
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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