:root {
  --bg: #f3f4f6;
  --fg: #1c1f24;
  --muted: #5f6773;
  --line: #d7dce3;
  --card: #ffffff;
  --accent: #1f5da8;
  --accent-strong: #174987;
  --ok: #0f766e;
  --warn-bg: #fff6e8;
  --warn-line: #f9c97b;
  --warn-fg: #8b4d00;
  --error-bg: #fff1f1;
  --error-line: #f4b7b7;
  --error-fg: #9b1f1f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--fg);
  background:
    radial-gradient(900px 300px at 0% -10%, #dbe5f2 0%, rgba(219, 229, 242, 0) 70%),
    radial-gradient(900px 300px at 100% -20%, #f1e6dc 0%, rgba(241, 230, 220, 0) 70%),
    var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.navwrap {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.nav a {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: #2a3441;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.nav a:hover {
  text-decoration: none;
  background: #eef2f7;
  border-color: #d4dce6;
  transform: translateY(-1px);
}

.nav a.active {
  color: #0f2a4b;
  background: linear-gradient(180deg, #e8f0fb 0%, #d8e6f8 100%);
  border-color: #b9cde9;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 28px;
}

.page-title {
  margin: 4px 0;
  font-size: clamp(28px, 3.2vw, 36px);
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
}

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(19, 26, 36, 0.05);
  overflow: hidden;
}

.cardh {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fafc 0%, #f2f5f9 100%);
  font-size: 14px;
  font-weight: 700;
  color: #243244;
}

.cardb {
  padding: 14px;
}

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

.section-group {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(19, 26, 36, 0.05);
  padding: 14px;
}

.section-group + .section-group {
  margin-top: 2px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  border-bottom: 1px dashed #d5dde9;
  padding-bottom: 10px;
}

.section-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.section-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.section-grid > .card {
  grid-column: span 6;
}

.field-action {
  flex: 0 0 auto;
}

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

.admin-list-scroll {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
  padding: 0 12px;
}

.admin-list-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 9px 0;
  border-bottom: 1px solid #e7edf6;
  font-size: 13px;
}

.admin-list-row:last-child {
  border-bottom: 0;
}

.admin-list-row .btn {
  margin-left: auto;
}

.admin-list-primary {
  font-weight: 600;
  color: #1f2937;
}

.admin-list-amount {
  font-size: 13px;
  font-weight: 700;
  color: #1f4f8a;
  white-space: nowrap;
}

.admin-list-note {
  flex: 1 1 220px;
  min-width: 160px;
  color: #4b5563;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-list-meta {
  color: #6b7280;
  font-size: 12px;
  white-space: nowrap;
}

.admin-list-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-list-actions .input {
  flex: 1 1 260px;
}

.btn-sm {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.btn-danger {
  border-color: #efb5b5;
  background: linear-gradient(180deg, #fff4f4 0%, #ffe9e9 100%);
  color: #7c1f1f;
}

.btn-danger:hover {
  background: linear-gradient(180deg, #ffeded 0%, #ffe2e2 100%);
}

.history-row {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px 10px;
}

.history-file {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

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

.kpi .value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -0.02em;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.field {
  min-width: 140px;
  flex: 1 1 180px;
}

.field-wide {
  min-width: 220px;
  flex: 2 1 260px;
}

.field-tight {
  min-width: 120px;
  flex: 0 1 140px;
}

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  min-height: 38px;
  color: #1f2937;
}

.input:focus {
  outline: none;
  border-color: #aac3e3;
  box-shadow: 0 0 0 3px rgba(31, 93, 168, 0.13);
}

.btn {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #b8cde8;
  background: linear-gradient(180deg, #f3f8ff 0%, #e7f1ff 100%);
  color: #12385f;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  background: linear-gradient(180deg, #eaf3ff 0%, #dcecff 100%);
}

.badge {
  background: #f3f5f8;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  white-space: nowrap;
}

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

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

table {
  border-collapse: collapse;
  width: 100%;
}

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

th {
  background: #f6f8fb;
  font-weight: 700;
  color: #334155;
  font-size: 13px;
}

tbody tr:hover {
  background: #fafcff;
}

footer {
  margin: 28px 0 20px;
  text-align: center;
  color: #7b8390;
  font-size: 12px;
}

.canvas {
  width: 100%;
  height: 300px;
  border: none;
  border-radius: 12px;
  background: #fff;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: linear-gradient(180deg, #1f5da8 0%, #184b87 100%);
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  z-index: 9999;
  max-width: 380px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.toast .btn {
  background: #fff;
  border: none;
  color: #12385f;
  margin-left: 8px;
}

.hidden {
  display: none !important;
}

.state-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f9fafb;
  color: #374151;
  font-size: 13px;
}

.state-box.warn {
  background: var(--warn-bg);
  border-color: var(--warn-line);
  color: var(--warn-fg);
}

.state-box.error {
  background: var(--error-bg);
  border-color: var(--error-line);
  color: var(--error-fg);
}

.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.quick-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 980px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .section-grid > .card {
    grid-column: span 6;
  }

  .admin-list-scroll {
    max-height: 260px;
  }
}

@media (max-width: 720px) {
  .container {
    padding: 16px 12px 20px;
  }

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

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

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

  .nav {
    gap: 8px;
    padding: 10px 12px;
  }

  .nav a {
    padding: 8px 12px;
    font-size: 13px;
  }

  .admin-list-row {
    align-items: flex-start;
  }

  .admin-list-row .btn {
    margin-left: 0;
  }
}
