/* Simple desktop-like UI */
:root {
  --bg: #f6f6f6;
  --panel: #ffffff;
  --border: #d9d9d9;
  --divider: #cfcfcf;
  --text: #111;
  --muted: #666;
  --btn: #f2f2f2;
  --btn-border: #cfcfcf;
  --primary: #e74c3c;
  --danger: #333333;
  --auto: #e9e9e9;
  --auto2: #efefef;
}

* { box-sizing: border-box; }
body { margin: 0; padding: 18px; background: var(--bg); font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; color: var(--text); }

.window { width: min(1400px, 98vw); margin: 0 auto; }
.titlebar { display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 12px; }

.top-actions { display:flex; align-items:center; gap:10px; justify-content:flex-end; }
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  font-size: 16px;
  line-height: 1;
}
.icon-btn.text-btn {
  width: auto;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
}
.icon-btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.25); }
.logout-btn { background: #22c55e; color: #ffffff; border-color: #16a34a; }
.logout-btn:hover { filter: brightness(0.97); }
.pass-btn { background: #111827; color: #ffffff; border-color: #111827; }
.pass-btn:hover { filter: brightness(0.97); }
.log-btn { background: #2563eb; color: #ffffff; border-color: #1d4ed8; }
.log-btn:hover { filter: brightness(0.97); }
.reset-btn { background: #9ca3af; color: #ffffff; border-color: #6b7280; }
.reset-btn:hover { filter: brightness(0.97); }
.brand { font-size: 22px; font-weight: 700; }
.sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.ver { font-size: 13px; color: var(--muted); margin-top: 6px; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.top-controls { justify-content: space-between; }
.field { display: flex; flex-direction: column; gap: 4px; }
label { font-size: 12px; color: var(--muted); }
input[type="date"], input.num, input.text { height: 30px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; min-width: 140px; background: #fff; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
.btns { display: flex; gap: 8px; align-items: center; }
.hidden { display: none; }
.btn { display: inline-block; padding: 7px 12px; border: 1px solid var(--btn-border); border-radius: 8px; background: var(--btn); text-decoration: none; color: var(--text); font-size: 13px; cursor: pointer; }
.btn.primary { background: #0047ff; border-color: #0037c7; color: #fff; font-weight: 800; }
.btn.danger { background: #dbeafe; border-color: #93c5fd; }
.btn:active { transform: translateY(1px); }
.btns.right { margin-left: auto; }

.grid-wrap {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}
.entry-grid {
  width: 100%;
  min-width: 1260px;
  border-collapse: collapse;
  table-layout: fixed;
}
.entry-grid th,
.entry-grid td {
  border: 1px solid var(--divider);
}
.entry-grid th {
  background: #f0f0f0;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.entry-grid td {
  padding: 2px;
}
.entry-grid td.receipt-cell {
  text-align: center;
  vertical-align: middle;
}
.entry-grid input {
  width: 100%;
  height: 30px;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 0;
  outline: none;
  min-width: 0;
  padding: 0 6px;
  text-align: right;
}
.entry-grid input.text-input { text-align: left; }
.entry-grid input:focus {
  border-color: #3b82f6;
  box-shadow: inset 0 0 0 2px #3b82f6;
}
.receipt-btn {
  padding: 5px 8px;
  font-size: 12px;
  white-space: nowrap;
  background: #e0ecff;
  border-color: #93c5fd;
  margin: 0 auto;
  display: inline-block;
}

.entry-grid input.readonly { background: var(--auto); }
.readonly { color: #333; }

.summary { display: none; }
.summary .total { font-weight: 700; }
.summary span { font-variant-numeric: tabular-nums; }

.searchbar { margin-top: 8px; display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.hint { margin-top: 8px; font-size: 12px; color: var(--muted); }
.quick-sort { margin-top: 6px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.quick-sort a { color: inherit; text-decoration: none; padding: 2px 6px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.quick-sort a:hover { background: #f3f4f6; }
.notice { margin-top: 8px; font-size: 13px; }
.notice.success { color: #0f766e; }
.notice.error { color: #b91c1c; }
.formula-banner {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
}
.formula-title {
  font-size: 13px;
  font-weight: 800;
  color: #1d4ed8;
}
.formula-text {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 700;
  color: #1e3a8a;
}
.entry-grid-revamp {
  min-width: 980px;
}
.entry-grid-revamp th {
  padding: 8px 6px;
  vertical-align: top;
}
.entry-grid-revamp th span {
  display: block;
}
.circle-num,
.calc-label {
  font-size: 14px;
  font-weight: 800;
  color: #111827;
  margin-bottom: 4px;
}
.difference-field {
  font-weight: 800;
}
.difference-field.negative,
input.readonly.negative {
  color: #b91c1c;
  background: #fee2e2;
  border-color: #fca5a5;
}

.table-wrap {
  margin-top: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto; /* 가로/세로 스크롤 */
  max-width: 100%;
}
.results {
  width: 100%;
  min-width: 1380px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}
.results thead th { background: #f0f0f0; border-bottom: 1px solid var(--border); padding: 6px 6px; text-align: right; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.results thead th:nth-child(1),
.results thead th:nth-child(2) { text-align: left; }
.results td { border-top: 1px solid #eee; padding: 5px 6px; white-space: nowrap; }
.results td.negative { color: #b00020; font-weight: 700; }
.numcell { text-align: right; font-variant-numeric: tabular-nums; }
.results .empty { text-align: center; color: var(--muted); padding: 18px; }
.sum-row td { font-weight: 700; background: #f4f4f4; border-top: 1px solid var(--border); }
.sum-label { text-align: left; }
.results th:nth-child(1), .results td:nth-child(1) { width: 52px; }
.results th:nth-child(2), .results td:nth-child(2) { width: 10ch; }
.results th:nth-child(3), .results td:nth-child(3) { width: 100px; }
.results th:nth-child(4), .results td:nth-child(4),
.results th:nth-child(5), .results td:nth-child(5),
.results th:nth-child(6), .results td:nth-child(6),
.results th:nth-child(7), .results td:nth-child(7),
.results th:nth-child(8), .results td:nth-child(8) { width: 118px; }
.results th:nth-child(9), .results td:nth-child(9) { width: 92px; }
.results th:nth-child(10), .results td:nth-child(10) { width: 102px; }
.results th:nth-child(11), .results td:nth-child(11) { width: 86px; }
.results td:nth-child(10) { text-align: right; }
.results td:nth-child(11) { text-align: right; }

.table-wrap { max-height: 356px; overflow: auto; } /* ~8 rows visible, then scroll */

.data-row { cursor: pointer; }
.data-row.selected { outline: 2px solid #9aa7ff; outline-offset: -2px; }

input.negative { color: #b00020; }

.sortlink { color: inherit; text-decoration: none; }
.sortlink:hover { text-decoration: underline; }

/* 페이징 (하단 중앙) */
.pager {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px 0;
}
.pager a, .pager span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #222;
  text-decoration: none;
  font-size: 13px;
}
.pager a:hover { background: #f3f4f6; }
.pager .current { background: #111827; color: #fff; border-color: #111827; }
.pager .disabled { opacity: 0.4; }


/* SUM row alignment: match data-row cell alignment (right) */
.results td.num { text-align: right; }
.results tfoot .sum-row td.num { font-weight: 700; }

.page-ellipsis{display:inline-block;padding:6px 10px;color:#666;}


/* ===== Modal (DB Reset) ===== */
.modal.hidden { display: none; }
.modal { position: fixed; inset: 0; z-index: 9999; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.35); }
.modal-card {
  position: relative;
  width: min(420px, calc(100vw - 40px));
  margin: 12vh auto 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.2);
  padding: 18px;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.modal-text { margin-bottom: 10px; color: #333; }
.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cfcfcf;
  border-radius: 10px;
  outline: none;
}
.modal-input:focus { border-color: #4f8cff; box-shadow: 0 0 0 3px rgba(79,140,255,0.25); }
.modal-hint { margin-top: 8px; color: #666; font-size: 12px; }
.modal-actions { margin-top: 14px; display: flex; justify-content: flex-end; gap: 8px; }
.btn-danger { background: #e74c3c; border-color: #e74c3c; color: #fff; }
.btn-danger:hover { filter: brightness(0.95); }
