/* Hisab platform — landing, dashboard, app shell and the shared UI kit used by every app module.
   Builds on app.css (tokens, .glass, .btn, .card, .seg, .chip, dialog, .field, .combo-*, .toast). */

/* ---------- View switching ---------- */
#landingView, #homeView, #shellView { display: none; }
body.is-landing #landingView, body.is-home #homeView, body.is-shell #shellView { display: block; animation: viewIn .6s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; } }
body.is-loading::after { content: ""; position: fixed; top: 50%; left: 50%; width: 34px; height: 34px; margin: -17px; border-radius: 50%; border: 3px solid var(--line2); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
[hidden] { display: none !important; }

/* ---------- Top nav (landing + dashboard) ---------- */
.nav { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px clamp(16px, 4vw, 48px);
  background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); }
.nav .brand { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 10px; }
.nav-links > a { text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 500; padding: 8px 10px; border-radius: 999px; transition: color .3s, background .3s; }
.nav-links > a:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.btn.big { padding: 14px 26px; font-size: 16px; }
.link-btn { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; padding: 0; }

/* ---------- Landing ---------- */
.lp-hero { max-width: 980px; margin: 0 auto; padding: clamp(56px, 11vh, 120px) 20px 40px; text-align: center; }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--blue); margin: 0 0 14px; }
.lp-hero h1 { font-size: clamp(40px, 7.4vw, 84px); line-height: 1.12; letter-spacing: -.02em; margin: 0; font-weight: 700; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: clamp(17px, 2.1vw, 21px); color: var(--muted); max-width: 720px; margin: 22px auto 0; line-height: 1.5; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 34px; }
.hero-cta .btn:not(.primary) { background: rgba(255,255,255,.6); backdrop-filter: blur(12px); }
[data-theme=dark] .hero-cta .btn:not(.primary) { background: rgba(255,255,255,.06); }
.fine-hero { font-size: 13px; color: var(--faint); margin-top: 18px; }
.section { max-width: 1240px; margin: 0 auto; padding: 40px clamp(16px, 4vw, 48px); }
.section-head { text-align: center; margin-bottom: 30px; }
.section-head h2, .cta-band h2 { font-size: clamp(28px, 4vw, 44px); letter-spacing: -.035em; margin: 0 0 8px; }
.why-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.why { border-radius: var(--r); padding: 22px; }
.why span { font-size: 28px; display: block; margin-bottom: 10px; }
.why b { font-size: 17px; letter-spacing: -.01em; }
.why p { color: var(--muted); margin: 6px 0 0; font-size: 14.5px; }
.cta-band { text-align: center; border-radius: 32px; margin: 30px auto 50px; max-width: 1000px; padding: 50px 24px; }
.cta-band .btn { margin-top: 14px; }
.foot { text-align: center; color: var(--faint); font-size: 13px; padding: 10px 0 40px; }

/* ---------- App cards (landing + dashboard) ---------- */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.app-card { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-content: start; padding: 20px; border-radius: var(--r); text-decoration: none; color: var(--text);
  animation: cardIn .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); transition: transform .45s var(--ease), box-shadow .45s var(--ease); min-height: 150px; }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.app-card:hover { transform: translateY(-4px); box-shadow: inset 1.5px 1.5px 0 rgba(255,255,255,.95), 0 22px 50px -16px color-mix(in srgb, var(--g1) 45%, transparent); }
.app-card:active { transform: scale(.98); }
.app-ic { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; font-size: 26px; grid-row: span 2;
  background: linear-gradient(135deg, var(--g1, #0071e3), var(--g2, #5e5ce6)); box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 10px 22px -10px var(--g1, #0071e3); }
.app-ic.sm { width: 34px; height: 34px; border-radius: 10px; font-size: 17px; grid-row: auto; flex: none; }
.app-txt b { display: block; font-size: 17px; letter-spacing: -.015em; line-height: 1.25; }
.app-txt small { color: var(--muted); font-size: 13.5px; }
.app-desc { grid-column: 1 / -1; color: var(--muted); font-size: 14px; line-height: 1.45; margin-top: 8px; }
.app-stat { grid-column: 1 / -1; font-size: 12.5px; font-weight: 600; color: var(--g1); margin-top: 4px; }
.app-badge { position: absolute; top: 14px; right: 14px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--grad); color: #fff; }
.home-grid .app-card:first-child { grid-column: span 2; background-image: linear-gradient(135deg, color-mix(in srgb, var(--g1) 14%, transparent), color-mix(in srgb, var(--g2) 10%, transparent)); }

/* ---------- Dashboard ---------- */
.home { max-width: 1240px; margin: 0 auto; padding: 30px clamp(16px, 4vw, 48px) 60px; }
.greet { display: flex; align-items: end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.greet .eyebrow { margin-bottom: 4px; color: var(--muted); }
.greet h1 { font-size: clamp(30px, 4.4vw, 44px); letter-spacing: -.035em; margin: 0; }
.greet-stats { display: flex; gap: 26px; padding: 14px 22px; border-radius: 20px; }
.greet-stats:empty { display: none; }
.greet-stats small { display: block; font-size: 12px; color: var(--muted); }
.greet-stats b { font-size: 18px; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.app-search { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 46px; margin-bottom: 20px; max-width: 420px; color: var(--muted); }
.app-search input { flex: 1; border: 0; background: none; outline: none; font-size: 15px; color: var(--text); }
.user-pill { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px 0 7px; border: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.user-pill svg { width: 14px; height: 14px; color: var(--muted); }
.menu-who { padding: 10px 12px 8px; display: grid; }
.menu-who small { color: var(--muted); font-size: 12.5px; }
.menu a.menu-link { display: block; text-decoration: none; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.menu a.menu-link:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
body[data-guest="1"] .no-guest { display: none; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; flex: none; color: #fff; font-weight: 700; letter-spacing: 0;
  background: linear-gradient(135deg, hsl(var(--h) 75% 58%), hsl(calc(var(--h) + 40) 70% 50%)); }
.demo-bar button, .demo-bar a { color: #fff; }

/* ---------- Auth sheet ---------- */
.auth-dlg { width: min(430px, calc(100vw - 24px)); border-radius: 28px; }
.auth { padding: 30px 28px 24px; display: grid; gap: 14px; position: relative; }
.auth h2 { margin: 6px 0 0; font-size: 27px; letter-spacing: -.03em; }
.auth > .muted { margin: -8px 0 0; }
.auth-seg { width: 100%; } .auth-seg button { flex: 1; padding: 8px; }
.auth .field input { font-size: 16px; }
.close-x { position: absolute; top: 14px; right: 14px; }
.pw { position: relative; display: block; }
.pw input { padding-right: 46px !important; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; width: 36px; height: 36px; border-radius: 10px; color: var(--muted); display: grid; place-items: center; }
.auth .remember { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }
.auth .remember input { width: 16px; height: 16px; accent-color: var(--blue); }
.auth .fine { margin-top: 2px; }
.auth .alert { margin: 0; }

/* ---------- App shell ---------- */
.app-top { grid-template-columns: 1fr auto 1fr; }
.back-link { text-decoration: none; min-width: 0; }
.back-link > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.back-ic { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 999px; color: var(--blue); transition: background .3s, transform .3s var(--ease); flex: none; }
.back-link:hover .back-ic { background: rgba(0,113,227,.1); transform: translateX(-2px); }
.space-switch { position: relative; justify-self: center; }
.space-btn { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border: 1px solid var(--line); font-weight: 600; font-size: 14px; max-width: 46vw; }
.space-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-btn svg { width: 14px; height: 14px; color: var(--muted); }
.space-menu { left: 50%; right: auto; transform-origin: top center; translate: -50% 0; min-width: 240px; }
.space-menu button { display: flex; align-items: center; gap: 8px; }
.space-menu button small { margin-left: auto; color: var(--faint); font-size: 12px; }
.space-menu button.on { background: rgba(0,113,227,.1); color: var(--blue); font-weight: 600; }
.invite { display: grid; gap: 6px; padding: 16px; border-radius: 16px; background: rgba(0,113,227,.07); border: 1px dashed rgba(0,113,227,.35); text-align: center; }
.invite small { color: var(--muted); }
.invite b { font-size: 28px; letter-spacing: .14em; }
.invite-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }
.invite-btns .btn { text-decoration: none; padding: 8px 14px; font-size: 13.5px; }
.members { display: grid; gap: 6px; }
.member { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.member > small { color: var(--faint); }
.app-root { max-width: 1240px; margin: 0 auto; padding: 22px clamp(14px, 3vw, 36px) 110px; }
.app-root.in > * { animation: cardIn .6s var(--ease) both; }
.loading-dots { display: flex; gap: 8px; justify-content: center; padding: 80px 0; }
.loading-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); animation: dot 1s ease-in-out infinite; }
.loading-dots i:nth-child(2) { animation-delay: .15s; } .loading-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 50% { transform: translateY(-8px); opacity: .4; } }
dialog.wide { width: min(640px, calc(100vw - 24px)); }
dialog { max-height: calc(100dvh - 24px); overflow-y: auto; }

/* =====================================================================
   UI KIT for app modules (use these classes; do not add per-app CSS files)
   ===================================================================== */
/* Page layout */
.page { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.split > *, .cols-2 > *, .cols-3 > *, .kpis > * { min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(24px, 3vw, 32px); letter-spacing: -.03em; margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.split > .side { position: sticky; top: 86px; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stack { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.row-flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { border-radius: 20px; padding: 16px 18px; display: grid; gap: 2px; }
.kpi small { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi b { font-family: var(--mono); font-size: clamp(20px, 2.4vw, 26px); letter-spacing: -.03em; font-feature-settings: "tnum"; }
.kpi span { font-size: 12.5px; color: var(--faint); }
.kpi.hero { background-image: linear-gradient(135deg, rgba(0,113,227,.16), rgba(191,90,242,.12)); }
.kpi.good b { color: var(--pos); } .kpi.bad b { color: var(--neg); }

/* Lists */
.list { display: grid; grid-template-columns: minmax(0, 1fr); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-radius: 14px; border-bottom: 1px solid var(--line); cursor: default; transition: background .25s; }
.item:last-child { border-bottom: 0; }
.item.click { cursor: pointer; }
.item.click:hover { background: color-mix(in srgb, var(--text) 4.5%, transparent); }
.item .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; flex: none; background: color-mix(in srgb, var(--text) 6%, transparent); }
.item .main { flex: 1; min-width: 0; }
.item .main b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .main small { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .amt { font-family: var(--mono); font-weight: 600; text-align: right; white-space: nowrap; font-feature-settings: "tnum"; }
.item .amt small { display: block; font-family: var(--font); font-weight: 500; color: var(--faint); font-size: 11.5px; }
.item .acts { display: flex; gap: 2px; opacity: .55; transition: opacity .2s; }
.item:hover .acts { opacity: 1; }
.item .acts .icon-btn { width: 34px; height: 34px; }
.item .acts svg { width: 16px; height: 16px; }
.group-label { font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; padding: 14px 8px 4px; }

/* Tags / pills */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.tag.blue { background: rgba(0,113,227,.12); color: var(--blue); }
.tag.green { background: color-mix(in srgb, var(--pos) 14%, transparent); color: var(--pos); }
.tag.red { background: color-mix(in srgb, var(--neg) 13%, transparent); color: var(--neg); }
.tag.amber { background: color-mix(in srgb, var(--amber) 18%, transparent); color: color-mix(in srgb, var(--amber) 70%, #000); }
[data-theme=dark] .tag.amber { color: var(--amber); }
.tag.purple { background: rgba(175,82,222,.13); color: #a04fd0; }

/* Progress bar */
.bar { height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, transparent); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--grad); transition: width .8s var(--ease); }
.bar.thin { height: 5px; }

/* Tabs (use .seg from app.css for small toggles) */
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 1px solid var(--line); background: rgba(255,255,255,.5); padding: 8px 15px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap; transition: all .3s var(--ease); }
[data-theme=dark] .tabs button { background: rgba(255,255,255,.05); }
.tabs button.on { background: var(--text); color: var(--bg); border-color: transparent; }

/* Forms inside dialogs and cards */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.field select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 36px; }
.field .hint { font-size: 12px; color: var(--faint); font-weight: 400; }
.radio-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.radio-pills label { position: relative; }
.radio-pills input { position: absolute; opacity: 0; pointer-events: none; }
.radio-pills span { display: inline-block; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line2); font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; transition: all .25s var(--ease); }
.radio-pills input:checked + span { background: var(--accent); border-color: transparent; color: #fff; }
.radio-pills input:focus-visible + span { box-shadow: 0 0 0 4px rgba(0,113,227,.2); }
.inline-add { display: flex; gap: 8px; }
.inline-add input { flex: 1; min-width: 0; background: color-mix(in srgb, var(--text) 5%, transparent); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: none; }
.inline-add input:focus { border-color: var(--blue); }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text); font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
textarea.big { min-height: 160px; font-family: var(--mono); font-size: 13px; }

/* Mobile floating add button (module adds <button class="fab">) */
.fab { position: fixed; right: 18px; bottom: calc(20px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; box-shadow: 0 14px 30px -10px rgba(0,113,227,.7); display: none; place-items: center; z-index: 25; }
.fab svg { width: 24px; height: 24px; }

/* Misc */
.note { padding: 12px 14px; border-radius: 14px; background: rgba(0,113,227,.07); font-size: 14px; color: var(--text); }
.note.warn { background: color-mix(in srgb, var(--amber) 14%, transparent); }
.note.ok { background: color-mix(in srgb, var(--pos) 12%, transparent); }
.big-num { font-family: var(--mono); font-size: clamp(30px, 5vw, 46px); font-weight: 600; letter-spacing: -.04em; font-feature-settings: "tnum"; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--faint); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table td.r, .table th.r { text-align: right; font-family: var(--mono); }
.table-wrap { overflow-x: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .why-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .split > .side { position: static; }
  .cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .nav-links > a { display: none; }
  .nav-links .btn:not(.primary) { padding: 9px 14px; }
  .nav-links .btn.primary { padding: 9px 14px; font-size: 14px; }
  .home-grid .app-card:first-child { grid-column: auto; }
  .app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .app-card { padding: 14px; grid-template-columns: 1fr; min-height: 0; gap: 4px; }
  .app-ic { width: 44px; height: 44px; font-size: 22px; grid-row: auto; margin-bottom: 6px; }
  .app-txt b { font-size: 15px; } .app-txt small { font-size: 12.5px; }
  .app-desc { display: none; }
  .app-badge { top: 10px; right: 10px; font-size: 10px; padding: 2px 7px; }
  .greet-stats { width: 100%; justify-content: space-between; gap: 10px; padding: 12px 16px; }
  .greet-stats b { font-size: 15px; }
  .app-search { max-width: none; }
  .why-grid, .cols-2, .cols-3, .form-grid { grid-template-columns: 1fr; }
  .app-top { grid-template-columns: 1fr auto; padding: 10px 14px; gap: 8px; }
  .app-top .space-switch { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; }
  .app-top .space-btn { max-width: none; width: 100%; justify-content: center; }
  .back-link small { display: none; }
  .fab { display: grid; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px 14px; }
  .item .acts { opacity: 1; }
  .page-head .page-actions .btn.hide-sm { display: none; }
  .user-pill #userName { display: none; }
}
@media (max-width: 380px) { .nav-links .btn:not(.primary) { display: none; } }

.item.sel { background: rgba(0,113,227,.08); }
.aurora { contain: strict; }
.app-top .back-link > span:last-child { display: block !important; }
@media (max-width: 700px) { .toasts { bottom: calc(92px + env(safe-area-inset-bottom)); } }
.dlg { grid-template-columns: minmax(0, 1fr); }
.dlg-actions { flex-wrap: wrap; }
.member > span:not(.avatar) { flex: 1; min-width: 0; }
.member > span.avatar { flex: none; }
