:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #dbe3ee;
  --brand: #0f3d63;
  --brand-dark: #0b2e4a;
  --green-bg: #e8f7ed;
  --green-text: #17623a;
  --red-bg: #fdecec;
  --red-text: #9f2d2d;
  --shadow: 0 10px 24px rgba(15, 61, 99, 0.08);
}

* { box-sizing: border-box; }

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

.site-header {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  padding: 16px 22px;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 6px;
}

.brand-kicker {
  font-size: 12px;
  opacity: 0.9;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-title {
  margin: 4px 0 0;
  font-size: 24px;
}

.header-link {
  color: #fff;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 600;
  background: transparent;
}

.page-shell {
  max-width: 1100px;
  margin: 20px auto;
  padding: 0 16px 28px;
}

.page-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.full-width { grid-column: 1 / -1; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.action-card {
  background: #fffdf4;
  border: 1px solid #f0d37a;
  padding: 14px 16px;
}

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.action-title {
  font-size: 16px;
  font-weight: 700;
}

.action-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.action-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toggle-group {
  display: inline-flex;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.toggle-button {
  padding: 10px 14px;
  text-decoration: none;
  color: #0f3d63;
  background: #fff;
  font-weight: 700;
  font-size: 14px;
  border-right: 1px solid #cbd5e1;
}

.toggle-button:last-child {
  border-right: 0;
}

.toggle-button.active {
  background: #0f3d63;
  color: #fff;
}

.secondary-button {
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: #0f3d63;
  background: #fff;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.section-note {
  margin-top: 0;
  margin-bottom: 14px;
}

h2 {
  margin: 0;
  font-size: 22px;
}

.muted { color: var(--muted); }

.label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 5px;
}

.value {
  font-size: 17px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

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

.search-form { margin-top: 16px; }

.search-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

input[type="text"] {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 17px;
  background: #fff;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: var(--brand);
}

button:hover,
.header-link:hover,
.secondary-button:hover,
.toggle-button:hover {
  opacity: 0.92;
}

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

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

.stat-value {
  font-size: 28px;
  font-weight: 800;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.stat-remaining {
  background: #eef7ff;
  border-color: #cfe4fb;
}

.pill {
  display: inline-block;
  background: #eef3f8;
  color: var(--brand);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
}

.pill-red {
  background: #fdecec;
  color: #9f2d2d;
}

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

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

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

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

.status {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-active {
  background: var(--green-bg);
  color: var(--green-text);
}

.status-inactive {
  background: var(--red-bg);
  color: var(--red-text);
}

.alert {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
}

.alert-error {
  background: #fdecec;
  color: #8e1f1f;
  border: 1px solid #f3c9c9;
}

.alert-success {
  background: #e8f7ed;
  color: #17623a;
  border: 1px solid #c8ead6;
}

.money-positive {
  color: #17623a;
  font-weight: 700;
}

.money-negative {
  color: #b91c1c;
  font-weight: 700;
}

@media (max-width: 900px) {
  .page-grid,
  .info-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .header-inner,
  .search-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-title { font-size: 22px; }
  .brand-logo { width: 52px; height: 52px; }

  th, td {
    padding: 9px 7px;
    font-size: 14px;
  }

  .stat-value { font-size: 24px; }

  .action-bar,
  .action-controls {
    align-items: stretch;
  }

  .toggle-group {
    width: 100%;
  }

  .toggle-button {
    flex: 1;
    text-align: center;
  }

  .secondary-button {
    width: 100%;
  }
}

@media print {
  .site-header,
  .no-print {
    display: none !important;
  }

  body { background: #fff; }
  .page-shell {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
  .page-grid { display: block; }
  .card {
    box-shadow: none;
    border: 1px solid #ccc;
    border-radius: 0;
    margin-bottom: 18px;
    page-break-inside: avoid;
  }
}
