/* KingSpirits */
:root {
  --ink: #1d2a24; --muted: #66736c; --line: #d5ddd8; --bg: #f4f6f5; --panel: #fff;
  --brand: #1b3a2b; --green: #2e7d32; --blue: #1565c0; --red: #c62828; --orange: #ef6c00; --slate: #455a64;
  --yellow: #fff9d6; --up-bg: #e3f4e4; --up: #1b5e20; --down-bg: #fde4e4; --down: #b71c1c;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; color: var(--ink); background: var(--bg); font-size: 14px; display: flex; flex-direction: column; }
body.busy { cursor: progress; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.blue { color: var(--blue); } .green { color: var(--green); } .big { font-size: 16px; }
.red-text { color: var(--red); } .orange-text { color: var(--orange); } .green-text { color: var(--green); }

/* top bar */
.topbar { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--brand); color: #fff; }
.topbar a { color: #cfe8d8; }
.topbar-logo { width: 40px; height: 40px; border-radius: 8px; background: #fff; }
.app-name { font-weight: 700; font-size: 18px; }
.version { font-weight: 400; font-size: 11px; color: #a9c5b4; }
.store-name { font-size: 13px; color: #d6e9dd; }
.topbar-info { margin-left: 12px; }
.topbar-info .muted { color: #a9c5b4; }
.eff-date { font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.toplink { text-decoration: none; }
.toplink:hover { text-decoration: underline; }
.user { font-weight: 600; }
.mode-switch { display: inline-flex; border: 1px solid #6f9a82; border-radius: 6px; overflow: hidden; }
.mode-switch button { border: 0; background: transparent; color: #d6e9dd; padding: 5px 12px; cursor: pointer; font: inherit; }
.mode-switch button.on { background: #fff; color: var(--brand); font-weight: 700; }

/* control panel */
.controls { display: flex; flex-wrap: wrap; gap: 12px; padding: 10px 16px 4px; }
.group { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px 10px; margin: 0; display: flex; flex-direction: column; gap: 7px; min-width: 250px; }
.group legend { font-weight: 700; padding: 0 6px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row > label:first-child, .label-gap { width: 78px; color: var(--blue); font-weight: 600; font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 13px; cursor: pointer; }
.check.inc { color: var(--green); } .check.dec { color: var(--red); }
select, input[type=number], input[type=search], input:not([type]) { font: inherit; padding: 5px 7px; border: 1px solid #b9c4be; border-radius: 5px; background: #fff; }
select { min-width: 160px; }
.tiny { width: 52px; } .tiny-wide { width: 72px; } .small-input { width: 80px; }
.search { width: 100%; }
.cents-box { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; }
.include-box { background: #fff3e0; border-radius: 5px; padding: 5px 8px; font-size: 13px; display: flex; gap: 10px; align-items: center; }

.btn { font: inherit; font-weight: 700; border: 2px solid transparent; border-radius: 6px; padding: 7px 14px; cursor: pointer; color: #fff; line-height: 1.2; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-small { padding: 4px 10px; font-size: 12px; }
.btn-green { background: var(--green); border-color: #1b5e20; }
.btn-blue { background: var(--blue); border-color: #0d47a1; }
.btn-red { background: var(--red); border-color: #8e1b1b; }
.btn-orange { background: var(--orange); border-color: #c45400; }
.btn-slate { background: var(--slate); border-color: #263238; }
.btn-grey { background: #757575; border-color: #616161; }
.btn-plain { background: #fff; color: var(--ink); border: 1px solid #b9c4be; font-weight: 600; }
.btn:not(:disabled):hover { filter: brightness(1.08); }

.status { padding: 2px 18px; min-height: 20px; font-size: 13px; color: var(--muted); }
.status.error { color: var(--red); font-weight: 600; }

/* grid */
.grid-wrap { flex: 1; overflow: auto; margin: 0 16px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-height: 240px; }
.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 13px; }
.grid th { position: sticky; top: 0; z-index: 1; background: #e9efeb; border-bottom: 2px solid #b9c4be; padding: 6px 8px; text-align: left; white-space: nowrap; cursor: pointer; user-select: none; font-size: 12px; }
.grid th.num { text-align: right; }
.grid th.yellow { background: #f7eeb0; }
.grid td { padding: 3px 8px; border-bottom: 1px solid #edf1ee; white-space: nowrap; }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.center { text-align: center; }
.grid td.yellow { background: var(--yellow); }
.grid tbody tr:hover td { background: #eef6f1; }
.grid tbody tr.sel td { background: #1e90ff; color: #fff; }
.grid td.up { background: var(--up-bg); color: var(--up); font-weight: 600; }
.grid td.down { background: var(--down-bg); color: var(--down); font-weight: 600; }
.grid td.manual { box-shadow: inset 3px 0 0 var(--orange); }
#gridBody tr { cursor: default; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* Simple mode: hide what's marked .adv */
body.simple .adv { display: none !important; }

/* dialogs */
.dlg { border: 0; border-radius: 10px; padding: 0; max-width: min(640px, 96vw); box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.dlg-wide { max-width: min(1100px, 96vw); width: 1100px; }
.dlg::backdrop { background: rgba(20, 30, 25, .45); }
.dlg-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 10px; max-height: 90vh; }
.dlg h2 { margin: 0; font-size: 19px; }
.dlg h3 { margin: 8px 0 4px; font-size: 14px; }
.dlg-buttons { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.spacer { flex: 1; }
.item-grid { display: grid; grid-template-columns: 170px 1fr; gap: 5px 10px; align-items: center; }
.item-grid > span { color: var(--muted); font-size: 13px; }
.calc { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 0 10px; }
.readonly { background: #f0f0f0; }
.targets-list { overflow: auto; max-height: 55vh; border: 1px solid var(--line); border-radius: 6px; }
.tg-row { display: grid; grid-template-columns: 24px minmax(220px, 1fr) 150px 170px; align-items: center; gap: 8px; padding: 5px 10px; border-bottom: 1px solid #edf1ee; cursor: pointer; }
.tg-name { font-weight: 700; }
.tg-avg { color: var(--blue); font-weight: 600; font-size: 13px; }
.warn { color: var(--red); font-weight: 700; text-align: center; margin: 0; }
.table-scroll { overflow: auto; max-height: 50vh; border: 1px solid var(--line); border-radius: 6px; }
.small-grid th { cursor: default; }

/* sign-in */
.signin-page { align-items: center; justify-content: center; background: linear-gradient(160deg, #1b3a2b, #2f5d46); }
.signin-card { background: #fff; border-radius: 12px; padding: 28px 30px; width: min(380px, 92vw); text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 6px; }
.signin-card h1 { margin: 4px 0 0; font-size: 22px; }
.signin-logo { width: 72px; height: 72px; margin: 0 auto; }
.signin-card form { display: flex; flex-direction: column; gap: 8px; text-align: left; margin-top: 10px; }
.signin-card input { font-size: 16px; padding: 8px 10px; border: 1px solid #b9c4be; border-radius: 6px; }
.signin-card .btn { padding: 9px; }
.btn-primary { background: var(--green); border-color: #1b5e20; }
.alert { background: #fde4e4; color: var(--red); border-radius: 6px; padding: 7px 10px; margin-top: 8px; font-size: 13px; }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .topbar-right { margin-left: 0; }
}
