:root {
  --cream: #f5f1e9;
  --cream-dark: #ece4d4;
  --espresso: #2b1d1a;
  --espresso-soft: #3d2c27;
  --gold: #c7a977;
  --gold-strong: #b39155;
  --terracotta: #c2694e;
  --sage: #8e9b86;
  --error: #8d2d2d;
  --success: #2f5d3a;
  --line: rgba(43, 29, 26, 0.14);
  --shadow: 0 18px 40px rgba(43, 29, 26, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--cream);
  color: var(--espresso);
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.brand {
  margin: 0;
  letter-spacing: 0.42em;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold-strong);
}

h1 {
  margin: 0.2rem 0 0;
  font-weight: 500;
  letter-spacing: 0.18em;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

h2 {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  letter-spacing: 0.16em;
  font-weight: 600;
}

.field-label {
  display: block;
  margin-bottom: 0.55rem;
  letter-spacing: 0.2em;
  font-size: 0.82rem;
  font-weight: 600;
}

.field {
  display: block;
}

input,
select,
button {
  font: inherit;
  color: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  min-height: 72px;
  padding: 0 1rem;
}

button {
  cursor: pointer;
}

.submit-btn,
.ghost-btn,
.month-arrow {
  border: 0;
  border-radius: 16px;
  min-height: 72px;
}

.submit-btn {
  width: 100%;
  background: var(--espresso);
  color: var(--cream);
  letter-spacing: 0.22em;
  font-weight: 600;
  text-align: center;
}

.submit-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.ghost-btn {
  background: transparent;
  color: var(--espresso);
  border: 1px solid var(--espresso);
  letter-spacing: 0.16em;
  font-weight: 600;
  padding: 0 1.2rem;
}

.status {
  min-height: 3.4rem;
  margin: 0;
  text-align: center;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.status.ok {
  color: var(--success);
}

.status.bad {
  color: var(--error);
}

.status .detail {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.05rem;
  letter-spacing: 0;
  font-weight: 500;
}

.page-entry {
  height: 100dvh;
  overflow: hidden;
}

.entry-shell {
  height: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 28px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.entry-header {
  text-align: center;
}

.entry-form {
  display: grid;
  gap: 18px;
  flex: 1;
  align-content: center;
}

.amount-wrap {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  min-height: 92px;
  padding: 0 8px 0 18px;
}

.amount-wrap .currency {
  font-size: 2rem;
  color: var(--gold-strong);
  margin-right: 8px;
}

#amount {
  border: 0;
  min-height: 88px;
  font-size: 2.4rem;
  padding: 0;
  background: transparent;
}

#staff {
  min-height: 84px;
  font-size: 1.45rem;
}

.page-admin {
  min-height: 100dvh;
}

.admin-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.admin-tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  min-height: 52px;
  padding: 0 18px;
  letter-spacing: 0.14em;
  font-weight: 600;
}

.admin-tab.active {
  background: var(--espresso);
  color: var(--cream);
  border-color: var(--espresso);
}

.admin-panel {
  display: block;
}

.status-badge {
  display: inline-block;
  margin: 0 0 12px;
  padding: 8px 14px;
  border-radius: 999px;
  letter-spacing: 0.16em;
  font-weight: 700;
  font-size: 0.85rem;
}

.status-open {
  background: var(--cream-dark);
}

.status-draft {
  background: #efe2c4;
}

.status-finalized {
  background: #d7e4d4;
}

.warning-banner {
  background: #f4e1d8;
  color: var(--error);
  border: 1px solid #e2b8a8;
  border-radius: 16px;
  padding: 14px 16px;
  font-weight: 700;
  margin: 0 0 18px;
}

.dist-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 18px;
}

.metric-value {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.metric-note {
  margin: 6px 0 0;
  color: #6b5b52;
  font-size: 0.85rem;
}

.balanced-yes {
  background: #d7e4d4;
}

.balanced-no {
  background: #f4e1d8;
}

.dist-wrap {
  margin-bottom: 18px;
}

.dist-table th,
.dist-table td,
.emp-table th,
.emp-table td {
  font-size: 0.88rem;
  padding: 10px 12px;
  white-space: nowrap;
}

.dist-table select,
.dist-table input[type="text"],
.emp-table select,
.emp-table input[type="date"] {
  min-height: 44px;
  border-radius: 10px;
  padding: 0 8px;
}

.dist-table select.att-select {
  min-width: 6.75rem;
  width: 6.75rem;
  padding: 0 6px;
  font-size: 0.85rem;
}

.dist-table input.note-input {
  min-width: 8.5rem;
  width: 8.5rem;
  min-height: 44px;
  font-size: 0.85rem;
}

.dist-table input.note-required {
  border-color: var(--error);
  background: #fbeeee;
}

.compact-btn {
  min-height: 44px;
  padding: 0 12px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.reversed-row {
  background: #f4e1d8;
}

.corrected-row {
  background: #f4ead4;
}

.ineligible-row {
  opacity: 0.72;
}

.dist-actions {
  align-items: center;
}

.dist-finalize {
  width: auto;
  min-width: 220px;
  padding: 0 24px;
}

.add-employee {
  margin-top: 28px;
}

.add-employee-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

.add-employee-form .ghost-btn {
  min-height: 72px;
}

.add-employee-form input[readonly] {
  background: var(--cream-dark);
}

.history-list {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.history-item {
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 56px;
  padding: 12px 16px;
  letter-spacing: 0.02em;
  font-weight: 600;
}

.history-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.confirm-dialog {
  border: 0;
  border-radius: 20px;
  padding: 28px;
  max-width: 520px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow);
}

.confirm-dialog::backdrop {
  background: rgba(43, 29, 26, 0.45);
}

.confirm-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  font-weight: 600;
}

.confirm-check input {
  width: auto;
  min-height: 0;
}

.dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.dialog-actions .submit-btn,
.dialog-actions .ghost-btn {
  width: auto;
  min-width: 140px;
  padding: 0 18px;
}

.login-card {
  max-width: 460px;
  margin: 12vh auto 0;
  background: #fff;
  padding: 36px 28px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card form {
  margin-top: 28px;
  display: grid;
  gap: 18px;
  text-align: left;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 28px;
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
}

.month-arrow {
  width: 64px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 1.6rem;
}

.month-current {
  position: relative;
  min-width: 260px;
  text-align: center;
  letter-spacing: 0.22em;
  font-size: 1.15rem;
  font-weight: 600;
  padding: 18px 12px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
}

.month-current input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  min-height: 0;
}

.pool-card {
  background: var(--espresso);
  color: var(--cream);
  padding: 28px;
  border-radius: 24px;
  margin-bottom: 28px;
}

.pool-card .field-label {
  color: var(--gold);
}

.pool-total {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 4rem);
  letter-spacing: 0.04em;
}

.pool-note,
.section-note {
  color: var(--espresso-soft);
  font-size: 0.92rem;
  line-height: 1.45;
}

.pool-note {
  color: rgba(245, 241, 233, 0.78);
  max-width: 42rem;
}

.staff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0 28px;
}

.staff-card {
  background: #fff;
  border-radius: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
}

.staff-card .name {
  font-weight: 700;
  margin-bottom: 6px;
}

.staff-card .money {
  font-size: 1.25rem;
}

.staff-card .pct {
  color: #6b5b52;
  font-size: 0.92rem;
}

.export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}

.table-wrap {
  overflow-x: auto;
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

th {
  letter-spacing: 0.12em;
  font-size: 0.78rem;
}

td:last-child,
th:last-child {
  text-align: right;
}

.empty-row td {
  text-align: center;
  color: #6b5b52;
}

@media (orientation: landscape) and (min-width: 900px) {
  .page-entry .entry-form {
    grid-template-columns: 1fr 1fr;
  }

  .page-entry .submit-btn,
  .page-entry .status {
    grid-column: 1 / -1;
  }

  #amount {
    font-size: 2.1rem;
  }
}

@media (max-width: 700px) {
  .admin-header,
  .export-row {
    flex-direction: column;
    align-items: stretch;
  }

  .month-current {
    min-width: 0;
    flex: 1;
  }
}
