/* ---------- App shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  background: #0f2142;
  color: #fff;
  padding: 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-head {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 8px;
}
.logo-badge {
  width: 40px; height: 40px; flex-shrink: 0;
  background: linear-gradient(135deg,#2563eb,#1e40af);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; letter-spacing: .5px;
  box-shadow: 0 2px 8px rgba(37,99,235,0.4);
}
.sidebar-head strong { display: block; font-size: 14px; font-weight: 700; }
.sidebar-head small { color: rgba(255,255,255,0.55); font-size: 11px; }
.sidebar-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: rgba(255,255,255,0.35);
  padding: 10px 18px 4px;
}
.sidebar-divider {
  height: 1px; background: rgba(255,255,255,0.07);
  margin: 8px 14px;
}

.search-box input {
  width: 100%; padding: 11px 13px; border: none; border-radius: 10px;
  font-size: 14px; background: rgba(255,255,255,0.95);
}
.search-box input:focus { outline: 2px solid rgba(255,255,255,0.5); }

.result-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.result-item {
  width: 100%; text-align: left; border: none; cursor: pointer;
  background: rgba(255,255,255,0.08); color: #fff;
  border-radius: 10px; padding: 11px 13px;
}
.result-item:hover { background: rgba(255,255,255,0.16); }
.result-item.selected { background: #fff; color: var(--brand); }
.result-item strong { display: block; font-size: 13.5px; }
.result-item span { display: block; font-size: 12px; opacity: .85; margin-top: 2px; }
.result-item small { display: block; font-size: 11.5px; opacity: .7; margin-top: 1px; }
.empty-state { padding: 16px; text-align: center; color: rgba(255,255,255,0.6); font-size: 13px; }

/* Workspace */
.workspace { overflow-y: auto; padding: 24px 28px 28px; background: #f4f6fb; }

/* ---------- Receipt sheet ---------- */
.receipt {
  background: #fff;
  max-width: 560px;
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(20,40,80,0.08);
}

.receipt-header {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px;
  border-bottom: 2px solid var(--ink);
}
.rh-logo {
  width: 50px; height: 50px; flex-shrink: 0;
  border: 2px solid var(--brand); color: var(--brand);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 11px;
}
.rh-title { flex: 1; text-align: center; }
.rh-title h1 { margin: 0; font-size: 26px; letter-spacing: 2px; }
.rh-sub { font-size: 12px; font-weight: 700; text-decoration: underline; letter-spacing: .5px; }
.rh-spacer { width: 50px; }

.receipt-meta { padding: 14px 20px; border-bottom: 1px solid var(--line); }
.meta-row { display: flex; gap: 14px; margin-bottom: 10px; }
.meta-row.single .meta-cell { flex: 1; }
.meta-row:last-child { margin-bottom: 0; }
.meta-cell { flex: 1; display: flex; align-items: center; gap: 8px; }
.meta-cell label { font-size: 12.5px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.meta-cell input, .meta-cell select {
  flex: 1; min-width: 0; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 6px; font-size: 13px;
  background: #fff;
}
.meta-cell input[readonly] { background: #f5f7fa; color: var(--brand); font-weight: 600; }

/* Class table */
.bill-table { width: 100%; border-collapse: collapse; }
.bill-table th {
  background: var(--brand-light); font-size: 12px; text-transform: uppercase;
  letter-spacing: .03em; padding: 8px 12px; text-align: left; color: var(--brand);
  border-bottom: 1px solid var(--line);
}
.bill-table th:nth-child(2) { width: 130px; text-align: center; }
.bill-table th:nth-child(3) { width: 90px; text-align: center; }
.bill-table th:nth-child(4) { width: 90px; text-align: right; }
.bill-table td { padding: 4px 12px; border-bottom: 1px solid #eef1f5; font-size: 13px; }
.bill-table td:first-child { font-weight: 600; }
.bill-table input {
  width: 100%; padding: 5px 7px; border: 1px solid var(--line);
  border-radius: 5px; font-size: 13px; text-align: right;
}
.bill-table input[readonly] { background: #f5f7fa; border-color: transparent; }
.bill-table .qty-input { background: #fffdf4; border-color: #ecd9a6; }

.ta-right { text-align: right; }
.ta-center { text-align: center; }

/* Summary table */
.summary-table { width: 100%; border-collapse: collapse; border-top: 2px solid var(--ink); }
.summary-table td { padding: 7px 12px; font-size: 13px; border-bottom: 1px solid #eef1f5; }
.summary-table td:first-child { color: var(--muted); }
.summary-table tr.strong td { font-weight: 700; color: var(--ink); background: #fafbfd; }
.summary-table tr.due-row td { color: var(--red); background: var(--red-light); font-size: 14px; }
.summary-table small { color: var(--muted); font-weight: 400; font-size: 11px; }

.pct-wrap { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.pct-wrap input { width: 52px; padding: 4px 6px; border: 1px solid #ecd9a6; background: #fffdf4; border-radius: 5px; text-align: center; font-size: 13px; }
.inline-amount { width: 100px; padding: 4px 7px; border: 1px solid #ecd9a6; background: #fffdf4; border-radius: 5px; text-align: right; font-size: 13px; }

.receipt-footer {
  display: flex; justify-content: flex-end; align-items: baseline; gap: 14px;
  padding: 14px 20px; border-top: 2px solid var(--ink); background: #fafbfd;
}
.receipt-footer span { font-weight: 700; }
.receipt-footer strong { font-size: 20px; color: var(--red); }

/* Action bar */
.action-bar { max-width: 560px; margin: 18px auto 0; display: flex; gap: 12px; justify-content: flex-end; }

/* Buttons */
.btn {
  border: none; border-radius: 10px; padding: 11px 20px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
  letter-spacing: -0.01em;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: #17335f; box-shadow: var(--shadow-sm); }
.btn-ghost {
  background: transparent; color: rgba(255,255,255,0.78);
  border-radius: 8px; text-align: left;
  padding: 9px 14px; font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; transition: background .15s, color .15s;
  display: flex; align-items: center; gap: 9px;
  margin: 1px 8px; width: calc(100% - 16px);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: #fff; }
.btn-success { background: var(--green); color: #fff; box-shadow: var(--shadow-xs); }
.btn-success:hover { background: #0e6b4d; box-shadow: var(--shadow-sm); }
.btn-warning { background: var(--amber); color: #fff; box-shadow: var(--shadow-xs); }
.btn-warning:hover { background: #bf760a; }
.btn-light { background: #fff; color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow-xs); }
.btn-light:hover { background: #f8fafc; border-color: var(--line-strong); }
.btn:hover { opacity: .96; }

/* History */
.history { max-width: 920px; margin: 30px auto 0; background: #fff; border-radius: 12px; border: 1px solid var(--line); padding: 18px 20px; }
.history-head h2 { margin: 0 0 14px; font-size: 16px; }
.table-wrap { overflow-x: auto; }
.history-table { width: 100%; border-collapse: collapse; }
.history-table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.history-table td { padding: 10px; border-bottom: 1px solid #eef1f5; font-size: 13px; }
.history-table tbody tr:hover { background: #fafbfc; }
.link-btn { background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 5px 11px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--brand); transition: background .14s, box-shadow .14s, transform .1s; }
.link-btn:hover { background: #f4f6fb; box-shadow: var(--shadow-xs); }
.link-btn:active { transform: translateY(1px); }

/* ---------- Screens (one shows at a time; the side menu switches them) ---------- */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- History / Search ---------- */
.section-search {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 14px; margin-bottom: 16px; outline: none;
}
.section-search:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }

/* ---------- Ledger ---------- */
.ledger-wrap { background: #fff; border-radius: 12px; border: 1px solid var(--line); overflow: hidden; }
.ledger-table { width: 100%; border-collapse: collapse; }
.ledger-table th {
  background: var(--brand-light); color: var(--brand);
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line);
}
.ledger-table td { padding: 11px 14px; font-size: 13px; border-bottom: 1px solid #eef1f5; }
.ledger-table tbody tr:hover { background: #fafbfc; cursor: pointer; }
.due-positive { color: var(--red); font-weight: 700; }
.due-clear { color: var(--green); font-weight: 600; }
.ledger-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }

