:root {
  --navy: #1b2a4a; --gold: #b8914a; --bg: #f5f6f8; --line: #dde1e8; --text: #1f2633; --muted: #6b7385;
  --ok: #2e8b57; --excess: #2f6fb5; --shortfall: #e07b1f; --trapped: #c0392b; --draft: #8a8f99;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
a { color: var(--navy); }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
h1 { font-size: 24px; color: var(--navy); margin: 0 0 16px; }
h2 { font-size: 18px; color: var(--navy); margin: 24px 0 10px; }

.top { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 24px; padding: 10px 20px;
       border-bottom: 3px solid var(--gold); flex-wrap: wrap; }
.top a { color: #fff; text-decoration: none; }
.top .brand { font-weight: 700; font-size: 18px; color: #e8d3a8; }
.top nav { display: flex; gap: 18px; flex: 1; }
.top nav a:hover { color: #e8d3a8; }
.top .year select { margin-inline-start: 6px; }
.top .logout span { opacity: .8; }
button.link { background: none; border: 0; color: #e8d3a8; cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 16px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 200px; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.spacer { flex: 1; }

label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 12px; }
label small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input:not([type]),
select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid #c4cad6; border-radius: 6px;
  font: inherit; background: #fff;
}
textarea { min-height: 90px; line-height: 1.5; }
input.num { direction: ltr; text-align: right; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.check input { width: auto; margin: 0; }

.btn { display: inline-block; background: var(--navy); color: #fff; border: 0; border-radius: 6px; padding: 9px 18px;
       font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--navy); }
.btn.danger { background: var(--trapped); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
th { background: #eef0f4; font-size: 13px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: left; direction: ltr; white-space: nowrap; }
tr.muted td { color: var(--muted); }
tr.group td { background: #f8f9fb; font-weight: 600; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; }
.flash.ok { background: #e6f4ec; color: #1e6b41; }
.flash.error { background: #fdecea; color: #9b2c20; }
.warn { background: #fff4e5; border: 1px solid #f3c58b; color: #8a4b08; padding: 12px 14px; border-radius: 6px; margin-bottom: 16px; }
.warn ul { margin: 6px 0 0; padding-inline-start: 20px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok); } .badge.excess { background: var(--excess); }
.badge.shortfall { background: var(--shortfall); } .badge.trapped { background: var(--trapped); }
.badge.draft { background: var(--draft); } .badge.none { background: #fff; color: var(--muted); border: 1px dashed #b5bcc9; }
.pos { color: var(--excess); } .neg { color: var(--shortfall); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters a { padding: 6px 12px; border-radius: 16px; background: #fff; border: 1px solid var(--line); text-decoration: none; font-size: 14px; }
.filters a.on { background: var(--navy); color: #fff; border-color: var(--navy); }

.steps { display: flex; gap: 4px; margin-bottom: 20px; counter-reset: s; flex-wrap: wrap; }
.steps a, .steps span { flex: 1; text-align: center; padding: 8px 6px; background: #e6e9ef; color: var(--muted);
  text-decoration: none; font-size: 13px; border-radius: 4px; min-width: 110px; }
.steps .on { background: var(--navy); color: #fff; font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: 6px; padding: 12px 14px; }
.kpi b { display: block; font-size: 20px; color: var(--navy); margin-top: 4px; direction: ltr; text-align: right; }
.kpi span { font-size: 13px; color: var(--muted); }
.login { max-width: 380px; margin: 80px auto; }
.muted { color: var(--muted); }
dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.info dt { color: var(--muted); } dl.info dd { margin: 0; }

details.folder { background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; }
details.folder > summary { cursor: pointer; padding: 10px 14px; font-size: 16px; }
details.folder table { border-top: 1px solid var(--line); }
td.files { font-size: 13px; line-height: 1.7; }

.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 16px; margin: 12px 0 0;
        border: 2px dashed #c9b27f; border-radius: 10px; background: #fbf8f1; cursor: pointer; text-align: center; font-weight: 400; }
.drop input[type=file] { display: none; }
.drop b { font-size: 16px; color: var(--navy); }
.drop small { color: var(--muted); }
.drop.over { background: #f3ead6; border-color: var(--gold); }
.drop.has-file { border-style: solid; border-color: var(--ok); background: #eef7f1; }

.logo-now { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 16px;
            border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.logo-now img { max-height: 90px; max-width: 260px; }
.logo-text { display: flex; flex-direction: column; align-items: center; background: var(--navy); color: #fff;
             padding: 12px 22px; border-radius: 6px; }
.logo-text span { color: var(--gold); font-size: 12px; letter-spacing: 3px; border-top: 1px solid var(--gold); margin-top: 3px; padding-top: 2px; }

.sent-ok { display: inline-flex; align-items: center; gap: 6px; color: #1e6b41; font-size: 13px; line-height: 1.2; }
.sent-ok small { color: var(--muted); }
.open-year { position: relative; }
.open-year summary { cursor: pointer; color: #e8d3a8; font-size: 13px; list-style: none; text-decoration: underline; }
.open-year form { position: absolute; top: 26px; right: 0; z-index: 5; background: #fff; padding: 10px; border-radius: 6px;
                  box-shadow: 0 4px 14px rgba(0,0,0,.2); display: flex; gap: 6px; }
.open-year input { width: 90px; margin: 0; }

.systitle { font-size: 28px; margin-bottom: 18px; border-bottom: 3px solid var(--gold); padding-bottom: 8px; }
.search { display: flex; gap: 6px; align-items: center; }
.search input { margin: 0; width: 230px; }
.rowbtns { white-space: nowrap; }
.rowbtns form { display: inline; }
.preview-layout { display: grid; grid-template-columns: minmax(320px, 2fr) 3fr; gap: 16px; align-items: start; }
.viewpane iframe { width: 100%; height: 1100px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.editpane textarea { min-height: 70px; }
.finalbar { border-top: 1px solid var(--line); padding-top: 14px; }
.btn.big { font-size: 16px; padding: 12px 22px; background: var(--ok); }
.calcdetails summary { cursor: pointer; font-weight: 600; color: var(--navy); }
main { max-width: 1400px; }
@media (max-width: 1000px) { .preview-layout { grid-template-columns: 1fr; } }

.divresult { margin-top: 10px; padding: 10px 14px; border-radius: 6px; border-right: 4px solid var(--line); background: #f6f7fa; }
.divresult.ok { background: #e6f4ec; border-color: var(--ok); color: #1e6b41; }
.divresult.ask { background: #fff4e5; border-color: var(--shortfall); color: #8a4b08; }
.divresult.err { background: #fdecea; border-color: var(--trapped); color: #9b2c20; }
