:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --panel: #ffffff;
  --ink: #17202d;
  --muted: #6c7787;
  --line: #dbe2ea;
  --accent: #1677ff;
  --accent-dark: #0d4fb3;
  --green: #14b873;
  --shadow: 0 18px 46px rgba(22, 37, 62, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(22, 119, 255, 0.10), transparent 34%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 24px auto;
}

.topbar,
.controls,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
}

.eyebrow {
  display: block;
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  letter-spacing: 0;
}

.subline,
.summary-card p,
.rule-list p,
.upload-box small {
  color: var(--muted);
}

.subline {
  margin-top: 8px;
  font-size: 15px;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}

button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.primary-button {
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 10px 26px rgba(22, 119, 255, 0.26);
}

.ghost-button {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 18px;
  padding: 16px;
}

.upload-box,
.settings-card,
.summary-card,
.amount-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 28px;
  text-align: center;
  border-style: dashed;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.upload-box:hover,
.upload-box.dragging {
  border-color: var(--accent);
  background: #f3f8ff;
}

.upload-box input {
  display: none;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 66px;
  height: 80px;
  margin-bottom: 14px;
  border-radius: 7px;
  color: #c91d32;
  font-size: 18px;
  font-weight: 900;
  background: linear-gradient(160deg, #fff 0 74%, #dfe8f2 74%);
  border: 1px solid #d7e0ea;
  box-shadow: 0 12px 24px rgba(22, 37, 62, 0.10);
}

.upload-box strong {
  display: block;
  font-size: 19px;
}

.upload-box small {
  margin-top: 8px;
}

.settings-card,
.summary-card,
.amount-card {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 18px;
}

.settings-card label,
.amount-card label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 12px;
  align-items: center;
  color: #314057;
  font-weight: 700;
}

.settings-card input,
.amount-card input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.settings-card input:focus,
.amount-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.13);
}

.rule-list {
  display: grid;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.rule-list b {
  color: var(--accent-dark);
}

.summary-card h2 {
  font-size: 28px;
}

.uppercase-output {
  min-height: 52px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-dark);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.5;
  overflow-wrap: anywhere;
  background: #f7fbff;
}

.table-panel {
  margin-top: 18px;
  overflow: hidden;
}

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

.table-wrap {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

th:last-child,
td:last-child {
  border-right: 0;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 8px;
  color: #314057;
  font-size: 13px;
  text-align: left;
  background: #f5f8fb;
}

td {
  padding: 6px;
  background: #fff;
}

tbody tr:hover td {
  background: #f8fbff;
}

td input,
td select {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  outline: none;
}

td input:focus,
td select:focus {
  border-color: var(--accent);
  background: #fff;
}

.col-year,
.col-month,
.col-day {
  width: 68px;
}

.col-people,
.col-amount,
.col-reason {
  width: 90px;
}

.col-delete {
  width: 64px;
  text-align: center;
}

.delete-button {
  min-height: 32px;
  padding: 0 10px;
  color: #bd2134;
  background: #fff5f6;
  border-color: #ffd1d7;
}

.empty-row td {
  height: 120px;
  color: var(--muted);
  text-align: center;
  background: #fbfcfe;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  width: min(520px, calc(100vw - 28px));
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  background: #17202d;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 980px) {
  .topbar,
  .controls {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

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

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 20px, 1280px);
    margin: 10px auto;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
