:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2a37;
  --muted: #5f6b7a;
  --line: #dbe2ea;
  --brand: #1864ab;
  --brand-dark: #0f4c81;
  --danger: #c92a2a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #edf2f7 0%, #f8fafc 100%);
  color: var(--text);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 1.7rem;
}

.subtitle {
  color: var(--muted);
  margin-top: 6px;
  margin-bottom: 0;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

select,
input,
textarea,
button {
  font: inherit;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 10px rgba(19, 33, 68, 0.04);
}

.year-setup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.summary {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 16px;
}

.metric h3 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.metric p {
  margin: 8px 0 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.autocomplete-host {
  position: relative;
}

.autocomplete-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  background: #fff;
  border: 1px solid #cdd8e5;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(15, 38, 68, 0.12);
  max-height: 220px;
  overflow-y: auto;
}

.autocomplete-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 0;
  color: #223246;
  font-weight: 500;
}

.autocomplete-item:hover,
.autocomplete-item.is-active {
  background: #e8f1fb;
}

.field-grow {
  flex: 1 1 340px;
  min-width: 240px;
}

label {
  color: #344155;
  font-size: 0.9rem;
  font-weight: 600;
}

input,
select,
textarea {
  border: 1px solid #cdd8e5;
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
}

textarea {
  min-height: 76px;
  resize: vertical;
}

button {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

a.btn-secondary {
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 600;
  display: inline-block;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-secondary {
  background: #e7eef6;
  color: #24405e;
}

.btn-danger {
  background: #f9e3e3;
  color: var(--danger);
}

.btn-link {
  background: transparent;
  color: var(--brand);
  padding: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #e6edf5;
  font-size: 0.92rem;
}

th {
  color: #4b5c6f;
}

small.note {
  color: var(--muted);
}

p.note {
  color: var(--muted);
  margin: 6px 0 0;
}

.inline {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

.options-row {
  align-items: center;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: #223246;
  font-weight: 600;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#errorBox {
  color: #b42318;
  background: #fee4e2;
  border: 1px solid #fecdca;
  padding: 10px 12px;
  border-radius: 8px;
  display: none;
}

#successBox {
  color: #065f46;
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  padding: 10px 12px;
  border-radius: 8px;
  display: none;
}

@media (max-width: 640px) {
  .container {
    padding: 14px;
  }

  h1 {
    font-size: 1.4rem;
  }
}
