:root {
  --lapis: #1f4e9c;
  --turq: #1aa6a0;
  --gold: #c9971c;
  --red: #c0392b;
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f4f7);
  --text: var(--tg-theme-text-color, #1b1f24);
  --hint: var(--tg-theme-hint-color, #7a828c);
  --line: color-mix(in srgb, var(--hint) 25%, transparent);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg2); color: var(--text);
  font: 15px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: 64px; }
.hidden { display: none !important; }
.muted { color: var(--hint); }
.center { text-align: center; }
.small { font-size: 12px; }

header { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 10px 12px; background: var(--lapis); color: #fff; }
header select { background: transparent; color: #fff; border: 0; font-weight: 600; font-size: 16px; max-width: 65vw; }
header select option { color: #000; }
#org { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#role { font-size: 12px; background: var(--gold); color: #fff; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }

main { padding: 10px; }
nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg);
  border-top: 1px solid var(--line); z-index: 5; }
nav button { flex: 1; border: 0; background: none; padding: 8px 2px 10px; color: var(--hint); font-size: 11px; }
nav button b { display: block; font-size: 19px; line-height: 1.2; }
nav button.on { color: var(--lapis); }

.card { background: var(--bg); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.card h3 { margin: 0 0 8px; font-size: 15px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.tot { background: var(--bg); border-radius: 12px; padding: 10px 12px; border-top: 3px solid var(--turq); }
.tot .cur { font-size: 12px; color: var(--hint); }
.tot .row { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; }
.tot .bal { font-size: 18px; font-weight: 700; color: var(--lapis); margin-top: 4px; }
.in { color: var(--turq); }
.out { color: var(--red); }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.filters .wide { grid-column: 1 / -1; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--text); font: inherit; }
textarea { min-height: 60px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--hint); margin: 8px 0 3px; }

.btn { display: inline-block; border: 0; border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600;
  background: var(--lapis); color: #fff; }
.btn.alt { background: var(--bg2); color: var(--text); }
.btn.red { background: var(--red); }
.btn.gold { background: var(--gold); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.block { display: block; width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .5; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  color: var(--text); font: inherit; font-weight: 600; }
.seg button.on.kirim { background: var(--turq); color: #fff; border-color: var(--turq); }
.seg button.on.chiqim { background: var(--red); color: #fff; border-color: var(--red); }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 6px; }

.list .item { display: flex; justify-content: space-between; gap: 8px; background: var(--bg); padding: 10px 12px;
  border-bottom: 1px solid var(--line); }
.list .item:first-child { border-radius: 12px 12px 0 0; }
.list .item:last-child { border-radius: 0 0 12px 12px; border-bottom: 0; }
.list .item:only-child { border-radius: 12px; }
.item .l { min-width: 0; }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 12px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; }
.item .r { text-align: right; white-space: nowrap; font-weight: 700; }
.daysep { font-size: 12px; color: var(--hint); margin: 12px 4px 4px; font-weight: 600; }

.tablewrap { overflow-x: auto; background: var(--bg); border-radius: 12px; }
table.entry { border-collapse: collapse; min-width: 980px; }
table.entry th { font-size: 11px; color: var(--hint); text-align: left; padding: 6px 4px; font-weight: 600; }
table.entry td { padding: 3px 2px; border-top: 1px solid var(--line); }
table.entry input, table.entry select { padding: 6px; border-radius: 6px; font-size: 13px; }
table.entry td.n { color: var(--hint); font-size: 12px; text-align: center; width: 24px; }
table.entry tr.err td { background: color-mix(in srgb, var(--red) 12%, transparent); }

.hist .item .s b { color: var(--text); font-weight: 600; }
.chg { font-size: 12px; margin-top: 3px; }
.chg del { color: var(--red); }
.chg ins { color: var(--turq); text-decoration: none; }

#sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; }
#sheet-body { background: var(--bg2); width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0;
  padding: 14px 12px 24px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 8px; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--hint); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

#toast { position: fixed; left: 12px; right: 12px; bottom: 76px; background: #222; color: #fff; padding: 10px 12px;
  border-radius: 10px; z-index: 30; text-align: center; }
#toast.err { background: var(--red); }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 8px; background: var(--bg2);
  color: var(--hint); margin-left: 4px; }
.row-actions { display: flex; gap: 6px; align-items: center; }
.linkbox { word-break: break-all; font-size: 13px; background: var(--bg2); padding: 8px; border-radius: 8px; margin: 6px 0; }
