:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #5f6f82;
  --line: #dce3ec;
  --accent: #b4233a;
  --accent-dark: #8f1b2e;
  --soft: #fff1f3;
  --focus: #2663eb;
  --success: #17623a;
  --danger: #9f1d1d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

.page-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.intro {
  max-width: 820px;
  margin-bottom: 24px;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: 2.35rem;
  line-height: 1.1;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.25rem;
}

.intro p,
.hint,
.empty-state,
.summary-card span {
  color: var(--muted);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgb(15 23 42 / 0.06);
  padding: 24px;
}

.controls-panel {
  margin-bottom: 16px;
}

.control-grid,
.employee-form {
  display: grid;
  grid-template-columns: minmax(280px, 1.25fr) minmax(130px, 0.35fr) minmax(190px, 0.5fr) auto;
  gap: 16px;
  align-items: end;
}

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

.compact-field {
  margin: 0;
}

label {
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--text);
  background: white;
}

textarea {
  min-width: 180px;
  min-height: 44px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus), transparent 70%);
  outline-offset: 2px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 10px 18px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

button.secondary {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}

button.secondary:hover {
  background: #f8fafc;
}

.employee-details {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.autosave-status {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.autosave-status.saving {
  color: var(--accent);
}

.autosave-status.error {
  color: var(--danger);
}

.limit-box {
  display: grid;
  gap: 3px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 11px;
  background: #f8fafc;
}

.limit-box span,
.limit-box small {
  color: var(--muted);
  font-size: 0.82rem;
}

.limit-box strong {
  font-size: 1rem;
  line-height: 1.15;
}

.employee-details summary {
  width: fit-content;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.employee-form {
  grid-template-columns: minmax(160px, 0.5fr) minmax(220px, 1fr) auto;
  margin-top: 16px;
}

.message {
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #f8fafc;
  color: var(--text);
}

.message.error {
  border-color: #f3a9a9;
  background: #fff5f5;
  color: var(--danger);
}

.message.success {
  border-color: #a7d7b8;
  background: #f0fff6;
  color: var(--success);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.summary-card {
  display: grid;
  gap: 6px;
  padding: 18px;
}

.summary-card strong {
  font-size: 1.3rem;
  line-height: 1.2;
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.table-heading .hint {
  margin-bottom: 0;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 24px;
  text-align: center;
}

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

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  left: 0;
  position: sticky;
  z-index: 2;
  background: white;
  text-align: left;
}

th:first-child {
  z-index: 3;
  background: #f8fafc;
}

td {
  font-variant-numeric: tabular-nums;
}

tbody tr:hover td,
tbody tr:hover td:first-child {
  background: #fbfdff;
}

.month-name {
  display: grid;
  gap: 3px;
  min-width: 96px;
}

.month-name strong {
  font-size: 0.96rem;
}

.month-name span {
  color: var(--muted);
  font-size: 0.82rem;
}

.number-input {
  width: 92px;
  min-height: 38px;
  padding: 7px 8px;
  text-align: right;
}

.money-input {
  width: 104px;
}

.note-input {
  width: 220px;
}

.calculated {
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

.carry {
  color: var(--accent);
}

.muted-value {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.invalid-field {
  border-color: #d33b3b;
  background: #fffafa;
}

.confirm-dialog {
  width: min(460px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.confirm-dialog::backdrop {
  background: rgb(15 23 42 / 0.36);
}

.confirm-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: white;
  box-shadow: 0 20px 60px rgb(15 23 42 / 0.22);
}

.confirm-panel h2 {
  margin-bottom: 8px;
}

.confirm-panel p {
  margin-bottom: 16px;
  color: var(--muted);
  line-height: 1.45;
}

.rename-values {
  display: grid;
  gap: 10px;
  margin: 0 0 20px;
}

.rename-values div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #f8fafc;
}

.rename-values dt {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.rename-values dd {
  margin: 4px 0 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.dialog-actions {
  justify-content: flex-end;
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100% - 24px, 720px);
    padding-top: 24px;
  }

  h1 {
    font-size: 1.9rem;
  }

  .control-grid,
  .employee-form,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .compact-actions {
    justify-content: flex-start;
  }

  .panel {
    padding: 18px;
  }

  .table-panel {
    padding: 0;
  }

  .table-heading {
    padding: 18px;
  }
}
