:root {
  --ink: #17202a;
  --muted: #667085;
  --line: #d6dce6;
  --soft: #f5f7fb;
  --panel: #ffffff;
  --primary: #126356;
  --primary-dark: #0c4d43;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button {
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: var(--primary-dark); }
button.secondary { background: #e8edf3; color: var(--ink); }
button:disabled {
  cursor: not-allowed;
  opacity: .45;
}
input, select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  min-width: 0;
}
label { display: grid; gap: 5px; color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(120deg, #eef5f2, #f7f7fb 60%, #edf4f9);
}
.login-panel {
  width: min(420px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  gap: 16px;
  box-shadow: 0 16px 48px rgba(33, 50, 70, .12);
}
.login-panel h1 { margin: 0; font-size: 24px; }
#loginError { color: #9b1c1c; min-height: 20px; margin: 0; }

.page { min-height: 100vh; padding: 20px; display: grid; gap: 14px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}
.topbar h1 { margin: 0; font-size: 24px; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.account { display: flex; align-items: center; gap: 10px; }
.toolbar, .panel, .sheet-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.toolbar {
  display: flex;
  gap: 10px;
  align-items: end;
  padding: 12px;
  flex-wrap: wrap;
}
.panel { padding: 12px; }
.panel summary { cursor: pointer; font-weight: 650; }
.employee-form {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.summary-board {
  width: fit-content;
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.compact-summary .sheet-head {
  display: grid;
  justify-content: start;
  gap: 3px;
  padding: 8px 12px;
}
.compact-summary .sheet-head span {
  color: var(--muted);
  font-size: 12px;
}
.summary-table-wrap {
  overflow: auto;
}
.summary-table {
  min-width: 560px;
  width: max-content;
  table-layout: fixed;
}
.summary-table th,
.summary-table td {
  width: 118px;
  min-width: 118px;
  padding: 6px 10px;
  font-size: 13px;
}
.summary-table th:first-child,
.summary-table td:first-child {
  min-width: 100px;
  font-weight: 650;
}
.summary-table th {
  position: relative;
  background: #f6f8fb;
}
.summary-table th:last-child,
.summary-table td:last-child {
  padding-right: 22px;
}
.summary-table .money {
  text-align: left;
}
.summary-table .summary-total td {
  background: #f0fdf4;
  font-weight: 700;
}
.table-pager {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}
.pager-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pager-actions button {
  padding: 5px 9px;
}
.pager-actions label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.pager-actions select {
  padding: 4px 7px;
  min-width: 76px;
}
#sheetStatus { color: var(--muted); }
.sheet-wrap { overflow: auto; max-height: calc(100vh - 250px); }
table { width: max-content; border-collapse: collapse; min-width: 100%; background: #fff; table-layout: fixed; }
th, td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 7px; text-align: left; width: 120px; min-width: 120px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; background: #eef3f7; font-size: 13px; white-space: nowrap; user-select: none; }
.sort-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
  padding: 0 10px 0 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
}
.sort-btn:hover {
  background: transparent;
  color: var(--primary);
}
.sort-btn span {
  color: var(--muted);
  font-size: 12px;
}
.compact th,
.compact td {
  width: 104px;
  min-width: 88px;
  padding: 6px;
  font-size: 13px;
}
.compact th:first-child,
.compact td:first-child {
  width: 76px;
  min-width: 70px;
}
.compact th:nth-child(2),
.compact td:nth-child(2) {
  width: 92px;
  min-width: 82px;
}
.compact td input,
.compact td select {
  padding: 5px;
}
tfoot td { position: sticky; bottom: 0; z-index: 1; background: #fff7ed; font-weight: 700; }
th .col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
}
th .col-resizer:hover { background: rgba(18, 99, 86, .2); }
td { background: #fff; }
td.result { background: #f8fafc; font-weight: 650; }
td.name-cell { min-width: 110px; }
td input, td select {
  width: 100%;
  border: 0;
  border-radius: 4px;
  padding: 6px;
  background: transparent;
}
td input:focus, td select:focus { outline: 2px solid rgba(18, 99, 86, .25); background: #fff; }
td input.zero-value { color: #a6afbd; }
td input.has-value {
  color: #9b1c1c;
  background: #fff1f2;
  font-weight: 700;
}
.money { text-align: right; }
.strong { font-weight: 700; }
.amount-zero {
  color: #b4bdca;
  font-weight: 400;
}
.amount-value {
  color: #0f172a;
  font-weight: 700;
  background: #f0fdf4;
}
.amount-value.strong {
  color: #064e3b;
  background: #dcfce7;
}
.mini-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.mini-list span { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #f8fafc; }
.mask-sensitive .sensitive {
  color: transparent !important;
  text-shadow: 0 0 8px rgba(23, 32, 42, .35);
}
.mask-sensitive input.sensitive {
  -webkit-text-security: disc;
  color: var(--ink) !important;
  text-shadow: none;
}
@media (max-width: 760px) {
  .page { padding: 12px; }
  .topbar { display: grid; }
  .sheet-wrap { max-height: none; }
}
