:root {
  --rail: 240px;
  --header: calc(64px + env(safe-area-inset-top, 0px));
  --accent: #4864db;
  --accent-hover: #354dbc;
  --navigation: #142038;
  --navigation-text: #becae2;
  --shadow: 0 5px 18px #15254a09;
}
:root:not([data-theme="dark"]) { --bg: #f3f5fa; --line: #dfe5ef; }
:root[data-theme="dark"] { --navigation: #101725; --navigation-text: #bdc8dc; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #12161d; --line: #2b3340; }
}
body { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
body.hashdr { padding-top: var(--header); }
.hashdr main { max-width: 1510px; padding: clamp(16px, 3vw, 44px); }
h1 { font-size: clamp(1.65rem, 3.2vw, 2.45rem); line-height: 1.14; letter-spacing: -.045em; }
h2 { font-size: 1.13rem; letter-spacing: -.025em; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.konytop {
  position: fixed; inset: 0 0 auto; z-index: 20; height: var(--header);
  display: flex; align-items: center; gap: 12px; padding: env(safe-area-inset-top, 0px) clamp(12px, 3vw, 44px) 0;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.konyburger { display: grid; place-items: center; flex: 0 0 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); cursor: pointer; }
.konybrand { color: var(--text); font-weight: 750; white-space: nowrap; }
.konysearch { flex: 1; min-width: 0; max-width: 440px; margin: 0; }
.konysearch input { margin: 0; padding-inline: 16px; }
#konyScrim { position: fixed; inset: 0; display: none; background: #080f22a8; z-index: 25; }
#konyDrawer {
  position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--rail); max-width: 85vw;
  background: var(--navigation); color: var(--navigation-text); overflow-y: auto; overscroll-behavior: contain;
  padding: env(safe-area-inset-top, 0px) 12px 18px; visibility: hidden; transform: translateX(-100%);
}
.menu-open #konyDrawer { visibility: visible; transform: none; }
.menu-open #konyScrim { display: block; }
.menu-open { overflow: hidden; }
#konyDrawer .dhead { display: flex; align-items: center; gap: 11px; min-height: 72px; padding: 0 10px; color: #fff; font-size: 1.05rem; font-weight: 750; }
.workspace-mark {
  width: 36px; height: 36px; flex: 0 0 36px; display: inline-flex; align-items: flex-end; justify-content: center; gap: 3px;
  padding-bottom: 9px; background: var(--accent); border-radius: 10px; box-shadow: inset 0 0 0 1px #ffffff40;
}
.workspace-mark i { width: 4px; height: 8px; background: #fff; border-radius: 2px; }
.workspace-mark i:nth-child(2) { height: 13px; }
.workspace-mark i:nth-child(3) { height: 18px; }
#konyDrawer a, #konyDrawer .logout {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; margin: 2px 0; padding: 8px 10px;
  border: 0; border-radius: 8px; background: transparent; color: inherit; text-align: left; font: inherit; font-size: .88rem; cursor: pointer;
}
#konyDrawer a:hover, #konyDrawer .logout:hover { background: #ffffff12; color: #fff; }
#konyDrawer a.on { background: #506ae243; color: #fff; box-shadow: inset 3px 0 #98acff; font-weight: 650; }
#konyDrawer a span, #konyDrawer .logout span { display: grid; place-items: center; width: 22px; flex: 0 0 22px; }
#konyDrawer hr { border: 0; border-top: 1px solid #ffffff20; margin: 11px 8px; }
#konyDrawer .drawer-preferences { padding: 8px 10px; }
#konyDrawer label { color: inherit; }
#konyDrawer select { color-scheme: dark; color: #eef2ff; background: #202d45; border-color: #ffffff25; }
.card, .tile { border-radius: 16px; box-shadow: var(--shadow); }
.card { padding: clamp(14px, 2vw, 24px); }
.head { margin-bottom: 22px; }
input, select, textarea, .btn { border-radius: 9px; }
.btn.primary, .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover, .chip.on:hover { background: var(--accent-hover); }
table { background: var(--card); }
th, td { padding: 11px 14px; }
th { background: var(--bg); }
.scroll { border-radius: 10px; }
.dashboard-head p { margin: 7px 0 0; color: var(--muted); }
.finance-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.finance-tiles .tile { min-width: 0; padding: clamp(12px, 1.65vw, 22px); }
.finance-tiles .tile::before { content: ""; display: block; width: 24px; height: 4px; border-radius: 4px; background: var(--accent); margin-bottom: 14px; }
.finance-tiles .tile:nth-child(2)::before { background: #cb7453; }
.finance-tiles .tile:nth-child(3)::before { background: #1b937e; }
.finance-tiles .tile:nth-child(4)::before { background: #9464ce; }
.finance-tiles .tile b { display: block; margin-top: 6px; font-size: clamp(1.15rem, 2.05vw, 1.9rem); letter-spacing: -.04em; overflow-wrap: anywhere; }
.dashboard-panels { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
.provider-panel { flex: 2 1 390px; min-width: 0; }
.provider-panel .tiles { grid-template-columns: repeat(auto-fit, minmax(min(115px, 100%), 1fr)); }
.provider-panel .tile { background: var(--bg); box-shadow: none; }
.overdue-panel { flex: 1 1 300px; min-width: 0; }
.overdue-list { list-style: none; padding: 0; margin: 0; }
.overdue-list li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.overdue-list li div:last-child { text-align: right; }
.overdue-list small { display: block; color: var(--muted); }
.login-layout { min-height: calc(100vh - 32px); max-width: 420px; margin: auto; display: flex; flex-direction: column; justify-content: center; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; font-size: 1.18rem; }
.login-card { margin-bottom: 0; padding: clamp(22px, 5vw, 38px); }
.login-card h1 { margin-bottom: 24px; font-size: clamp(1.5rem, 5vw, 2rem); }
.login-card label { margin-bottom: 16px; }
.login-card input { padding: 11px 12px; }
.login-card .btn { width: 100%; margin-top: 4px; font-weight: 650; }
.login-download { margin: 19px 0 0; padding-top: 16px; border-top: 1px solid var(--line); text-align: center; }
@media (min-width: 1000px) {
  body.hashdr { padding-left: var(--rail); overflow: auto; }
  .konytop { left: var(--rail); }
  .konyburger, .konybrand, .menu-open #konyScrim { display: none; }
  #konyDrawer { visibility: visible; transform: none; }
}
@media (max-width: 720px) {
  .finance-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .hashdr main { padding: 16px; }
  .head { margin-bottom: 16px; }
}
@media print {
  #konyDrawer, .konytop, #konyScrim { display: none !important; }
  body.hashdr { padding: 0 !important; }
  .hashdr main { padding: 0; }
  .card, .tile { box-shadow: none; }
}

/* Both document views use their full-width layout on paper. */
@page accounting-document { size: A4; margin: 12mm; }
@media print {
  article.invoice {
    page: accounting-document;
    color-scheme: only light;
    --primary: #000;
    --text: #000;
    --muted: #000;
    --danger: #000;
    --line: #000;
    --bg: #fff;
    --card: #fff;
    color: #000;
    background: #fff;
    border: 0;
    padding: 0;
    font-weight: 600;
  }
  article.invoice .dates { background: #fff; }
  article.invoice :is(b, strong, h2, h3, th) { font-weight: 800; }
  article.invoice .scroll { overflow: visible; }
  article.invoice table { color: #000; background: #fff; }
  article.invoice th, article.invoice td { white-space: normal; background: #fff; }
  article.invoice tr { break-inside: avoid; }
}

.receipt-document {
  color-scheme: only light;
  --bg: #fff;
  --card: #fff;
  --text: #000;
  --muted: #000;
  --line: #000;
  color: #000;
  background: #fff;
  border: 1px solid #000;
  padding: clamp(16px, 4vw, 34px);
  max-width: 740px;
  margin: 0 auto;
  font: 650 16px/1.4 system-ui, sans-serif;
  overflow-wrap: anywhere;
}
.receipt-document h2, .receipt-document h3, .receipt-document th { color: #000; font-weight: 800; }
.receipt-document h2 { font-size: clamp(26px, 5vw, 38px); margin-bottom: 6px; }
.receipt-document h3 { text-transform: none; font-size: 1em; }
.receipt-document strong { font-weight: 800; }
.receipt-heading { text-align: center; padding-bottom: 12px; border-bottom: 2px solid #000; }
.receipt-heading p { margin: 0; }
.receipt-party { margin-top: 16px; }
.receipt-total { border-block: 2px solid #000; margin: 20px 0; padding: 12px 0; }
.receipt-total strong { display: block; font-size: clamp(27px, 5vw, 38px); }
.receipt-document th, .receipt-document td { white-space: normal; padding: 6px; }
@media print {
  article.receipt-document { margin: 0 auto; font-size: 12pt; }
  .receipt-document .receipt-party, .receipt-document .receipt-total { break-inside: avoid; }
}

.apk-update-button {
  display: grid;
  place-items: center;
  margin-inline-start: auto;
  flex: 0 0 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--primary);
  cursor: pointer;
}
.apk-update-button:hover { border-color: var(--primary); }
@media print {
  .apk-update-button { display: none !important; }
}

.receipt-divider { border-top: 1px solid var(--line); margin: 12px 0; }

@media screen {
  article.receipt-document {
    color-scheme: inherit;
    --bg: inherit;
    --card: inherit;
    --text: inherit;
    --muted: inherit;
    --line: inherit;
    color: var(--text);
    background: var(--card);
    border-color: var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    max-width: none;
  }
  .receipt-document .receipt-heading { text-align: left; border-color: var(--primary); }
  .receipt-document h2, .receipt-document h3, .receipt-document th { color: var(--text); }
}

@media screen {
  :root { --accent:#087aad; --accent-hover:#075f87; --header:calc(56px + env(safe-area-inset-top,0px)); }
  .konytop { background:#087aad; border:0; color:white; }
  .konybrand { display:block; overflow:hidden; text-overflow:ellipsis; color:white; font-size:1.15rem; }
  .konytop :is(.konyburger,.apk-update-button) { color:white; border-color:transparent; background:transparent; }
  .konysearch { margin-left:auto; }
  .card,.tile,.scroll { border-radius:5px; box-shadow:none; }
  .finance-tiles .tile::before { background:var(--accent); }
  .login-brand,.head h1 { color:var(--text); }
  .doc-list { background:var(--card); border:1px solid var(--line); padding-bottom:64px; }
  .doc-filters { padding:8px 14px; }
  .doc-filters summary { cursor:pointer; width:fit-content; margin-left:auto; color:var(--primary); }
  .doc-filters .chips { margin-top:10px; }
  .doc-month,.doc-link { display:flex; justify-content:space-between; gap:12px; align-items:center; }
  .doc-month { background:var(--bg); padding:10px 14px; }
  .doc-row { border-bottom:1px solid var(--line); }
  .doc-link { padding:10px 14px; min-height:60px; color:var(--text); }
  .doc-link:hover { text-decoration:none; background:var(--bg); }
  .doc-link > span:first-child { min-width:0; }
  .doc-link b, .customer-list-name { display:block; color:var(--text); font-size:1.25em; line-height:1.15; font-weight:650; overflow-wrap:anywhere; }
  .doc-link small { display:block; font-size:.8rem; }
  .doc-value,.doc-month strong { text-align:right; flex-shrink:0; }
  .doc-tag { width:fit-content; margin:2px 0 0 auto; color:white; background:#39689e; padding:1px 6px; border-radius:2px; }
  .doc-tag.green { background:#257447; }
  .doc-tag.late { background:#993b31; }
  .doc-tag.cancelled { background:#58616b; }
  .doc-action { display:inline-block; margin:0 14px 6px; font-size:.8rem; }
  .doc-add { display:grid; place-items:center; position:fixed; bottom:calc(18px + env(safe-area-inset-bottom,0px)); right:20px; background:var(--accent); color:white; border-radius:50%; width:54px; height:54px; font-size:27px; box-shadow:0 2px 6px #0003; }
  @media (max-width:720px) {
    .hashdr main:has(.doc-list) { padding:0; }
    .konysearch { max-width:105px; }
    .konybrand { flex:1; }
    .konytop { gap:4px; }
    .card,.tile { padding:12px; }
  }
}
@media screen and (max-width:720px) {
  .mobile-records.labelled,.mobile-records.labelled tbody { display:block; }
  .mobile-records.labelled thead { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  .mobile-records.labelled tr { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:4px 12px; padding:10px 4px; border-bottom:1px solid var(--line); }
  .mobile-records.labelled td { padding:0; border:0; overflow-wrap:anywhere; white-space:normal; text-align:left; }
  .mobile-records.labelled td:first-child,.mobile-records.labelled td[colspan] { grid-column:1/-1; }
  .mobile-records.labelled td:first-child { font-weight:600; color:var(--primary); }
  .mobile-records.labelled td:not(:first-child)[data-label]:not([data-label=""])::before { content:attr(data-label) " "; color:var(--muted); font-size:.78rem; }
  .mobile-records.labelled td:empty { display:none; }
}
@media screen {
  .admin-home { max-width:1080px; margin:auto; padding-bottom:calc(24px + env(safe-area-inset-bottom,0px)); }
  .admin-tools { display:flex; flex-wrap:wrap; gap:10px; margin:0 0 18px; }
  .admin-tools a { display:inline-flex; gap:8px; align-items:center; min-height:44px; padding:0 12px; border:1px solid var(--line); border-radius:10px; background:var(--card); color:var(--text); font-weight:600; }
  .admin-tools svg { width:19px; height:19px; fill:none; stroke:var(--primary); stroke-width:1.7; }
  .admin-home .card { padding:18px; border-radius:14px; }
  .admin-home h2 { font-size:1.2rem; margin:0 0 8px; }
  .admin-home ul { margin:0 0 12px; padding:0; list-style:none; }
  .admin-home li a { display:flex; align-items:center; gap:8px; justify-content:space-between; min-height:48px; border-bottom:1px solid var(--line); }
  .admin-home li small { color:var(--muted); font-size:.78rem; }
  .admin-create summary { cursor:pointer; list-style:none; display:flex; align-items:center; gap:8px; color:var(--primary); font-weight:650; min-height:44px; }
  .admin-create summary::before { content:"+"; display:grid; place-items:center; width:26px; height:26px; border-radius:8px; background:var(--bg); font-size:1.2rem; }
  .admin-create[open] summary::before { content:"−"; }
  .admin-create form { margin:10px 0 0; }
  .admin-create label { color:var(--text); }
  @media (max-width:720px) { .admin-home .two { display:grid; grid-template-columns:minmax(0,1fr); gap:12px; } }
}

@media screen {
  :root { --accent:#1264b2; --accent-hover:#074d91; }
  .konytop { background:linear-gradient(108deg,#084c86,#1264a1 68%,#086d8c); box-shadow:0 2px 9px #072b4d25; }
  .konytop .konybrand { letter-spacing:-.025em; }
  .konytop .konysearch input { color:#fff; background:#ffffff16; border-color:#ffffff52; border-radius:20px; }
  .konysearch input::placeholder { color:#edf6ff; opacity:1; }
  .hashdr .card:not(.invoice),.hashdr .tile,.login-card { border-radius:14px; }
  .finance-tiles .tile:first-child { background:#124d78; color:white; }
  .finance-tiles .tile:first-child span { color:#e4f4ff; }
  .finance-tiles .tile:first-child::before { background:#76d5ef; }
  .doc-value,.doc-month strong,.finance-tiles b { font-variant-numeric:tabular-nums; }
  .doc-month { border-block:1px solid var(--line); font-size:.93rem; }
  .doc-tag { border-radius:5px; padding:2px 8px; line-height:1.35; }
  .admin-home .two { align-items:start; }
  .admin-home h2 { display:flex; align-items:center; gap:9px; }
  .admin-home h2 small { padding:2px 7px; font-size:.76rem; border:1px solid var(--line); border-radius:6px; color:var(--muted); font-weight:600; }
  .admin-tools { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .admin-tools a { min-height:56px; border-radius:12px; }
  .admin-tools svg { box-sizing:content-box; padding:7px; border-radius:9px; background:var(--bg); }
  .user-entry { display:flex; align-items:center; gap:10px; color:var(--text); font-weight:600; overflow-wrap:anywhere; }
  .user-entry i { display:grid; place-items:center; width:32px; height:32px; flex:none; border-radius:10px; background:#deedf9; color:#164f76; font-style:normal; }
  .admin-home li a { min-height:52px; }
  .admin-create { border-top:1px solid var(--line); padding-top:5px; }
  .admin-home li:last-child a { border-bottom:0; }
  .admin-create form .btn { min-height:44px; }
}
