:root {
  --brand: #F97600;
  --brand-dark: #D96600;
  --ink: #232323;
  --cream: #F9F0ED;
  --line: #E6DDD9;
  --gray: #D3D2D2;
  --muted: #6F6A68;
  --ok: #1E7F4F;
  --err: #C0392B;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink); background: var(--cream);
}
a { color: var(--brand-dark); }
h1 { font-size: 1.45rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; }

/* viršutinė juosta */
.top { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10; }
.top-in { max-width: 1150px; margin: 0 auto; padding: .55rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 1.1rem; color: #fff; text-decoration: none; letter-spacing: .2px; }
.logo b { color: var(--brand); }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a { color: #ddd; text-decoration: none; padding: .45rem .7rem; border-radius: 8px; font-weight: 500; white-space: nowrap; }
.nav a:hover { background: #333; color: #fff; }
.nav a.on { background: var(--brand); color: #fff; }
.me { display: flex; align-items: center; gap: .6rem; font-size: .88rem; color: #bbb; }
.me form { margin: 0; }
.me button { background: none; border: 1px solid #555; color: #ddd; border-radius: 7px; padding: .25rem .6rem; cursor: pointer; }

main { max-width: 1150px; margin: 0 auto; padding: 1.2rem 1rem 4rem; }

/* pranešimai */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: .6rem; font-weight: 500; }
.flash.ok { background: #E3F4EA; color: var(--ok); border: 1px solid #BFE3CE; }
.flash.error { background: #FBE7E4; color: var(--err); border: 1px solid #F2C4BE; }
.flash.err { background: #FBE7E4; color: var(--err); border: 1px solid #F2C4BE; }
.flash.warn { background: #FFF0E0; color: var(--ink); border: 1px solid #F9C894; }

/* kortelės */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.stat { background: var(--cream); border-radius: 8px; padding: .6rem .75rem; text-decoration: none; color: inherit; display: block; }
.stat:hover { outline: 2px solid var(--brand); }
.stat small { color: var(--muted); display: block; font-size: .8rem; }
.stat strong { font-size: 1.3rem; display: block; }
.stat span { color: var(--muted); font-size: .8rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .7rem; gap: .5rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

/* formos */
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; color: #444; }
input, select, textarea {
  width: 100%; font: inherit; padding: .55rem .65rem; border: 1px solid var(--gray); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(249,118,0,.18); }
.row { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: .75rem; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: .95rem; }
.check input { width: auto; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font: inherit; font-weight: 600;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--gray); background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--err); border-color: #EBB8B1; }
.btn.sm { padding: .3rem .6rem; font-size: .85rem; }
.btn.big { padding: .8rem 1.4rem; font-size: 1.05rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.toolbar > div { min-width: 130px; }
.inline { display: inline; margin: 0; }

/* lentelės */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: var(--ink); color: #fff; font-weight: 600; font-size: .82rem; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.annulled td { color: #aaa; text-decoration: line-through; }
tfoot td { font-weight: 700; background: var(--cream); }
.muted { color: var(--muted); font-size: .85rem; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #eee; white-space: nowrap; }
.badge.ok { background: #E3F4EA; color: var(--ok); }
.badge.warn { background: #FFF0E0; color: var(--brand-dark); }
.badge.err { background: #FBE7E4; color: var(--err); }
.total-big { font-size: 1.6rem; font-weight: 800; color: var(--ink); }
.total-big small { font-size: .9rem; font-weight: 500; color: var(--muted); }

/* lankomumas */
.att td { padding: .4rem .45rem; }
.att input, .att select { padding: .4rem .45rem; }
.att .t { width: 92px; }
.att .h { width: 70px; }
.att tr.dirbo td:first-child { border-left: 4px solid var(--ok); }
.att tr.kita td:first-child { border-left: 4px solid var(--brand); }
.att tr.none td:first-child { border-left: 4px solid var(--gray); }
.month td, .month th { padding: .3rem .35rem; text-align: center; font-size: .82rem; }
.month td:first-child, .month th:first-child { text-align: left; white-space: nowrap; position: sticky; left: 0; background: #fff; }
.month th:first-child { background: var(--ink); }
.month th.we, .month td.we { background: #F4EAE6; }
.month th.we { background: #3a3a3a; }
.month td.code { color: var(--brand-dark); font-weight: 700; }

/* pardavimo eilutės */
.lines { width: 100%; }
.lines td { border: 0; padding: .25rem .25rem; }
.lines .pid { width: 28%; }
.lines .pr { width: 22%; }
.lines .rm { width: 44px; }
.sale-total { display: flex; justify-content: space-between; align-items: center; background: var(--ink); color: #fff; border-radius: var(--radius); padding: .8rem 1rem; margin: .8rem 0; }
.sale-total strong { font-size: 1.6rem; color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--gray); border-radius: 8px; overflow: hidden; }
.seg label { margin: 0; padding: .5rem .9rem; cursor: pointer; font-weight: 600; font-size: .9rem; background: #fff; }
.seg input { display: none; }
.seg input:checked + span { color: var(--brand-dark); }
.seg label:has(input:checked) { background: #FFF0E0; }
details summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }

/* prisijungimas */
.login { max-width: 380px; margin: 8vh auto; }
.login .brandbar { background: var(--ink); color: #fff; border-radius: var(--radius) var(--radius) 0 0; padding: 1.2rem; text-align: center; }
.login .brandbar .logo { font-size: 1.5rem; }
.login .card { border-radius: 0 0 var(--radius) var(--radius); }

@media (max-width: 700px) {
  body { font-size: 16px; }
  .top-in { gap: .4rem; }
  .nav { order: 3; flex: 0 0 100%; overflow-x: auto; flex-wrap: nowrap; }
  .me { margin-left: auto; }
  .me .name { display: none; }
  .att thead { display: none; }
  .att tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .35rem; padding: .6rem; border-bottom: 1px solid var(--line); }
  .att td { border: 0; padding: 0; }
  .att td.who { grid-column: 1 / -1; font-weight: 700; }
  .att td.st { grid-column: 1 / -1; }
  .att td.nt { grid-column: 1 / -1; }
  .att .t, .att .h { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; }
}
@media print {
  .top, .toolbar, .actions, .no-print { display: none !important; }
  body { background: #fff; }
}

/* darbuotojo kalendorius */
.cal td { vertical-align: top; height: 92px; width: 14.28%; font-size: .82rem; border-right: 1px solid var(--line); }
.cal th { text-align: center; }
.cal .dn { font-weight: 700; margin-bottom: .2rem; }
.cal .sv { font-weight: 600; }
.cal td.out { background: #FAFAFA; }
.cal td.we { background: #F4EAE6; }
.cal td.st-dirbo { background: #E3F4EA; }
.cal td.st-atostogos, .cal td.st-planuota { background: #FFF0E0; }
.cal td.st-liga { background: #FBE7E4; }
.cal td.st-kita { background: #EEF0F6; }
.cal td.td-today { outline: 2px solid var(--brand); outline-offset: -2px; }
@media (max-width: 700px) { .cal td { height: 64px; padding: .25rem; font-size: .72rem; } .cal td .muted { display: none; } }

/* pajamų suvestinė */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .8rem; }
.kpi { display: block; background: var(--cream); border-radius: 8px; padding: .7rem .8rem; text-decoration: none; color: inherit; border: 1px solid transparent; }
a.kpi:hover { border-color: var(--ink); }
.kpi small { display: block; color: var(--muted); font-size: .8rem; }
.kpi strong { display: block; font-size: 1.45rem; }
.kpi span { color: var(--muted); font-size: .8rem; }
.kpi.res { background: #FFF0E0; }
.kpi.res strong { color: var(--brand-dark); }
table.mini td { padding: .3rem 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
@media (max-width: 700px) { .kpis { grid-template-columns: 1fr; } }
table.mini { width: 100%; table-layout: fixed; }
table.mini td.num { white-space: normal; text-align: right; }
.formcard { display: block; text-decoration: none; color: inherit; margin: 0; }
.formcard:hover { border-color: var(--brand); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.formcard strong { display: block; font-size: 1.02rem; margin-bottom: .25rem; }
.formcard span { color: var(--muted); font-size: .85rem; }

td.row-actions { white-space: nowrap; }
td.row-actions .inline { display: inline-block; }

tr.cancelled-row td { background: #FAF6F5; color: var(--muted); }
tr.cancelled-row td b { color: var(--muted); }

/* darbo grafikas */
.sched th, .sched td { padding: .3rem .25rem; text-align: center; font-size: .8rem; }
.sched th div { font-weight: 400; opacity: .75; }
.sched td.who { text-align: left; white-space: nowrap; padding-right: .5rem; position: sticky; left: 0; background: #fff; z-index: 1; }
.sched th:first-child { position: sticky; left: 0; z-index: 2; }
.sched td.we { background: #F4EAE6; color: var(--muted); }
.sched td.code-d { background: #E3F4EA; font-weight: 600; }
.sched td.code-a { background: #FFF0E0; color: var(--brand-dark); font-weight: 700; }

.cal .plan { font-size: .72rem; color: var(--muted); border-bottom: 1px dashed var(--line); margin-bottom: .15rem; }

/* nesuvestos pastovios išlaidos */
tr.missing-row td { background: #FBE7E4; }
tr.missing-row td b { color: var(--err); }

/* patvirtinimo langas */
.vm-modal { position: fixed; inset: 0; background: rgba(35,35,35,.45); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; }
.vm-modal.open { display: flex; }
.vm-modal-card { background: #fff; border-radius: var(--radius); padding: 1.2rem; max-width: 440px; width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.vm-modal-text { margin: 0 0 .8rem; font-weight: 600; }
.vm-modal-input { width: 100%; margin-bottom: .4rem; }
.vm-modal-err { display: none; color: var(--err); font-size: .85rem; margin-bottom: .4rem; }
.vm-modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .6rem; }

/* pasirašymas */
.signbox { margin-top: .5rem; padding: .6rem .7rem; border: 1px dashed var(--brand); border-radius: 8px; background: #FFFBF6; }

[hidden] { display: none !important; }
