/* P05 styles: warm candle palette, left menu, tables with sticky headers, responsive down to phones. */
:root {
  --bg: #faf6f0; --card: #ffffff; --ink: #2b2420; --mut: #7d7268; --line: #ece3d8;
  --pri: #b8641e; --pri2: #8a4512; --side: #2f241d; --side2: #43342a; --good: #2e9d62; --bad: #c8382f; --warn: #d98a00;
  --rad: 12px; --sh: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 18px rgba(60, 40, 20, .07);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1 { font-size: 1.25rem; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
h2 { margin: .4em 0; } h3 { margin: 0 0 .8em; font-size: 1.02rem; }
.muted { color: var(--mut); } .small { font-size: .85rem; } .good { color: var(--good); } .bad { color: var(--bad); }
.row { display: flex; align-items: center; } .gap { gap: 10px; } .wrap { flex-wrap: wrap; } .col { display: flex; flex-direction: column; gap: 12px; }

/* One shared rule: everything clickable darkens visibly on hover and shows the hand; disabled items do not. */
.hov, button, a, summary, select, th, tr.trow, .ci, .kpi[data-go], .todo, .bar[data-open] { cursor: pointer; }
.hov:not(:disabled):hover, button:not(:disabled):hover, a.link:hover, tr.trow:hover > td, .ci:hover, .kpi[data-go]:hover, .todo:hover, .bar[data-open]:hover { box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .09); }
button:disabled { cursor: not-allowed; opacity: .55; }

/* buttons and inputs */
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 9px; padding: 8px 14px; font: inherit; font-weight: 600; transition: box-shadow .12s; }
.btn.primary { background: linear-gradient(180deg, #c8752b, var(--pri)); color: #fff; border-color: var(--pri2); }
.btn.danger { background: #fff1ef; color: var(--bad); border-color: #f2c6c0; }
.btn.big { padding: 13px 18px; font-size: 1.05rem; } .btn.small { padding: 5px 10px; font-size: .88rem; } .btn.icon { padding: 6px 10px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .86rem; color: var(--mut); font-weight: 600; flex: 1; min-width: 0; }
label.row { flex-direction: row; gap: 8px; }
input, select, textarea { font: inherit; color: var(--ink); padding: 9px 11px; border: 1px solid #ddd0c2; border-radius: 9px; background: #fffdfa; width: 100%; }
input:focus, select:focus { outline: 2px solid #f0b47a; border-color: var(--pri); }
input[type=checkbox] { width: auto; }
.link { color: var(--pri2); text-decoration: underline; text-underline-offset: 2px; border-radius: 4px; }
.msg { background: #fff8e8; border: 1px solid #f3dfae; padding: 10px 12px; border-radius: 9px; font-size: .92rem; }
.msg.ok { background: #ecf8f1; border-color: #bfe6cf; } .msg.bad { background: #fff1ef; border-color: #f2c6c0; color: var(--bad); }
.tag { background: #f3e7da; color: var(--pri2); border-radius: 20px; padding: 1px 8px; font-size: .75rem; }

/* sign-in */
body.login { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at 30% 10%, #fff3e0, #f3e4d2 55%, #e9d3bc); }
.login-box { width: min(440px, 100%); background: #fff; border-radius: 18px; padding: 24px; box-shadow: 0 20px 50px rgba(90, 50, 20, .18); display: flex; flex-direction: column; gap: 16px; }
.login-top { display: flex; gap: 12px; align-items: center; } .login-top > div:nth-child(2) { flex: 1; }
.logo { font-size: 2rem; filter: drop-shadow(0 2px 6px rgba(240, 160, 60, .6)); }
.or { text-align: center; color: var(--mut); font-size: .85rem; }
.emerg summary { color: var(--mut); font-size: .85rem; padding: 4px; border-radius: 6px; } .emerg form { margin-top: 10px; }

/* layout: left menu column */
aside#side { position: fixed; inset: 0 auto 0 0; width: 236px; background: linear-gradient(180deg, var(--side), #1f1813); color: #f3e7da; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 14px; font-size: .92rem; line-height: 1.25; border-bottom: 1px solid #ffffff14; }
nav { display: flex; flex-direction: column; padding: 8px; gap: 2px; flex: 1; overflow: auto; }
nav a { color: #f3e7da; padding: 10px 12px; border-radius: 9px; text-decoration: none; font-weight: 600; font-size: .95rem; }
nav a.on { background: var(--side2); color: #ffd9a8; } .warn-dot { color: #ffb347; }
.side-foot { padding: 10px 12px; border-top: 1px solid #ffffff14; font-size: .8rem; display: flex; flex-direction: column; gap: 6px; }
.side-foot footer.pm { color: #c8b6a4; padding: 0; text-align: left; }
.ver { color: #c8b6a4; }
.flags { display: inline-flex; gap: 4px; } .flag { border: 1px solid transparent; background: transparent; font-size: 1.15rem; border-radius: 6px; padding: 1px 4px; opacity: .55; } .flag.on { opacity: 1; border-color: #ffffff40; }
.login .flag.on { border-color: var(--line); }
main { margin-left: 236px; min-height: 100vh; display: flex; flex-direction: column; }
header { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 12px 22px; background: rgba(250, 246, 240, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
header #q { max-width: 260px; } #bMenu { display: none; }
.qmark { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-weight: 700; font-size: .8rem; padding: 0; color: var(--pri2); }
#page { padding: 20px 22px 64px; flex: 1; display: flex; flex-direction: column; gap: 16px; }
footer.pm { text-align: center; color: #a89a8c; font-size: .74rem; padding: 10px; letter-spacing: .02em; }
#shade { display: none; }

/* cards, KPIs */
.card { background: var(--card); border-radius: var(--rad); box-shadow: var(--sh); padding: 16px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--card); border-radius: var(--rad); box-shadow: var(--sh); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; border-left: 4px solid #e8b04b; }
.kpi span { color: var(--mut); font-size: .82rem; font-weight: 600; } .kpi b { font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.kpi.big { border-left-color: var(--pri); } .kpi.big b { color: var(--pri2); font-size: 1.7rem; }
.kpi.warn { border-left-color: var(--warn); } .kpi.ok { border-left-color: var(--good); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.form4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.todo { padding: 8px 10px; border-radius: 8px; color: #8a5a00; } .back { align-self: flex-start; padding: 2px 6px; }
.calc { background: #fbf3e8; border-radius: 9px; padding: 9px 12px; font-size: .9rem; }
.kv { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--line); padding: 4px 0; font-size: .9rem; }
.sumrows { margin-top: 12px; border-top: 1px solid var(--line); } .sumrows div { display: flex; justify-content: space-between; padding: 6px 4px; font-size: .92rem; font-variant-numeric: tabular-nums; }
.sumrows .tot { border-top: 2px solid var(--ink); font-size: 1.05rem; } .sumrows .tot b { color: var(--pri2); }

/* tables: single-line rows, sort arrows on every column, groups */
.tw { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { position: sticky; top: 0; background: #f6eee4; text-align: left; font-weight: 700; color: #5b4a3d; padding: 9px 10px; white-space: nowrap; user-select: none; border-bottom: 1px solid var(--line); }
.tbl th .ar { margin-left: 4px; font-size: .7rem; color: #b8a796; } .tbl th .ar.on { color: var(--pri); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #f3ece4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; font-variant-numeric: tabular-nums; }
.tbl td.wide { max-width: 320px; } .tbl .n { text-align: right; }
.tbl td.ed { background-image: linear-gradient(transparent calc(100% - 1px), #f0d8bd 1px); }
.tbl tr.grp td { background: #fbf6f0; font-weight: 700; color: #6b543f; padding: 7px 10px; max-width: none; }
.tbl tr.grp .gsum { float: right; }
input.cell, select.cell { padding: 4px 6px; border-radius: 6px; min-width: 90px; }
.empty { text-align: center; padding: 26px 12px; color: var(--mut); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty.small { padding: 10px; font-size: .88rem; } .empty.hero { padding: 60px 16px; } .empty .big { font-size: 3.4rem; }

/* charts */
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; gap: 10px; align-items: center; padding: 3px 4px; border-radius: 6px; font-size: .86rem; }
.bar .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .bar b { font-variant-numeric: tabular-nums; font-size: .82rem; }
.bt { display: flex; height: 18px; border-radius: 5px; overflow: hidden; background: #f4ece3; } .bt i { display: block; height: 100%; transition: width .5s; }
.bg { display: flex; flex-direction: column; gap: 2px; grid-column: span 2; } .bg i { display: block; height: 7px; border-radius: 4px; transition: width .5s; }
.legend { gap: 6px 14px; margin-top: 10px; font-size: .8rem; color: var(--mut); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.donut { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; } .donut svg { width: 210px; height: 210px; flex: none; }
.donut .seg { transition: opacity .15s; } .donut .seg:hover { opacity: .8; }
.dc1 { text-anchor: middle; font-weight: 800; font-size: 17px; fill: var(--pri2); } .dc2 { text-anchor: middle; font-size: 11px; fill: var(--mut); }
.donut .legend { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 180px; margin: 0; }
.donut .legend div { display: grid; grid-template-columns: auto 1fr auto auto; gap: 6px; align-items: center; } .donut .legend b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* modal, right-click menu, toast, guide */
#modal { position: fixed; inset: 0; background: rgba(30, 20, 12, .45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.mbox { background: #fff; border-radius: 16px; width: min(560px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 30px 70px rgba(0, 0, 0, .3); }
.mhead { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.mbody { padding: 16px; overflow: auto; }
.ctx { position: fixed; z-index: 70; background: #fff; border-radius: 10px; box-shadow: 0 12px 34px rgba(0, 0, 0, .22); padding: 6px; min-width: 200px; font-size: .9rem; }
.ctx .ci { padding: 7px 10px; border-radius: 7px; white-space: nowrap; } .ctx .sep { font-size: .75rem; color: var(--mut); padding: 6px 10px 2px; border-top: 1px solid var(--line); margin-top: 4px; }
.ctx.two .cm { display: grid; grid-template-columns: 1fr 1fr; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #2f241d; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 90; box-shadow: var(--sh); max-width: 90vw; }
.toast.bad { background: var(--bad); }
.hsec { border-bottom: 1px solid var(--line); } .hsec summary { padding: 10px 6px; font-weight: 700; border-radius: 8px; } .htext { padding: 0 8px 10px; line-height: 1.5; font-size: .93rem; }
.feat { white-space: pre-wrap; font-size: .8rem; background: #faf6f0; padding: 10px; border-radius: 8px; }
.glit { outline: 3px solid #ff9f1c !important; outline-offset: 3px; border-radius: 8px; position: relative; z-index: 45; }
.gbub { position: fixed; z-index: 80; background: #fffaf2; border: 2px solid #ff9f1c; border-radius: 14px; padding: 12px 14px; width: min(340px, calc(100vw - 20px)); box-shadow: 0 16px 40px rgba(0, 0, 0, .22); display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.gbub.done { top: 40%; left: 50%; transform: translateX(-50%); align-items: center; } .garrow { font-weight: 800; color: #c76a00; font-size: 1rem; }

/* phones: menu slides in, tables keep key columns (tap a row for the rest) */
@media (max-width: 1000px) { .kpis, .form4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  aside#side { transform: translateX(-100%); transition: transform .2s; width: 260px; }
  body.menu-open aside#side { transform: none; } body.menu-open #shade { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 15; }
  main { margin-left: 0; } #bMenu { display: inline-block; } header { padding: 10px 12px; flex-wrap: wrap; } header #q { order: 9; max-width: none; flex-basis: 100%; }
  #page { padding: 14px 10px 64px; } .toolbar .muted { display: none; } .tbl .nm { display: none; } .tbl td { max-width: 46vw; }
  .kpi b { font-size: 1.2rem; } .bar { grid-template-columns: minmax(70px, 34%) 1fr auto; }
}
