:root {
  --primary-lilac: #8B5CF6;
  --primary-dark: #6D28D9;
  --primary-deep: #4C1D95;
  --primary-light: #DDD6FE;
  --bg-lilac-soft: #F5F3FF;
  --text-main: #1E1B4B;
  --text-muted: #64748B;
  --white: #FFFFFF;
  --card-shadow: 0 10px 30px -5px rgba(139, 92, 246, 0.12), 0 4px 12px -2px rgba(0, 0, 0, 0.04);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --nav-height: calc(4.5rem + env(safe-area-inset-bottom));
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --display: "Playfair Display", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text-main);
  background: var(--bg-lilac-soft);
  line-height: 1.5;
  padding-top: env(safe-area-inset-top);
}
img { max-width: 100%; display: block; }
button, input, a { font: inherit; }
button, .bottom-nav button, .side-nav button, .menu-list button {
  min-height: 44px;
  min-width: 44px;
}
:focus-visible {
  outline: 3px solid var(--primary-deep);
  outline-offset: 2px;
}
.skip {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  background: var(--white);
  padding: 0.5rem 1rem;
  z-index: 5;
}
.skip:focus { top: 0.5rem; }

#splash, #offline, #login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  text-align: center;
}
#splash[hidden], #offline[hidden], #login[hidden], #shell[hidden], [hidden] { display: none !important; }
.muted { color: var(--text-muted); }
h1, h2 { font-family: var(--display); font-weight: 700; line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.25rem; }

.login-card, .item-card, .summary, .banner {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
}
.login-card { width: min(100%, 26rem); padding: 1.5rem; text-align: left; border-radius: var(--radius-lg); }
.brand, .top { display: flex; align-items: center; gap: 0.75rem; }
.logo-hero {
  width: min(220px, 72vw);
  height: auto;
  margin: 0 auto 0.75rem;
}
#login .logo-hero { width: min(240px, 100%); margin-bottom: 1rem; }
.logo-badge {
  width: 44px; height: 44px; display: grid; place-items: center; overflow: hidden;
  background: var(--white); border: 1px solid #EDE9FE; border-radius: 12px;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}
.logo-badge img { width: 100%; height: 100%; object-fit: cover; }
.brand-title { display: block; color: #DC2626; font-weight: 800; letter-spacing: 0.12em; }
.brand-sub { display: block; color: #2563EB; font-family: var(--display); font-style: italic; }
label { display: block; font-weight: 700; margin: 0.9rem 0 0.35rem; }
input {
  width: 100%; min-height: 48px; border: 1px solid #DDD6FE; border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem; background: var(--white); color: var(--text-main);
}
.password-row { display: flex; gap: 0.5rem; }
.password-row input { flex: 1; }
button {
  border: 0; border-radius: var(--radius-sm); background: var(--primary-lilac); color: var(--white);
  font-weight: 700; padding: 0.7rem 1rem; cursor: pointer;
}
button.secondary, .password-row button { background: var(--primary-light); color: var(--primary-deep); }
button:disabled { opacity: 0.7; }
#login-submit { width: 100%; margin-top: 1rem; }
.banner { padding: 0.8rem 1rem; color: var(--primary-deep); margin: 0 0 1rem; }
.banner p { margin: 0 0 0.5rem; }
.update { position: sticky; top: 0; z-index: 4; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.update[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 2; background: var(--primary-dark); color: var(--white);
  padding: 0.45rem 0.8rem;
  min-height: 3.25rem;
}
.top-text { min-width: 0; flex: 1; }
.top .brand-title, .top #shop-name { margin: 0; color: var(--white); font-style: normal; font-family: var(--font); letter-spacing: 0.08em; }
.top #shop-name { font-weight: 500; letter-spacing: 0; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-name { margin: 0; font-weight: 700; font-size: 0.85rem; max-width: 7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.net-status { margin: 0; padding: 0.35rem 1rem; background: #1E1B4B; color: #FFFFFF; font-size: 0.85rem; }
.home-meta { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; margin-bottom: 0.8rem; }
.home-meta p { margin: 0; color: var(--text-muted); font-size: 0.85rem; }
.home-meta button, .quick button, .summary button { min-height: 44px; }
.dash { display: grid; gap: 0.8rem; }
.summary-lead { border: 2px solid var(--primary-dark); }
.lead-title { font-size: 1.2rem; font-weight: 800; margin: 0.2rem 0; }
.figure { font-size: 1.6rem; font-weight: 800; margin: 0.2rem 0; }
.points-plus { color: #3F6212; }
.points-minus { color: var(--primary-deep); }
.nav-badge { display: inline-block; min-width: 1.2rem; padding: 0 0.3rem; border-radius: 999px; background: var(--primary); color: #fff; font-size: 0.75rem; line-height: 1.3; }
.notify-tools button, .item-card button { min-height: 44px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.quick button { background: var(--white); color: var(--primary-deep); border: 1px solid #DDD6FE; }
.badge { display: inline-block; margin: 0 0 0.5rem; padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--primary-light); color: var(--primary-deep); font-size: 0.8rem; font-weight: 800; }
.home-error { background: var(--white); border-radius: var(--radius-md); padding: 1rem; }
.sk-hello { height: 4.5rem; }
.sk-card { height: 8rem; }
.sk-line { height: 3rem; }
.top .logo-badge { width: 44px; height: 44px; border-color: transparent; }
.layout { padding: 1rem 1rem var(--nav-height); }
.section-head { margin-bottom: 1rem; }
.section-head p { margin: 0; color: var(--text-muted); }
.cards { display: grid; gap: 0.8rem; }
.item-card, .summary { padding: 1rem; margin-bottom: 0.8rem; }
.facts { display: grid; gap: 0.45rem; margin: 0; }
.facts div { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.5rem; }
.facts dt { color: var(--text-muted); font-size: 0.85rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.filters, .actions, .link-row, .menu-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 1rem; }
.filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.2rem; }
.filters button { flex: 0 0 auto; }
.filters button[aria-selected="true"] { background: var(--primary-dark); }
.search-label { display: block; margin: 0 0 0.8rem; font-size: 0.85rem; color: var(--text-muted); }
.search-label input { display: block; width: 100%; margin-top: 0.25rem; min-height: 44px; }
.item-title { margin: 0 0 0.45rem; font-size: 1.05rem; overflow-wrap: anywhere; }
.item-fold { padding: 0; }
.item-fold summary {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  min-height: 44px; padding: 0.85rem 1rem; cursor: pointer; list-style: none;
}
.item-fold summary::-webkit-details-marker { display: none; }
.item-fold summary .item-title { margin: 0; flex: 1; font-size: 1.05rem; font-weight: 700; }
.item-fold summary::after {
  content: "▾"; flex: 0 0 auto; color: var(--primary-deep); font-size: 0.9rem; line-height: 1;
}
.item-fold details[open] summary::after { content: "▴"; }
.item-fold-body { padding: 0 1rem 1rem; }
.item-card .badge { margin-top: 0; }
.money { font-variant-numeric: tabular-nums; }
.article-dialog {
  position: fixed; z-index: 5; left: 0.6rem; right: 0.6rem;
  bottom: calc(var(--nav-height) + 0.5rem); max-height: 70vh; overflow: auto;
  background: var(--white); border-radius: var(--radius-md); padding: 1rem;
  box-shadow: 0 8px 28px rgba(76, 29, 149, 0.18);
}
.article-dialog h2 { margin-top: 0; overflow-wrap: anywhere; }
.menu-list { flex-direction: column; }
.menu-list button, .item-card > button { width: 100%; text-align: left; background: var(--white); color: var(--text-main); box-shadow: none; }
.item-card > button { display: flex; flex-direction: column; align-items: flex-start; }
.empty, .loading { color: var(--text-muted); }
.skeleton { height: 5.5rem; border-radius: var(--radius-md); margin-bottom: 0.8rem; background: linear-gradient(90deg, #EDE9FE, #F5F3FF, #EDE9FE); background-size: 200% 100%; animation: shine 1.2s infinite; }
@keyframes shine { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  * { scroll-behavior: auto !important; }
}

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; justify-content: space-around; gap: 0.2rem;
  background: var(--white); border-top: 1px solid #EDE9FE;
  padding: 0.35rem 0.35rem env(safe-area-inset-bottom);
}
.bottom-nav button {
  flex: 1; background: transparent; color: var(--text-muted); font-size: 0.78rem; padding: 0.4rem 0.2rem;
}
.bottom-nav button[aria-current="page"] { color: var(--primary-deep); font-weight: 800; }
.side-nav { display: none; }

.pdf-dialog {
  position: fixed; inset: 0; z-index: 6; background: var(--bg-lilac-soft);
  display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0.8rem env(safe-area-inset-bottom);
}
.pdf-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.report-group { margin-bottom: 1.2rem; }
.report-group h2 { margin: 0 0 0.4rem; font-size: 1rem; }
.pdf-dialog iframe { flex: 1; width: 100%; border: 0; background: var(--white); border-radius: var(--radius-sm); min-height: 40vh; }
.pdf-bar button, #pdf-fallback { min-height: 44px; }
.pdf-help { color: var(--text-muted); font-size: 0.9rem; }
#pdf-fallback { display: inline-block; margin-bottom: 0.8rem; font-weight: 700; color: var(--primary-deep); }

@media (min-width: 768px) {
  .cards, .dash { grid-template-columns: 1fr 1fr; }
  .facts div { grid-template-columns: 8.5rem 1fr; }
  .layout { padding-left: 1.5rem; padding-right: 1.5rem; }
  .dash { align-items: start; }
  .home-block, .home-meta { grid-column: 1 / -1; }
  main { max-width: 45rem; }
}
@media (min-width: 840px) {
  .article-dialog { left: auto; right: 1.5rem; bottom: 1.5rem; width: min(28rem, 90vw); }
  .bottom-nav { display: none; }
  .layout { display: grid; grid-template-columns: 15rem minmax(0, 45rem); gap: 1.5rem; padding: 1.5rem; justify-content: center; }
  .side-nav { display: flex; flex-direction: column; gap: 0.4rem; align-self: start; position: sticky; top: 5rem; }
  .side-nav button { text-align: left; background: transparent; color: var(--text-main); }
  .side-nav button[aria-current="page"] { background: var(--primary-lilac); color: var(--white); }
}
@media (max-width: 359px) {
  .bottom-nav button { font-size: 0.68rem; }
  .facts div { grid-template-columns: 1fr; }
}
