@font-face { font-family: 'Yekan'; src: url('/fonts/yekan-regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Yekan'; src: url('/fonts/yekan-bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --bg: #f3f1ec; --card: #ffffff; --ink: #14192b; --muted: #4f566b; --line: #e4e1d9;
  --brand: #1d4a87; --brand-dark: #12305c; --brand-deep: #0a1830; --brand-soft: #e3ebf7; --accent: #c9a24a;
  --danger: #b42318; --danger-soft: #fde8e6; --warn: #8a4b08; --warn-soft: #fdf1da; --ok: #05603a; --ok-soft: #dcf5e8; --info: #1b4b8f; --info-soft: #e3edfb;
  --field: #fbfaf7; --topbar: rgba(255, 255, 255, .92); --seg: #e7e4dc; --bar: #e4e1d9; --brand-soft-hover: #d3dff2; --chip-neutral: #ece9e1; --line-strong: #c9c5b8;
  --radius: 18px; --tabbar: 72px; --shadow: 0 1px 2px rgba(20, 25, 43, .06), 0 8px 24px rgba(20, 25, 43, .06);
}
* { box-sizing: border-box; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: 'Yekan', Tahoma, sans-serif; font-size: 1rem; line-height: 1.75;
  -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.5rem; line-height: 1.5; }
h2 { font-size: 1.1rem; margin: 26px 0 12px; display: flex; align-items: center; gap: 10px; }
h2::before { content: ''; width: 6px; height: 22px; border-radius: 3px; background: var(--accent); flex: none; }
h3 { font-size: 1.05rem; margin-bottom: 4px; }
a { color: var(--brand-dark); }
img { max-width: 100%; }

.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5; background: var(--topbar); backdrop-filter: blur(10px); color: var(--ink); padding: 8px 16px; min-height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.2rem; font-weight: 700; }
main { flex: 1; width: 100%; max-width: 780px; margin: 0 auto; padding: 18px 16px calc(var(--tabbar) + 34px); }
.topactions { display: flex; align-items: center; gap: 8px; }
.topbtn { min-height: 48px; min-width: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 16px; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; position: relative; }
.topbtn:hover { background: var(--brand-soft); }
.topbtn svg { width: 24px; height: 24px; fill: currentColor; }
.topbar .badge { top: -6px; inset-inline-start: auto; inset-inline-end: -6px; margin: 0; }

/* bottom tab bar on phones, dark side rail on wide screens */
.tabbar {
  position: fixed; bottom: 10px; right: 10px; left: 10px; z-index: 6; height: var(--tabbar); background: var(--card); border-radius: 24px; box-shadow: 0 10px 34px rgba(10, 24, 48, .25);
  display: flex; justify-content: space-around; align-items: center; padding: 6px; border: 1px solid var(--line);
}
.sidebrand { display: none; }
.tab {
  flex: 1; min-width: 44px; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  text-decoration: none; color: var(--muted); font-size: 1rem; line-height: 1.3; position: relative; font-weight: 700; border-radius: 18px;
}
.tab svg { width: 26px; height: 26px; fill: currentColor; }
.tab[aria-current="page"] { color: #fff; background: var(--brand); }
.badge {
  position: absolute; top: 2px; inset-inline-start: 50%; margin-inline-start: 6px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px;
  background: var(--danger); color: #fff; font-size: 1rem; line-height: 24px; text-align: center; font-weight: 700; border: 2px solid #fff;
}
@media (min-width: 900px) {
  .shell { padding-inline-start: 250px; }
  .tabbar { top: 0; bottom: 0; left: auto; right: 0; width: 250px; height: auto; flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 6px; padding: 18px 14px; border-radius: 0; border: 0; background: var(--brand-deep); box-shadow: none; }
  .sidebrand { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 700; font-size: 1.15rem; padding: 6px 8px 22px; }
  .sidebrand img { width: 44px; height: 44px; border-radius: 12px; }
  .tab { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 8px 14px; min-height: 52px; color: #bfdad6; }
  .tab:hover { background: rgba(255, 255, 255, .08); color: #fff; }
  .tab[aria-current="page"] { background: #fff; color: var(--brand-deep); }
  .tab .badge { position: static; margin: 0; border-color: var(--brand-deep); }
  main { padding: 28px 28px 40px; max-width: 860px; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card.hero { background: linear-gradient(135deg, #1d4a87 0%, #0a1830 100%); color: #fff; border: 0; position: relative; overflow: hidden; }
.card.hero::after { content: ''; position: absolute; inset-inline-start: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255, 255, 255, .07); }
.card.hero .muted { color: #d6efea; }
.muted { color: var(--muted); }
.big { font-size: 1.75rem; font-weight: 700; line-height: 1.4; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack > * + * { margin-top: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .big { font-size: 1.25rem; }
.list { list-style: none; padding: 0; margin: 0; }
.list > li { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(16, 40, 38, .04); }
.sep { border-top: 1px solid var(--line); margin: 12px 0; }
main .list a, main .tile, main .seg a { text-decoration: none; }
main .list a { color: var(--ink); font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; min-width: 48px; padding: 8px 20px;
  border: 0; border-radius: 14px; background: var(--brand); color: #fff; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; box-shadow: 0 4px 12px rgba(29, 74, 135, .3);
}
.btn:hover { filter: brightness(.92); }
.btn.secondary { background: var(--brand-soft); color: var(--brand-dark); box-shadow: none; }
.btn.secondary:hover { background: var(--brand-soft-hover); }
.card.hero .btn.secondary { background: rgba(255, 255, 255, .95); color: #12305c; }
.btn.danger { background: var(--danger); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--brand-dark); border: 1.5px solid var(--line-strong); box-shadow: none; }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.linkbtn { display: inline-flex; align-items: center; min-height: 48px; padding: 0 6px; font: inherit; font-weight: 700; background: none; border: 0; color: var(--brand-dark); text-decoration: none; cursor: pointer; }

label.field { display: block; margin-bottom: 16px; font-weight: 700; }
label.field > span { display: block; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=tel], input[type=search], select, textarea {
  width: 100%; min-height: 50px; padding: 10px 14px; border: 1.5px solid var(--line-strong); border-radius: 14px; background: var(--field); color: var(--ink); font: inherit; font-weight: 400;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(29, 74, 135, .35); outline-offset: 1px; border-color: var(--brand); background: var(--card); }
.btn:focus-visible, .tab:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input[type=file] { width: 100%; min-height: 48px; padding: 10px 0; font: inherit; }
.checkrow { display: flex; align-items: center; gap: 12px; min-height: 48px; font-weight: 400; cursor: pointer; }
.checkrow input { width: 26px; height: 26px; flex: none; accent-color: var(--brand); }
.hint { color: var(--muted); font-weight: 400; display: block; margin-top: 4px; }
.err { color: var(--danger); font-weight: 700; margin: 8px 0; }

.chip { display: inline-block; padding: 2px 14px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; line-height: 1.7; }
.chip.new, .chip.pending { background: var(--warn-soft); color: var(--warn); }
.chip.in_progress { background: var(--info-soft); color: var(--info); }
.chip.done, .chip.approved, .chip.open { background: var(--ok-soft); color: var(--ok); }
.chip.rejected, .chip.closed { background: var(--danger-soft); color: var(--danger); }
.chip.s-paid { background: var(--ok-soft); color: var(--ok); }
.chip.s-pending { background: var(--info-soft); color: var(--info); }
.chip.s-unpaid, .chip.s-not_issued { background: var(--chip-neutral); color: var(--muted); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--danger); margin-inline-end: 8px; vertical-align: middle; }
.owes { color: var(--danger); font-weight: 700; }
.credit { color: var(--ok); font-weight: 700; }

.seg { display: flex; gap: 4px; background: var(--seg); padding: 5px; border-radius: 18px; margin-bottom: 16px; }
.seg a { flex: 1; min-height: 48px; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-weight: 700; border-radius: 14px; padding: 0 6px; }
.seg a[aria-current="page"] { background: var(--card); color: var(--brand-dark); box-shadow: 0 2px 8px rgba(16, 40, 38, .14); }

.bar { height: 14px; border-radius: 7px; background: var(--bar); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #4a8be0, #1d4a87); border-radius: 7px; }
.toast { position: fixed; inset-inline: 16px; bottom: calc(var(--tabbar) + 30px); z-index: 20; background: var(--brand-deep); color: #fff; padding: 14px 18px; border-radius: 16px; text-align: center; font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.toast.error { background: var(--danger); }
@media (min-width: 900px) { .toast { bottom: 24px; inset-inline: auto; inset-inline-start: 24px; min-width: 300px; } }
.photo { display: block; max-height: 280px; border-radius: 14px; border: 1px solid var(--line); margin-top: 8px; }
.login { max-width: 440px; margin: 0 auto; padding: 40px 16px; }
.login .logo { width: 84px; height: 84px; margin: 0 auto 14px; display: block; border-radius: 22px; box-shadow: var(--shadow); }
.login h1 { text-align: center; }
.login p { text-align: center; }
.timeline { list-style: none; padding: 0; margin: 8px 0 0; border-inline-start: 3px solid var(--line-strong); }
.timeline li { padding: 6px 16px 12px; position: relative; }
.timeline li::before { content: ''; position: absolute; inset-inline-start: -9px; top: 14px; width: 15px; height: 15px; border-radius: 50%; background: var(--brand); border: 3px solid var(--bg); }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }
details > summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-weight: 700; }
.nowrap { white-space: nowrap; }

/* tiles (menu and quick actions) */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; min-height: 112px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink); font-weight: 700; line-height: 1.5; }
.tile:hover { border-color: var(--brand); }
.tile .ico { width: 48px; height: 48px; border-radius: 14px; background: var(--brand-soft); display: grid; place-items: center; }
.tile .ico svg { width: 26px; height: 26px; fill: var(--brand-dark); }
.tile .badge { top: 10px; inset-inline-start: auto; inset-inline-end: 10px; margin: 0; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick .tile { min-height: 96px; align-items: center; text-align: center; padding: 12px 6px; gap: 6px; }
.greeting { display: flex; flex-direction: column; gap: 2px; }
.greeting .date { color: var(--muted); }
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed p { margin: 2px 0; }

.notice { border-color: #e6bf6f; background: var(--warn-soft); }
.notice.charge_waiting { border-color: #a9c3ec; background: var(--info-soft); }
.ltr { direction: ltr; text-align: right; unicode-bidi: plaintext; }
.picker { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pick-btn { position: relative; overflow: hidden; }
.pick-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
@media print {
  .topbar, .tabbar, .noprint, .toast { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .shell { padding: 0 !important; }
  .card, .list > li { break-inside: avoid; box-shadow: none; }
}

main a { display: inline-flex; align-items: center; min-height: 48px; min-width: 48px; }

.toptitle { display: flex; align-items: center; gap: 10px; min-width: 0; }
.toptitle h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loading { text-align: center; color: var(--muted); padding: 10px; }
.callrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.btn.call svg { width: 22px; height: 22px; fill: currentColor; }
@media (min-width: 900px) {
  form.card { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
  form.card > :not(label.field) { grid-column: 1 / -1; }
  form.card > label.field:has(textarea), form.card > label.field:has(input[type=file]) { grid-column: 1 / -1; }
}
@media (max-width: 520px) { .topbtn .lbl { display: none; } .topbtn[data-back] { padding: 0 12px; } }
:root[data-theme="dark"] {
  --bg: #0a1020; --card: #131b30; --ink: #eaeef8; --muted: #a2adc6; --line: #243050; --brand: #2f65b0; --brand-dark: #a9c6f2; --brand-deep: #060b17; --brand-soft: #1a2a4a;
  --danger: #ff9a90; --danger-soft: #3a1b18; --warn: #f2c46f; --warn-soft: #3b2d10; --ok: #7fe3ac; --ok-soft: #10331f; --info: #a5c8ff; --info-soft: #17304f;
  --field: #0e1527; --topbar: rgba(19, 27, 48, .92); --seg: #1a2440; --bar: #26355a; --brand-soft-hover: #243a66; --chip-neutral: #1d2745; --line-strong: #3a4a75;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
  --bg: #0a1020; --card: #131b30; --ink: #eaeef8; --muted: #a2adc6; --line: #243050; --brand: #2f65b0; --brand-dark: #a9c6f2; --brand-deep: #060b17; --brand-soft: #1a2a4a;
  --danger: #ff9a90; --danger-soft: #3a1b18; --warn: #f2c46f; --warn-soft: #3b2d10; --ok: #7fe3ac; --ok-soft: #10331f; --info: #a5c8ff; --info-soft: #17304f;
  --field: #0e1527; --topbar: rgba(19, 27, 48, .92); --seg: #1a2440; --bar: #26355a; --brand-soft-hover: #243a66; --chip-neutral: #1d2745; --line-strong: #3a4a75;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] .notice, :root[data-theme="dark"] .notice.charge_waiting { color: var(--ink); }
.mrow { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mrow:last-child { border-bottom: 0; }
.bar > i.in { background: linear-gradient(90deg, #22b07d, #05603a); }
.bar.out > i { background: linear-gradient(90deg, #f2a900, #c27a00); }
.statlink { text-decoration: none; color: var(--ink); display: block; }
.statlink:hover { border-color: var(--brand); }
.searchbar { display: flex; gap: 8px; }
.searchbar input { flex: 1; }
.msg { background: var(--bg); border: 1px dashed var(--line-strong); border-radius: 14px; padding: 12px 14px; margin: 8px 0; }
input[type=search] { width: 100%; min-height: 50px; padding: 10px 14px; border: 1.5px solid var(--line-strong); border-radius: 14px; background: var(--field); color: var(--ink); font: inherit; }

/* ---- login ---- */
.bare main { max-width: none; padding: 0; }
.auth { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.auth-hero { position: relative; min-height: 40vh; padding: 28px 22px 56px; display: flex; flex-direction: column; justify-content: flex-end; color: #fff;
  background: linear-gradient(180deg, rgba(8, 16, 40, .25) 0%, rgba(8, 16, 40, .88) 100%), url('/img/building.jpg') center 18% / cover; }
.auth-brand { display: flex; align-items: center; gap: 14px; }
.auth-brand img { width: 64px; height: 64px; border-radius: 18px; border: 2px solid rgba(255, 255, 255, .55); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.auth-hero h1 { color: #fff; font-size: 1.7rem; }
.auth-hero p { color: #e3d6b4; margin-top: 2px; }
.auth-panel { position: relative; margin-top: -30px; background: var(--card); border-radius: 30px 30px 0 0; padding: 26px 22px 40px; flex: 1; box-shadow: 0 -12px 34px rgba(10, 24, 48, .18); }
.auth-panel h2 { margin: 0 0 4px; font-size: 1.35rem; }
.auth-panel h2::before { display: none; }
.auth-panel form { margin-top: 18px; }
.pwrow { position: relative; }
.pwrow input { padding-inline-end: 96px; }
.pwtoggle { position: absolute; inset-inline-end: 6px; top: 3px; min-height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--brand-soft); color: var(--brand-dark); font: inherit; font-weight: 700; cursor: pointer; }
.auth-help { color: var(--muted); margin-top: 16px; padding: 14px 16px; background: var(--bg); border-radius: 16px; }
.auth-help strong { color: var(--ink); }
.auth .btn { min-height: 56px; font-size: 1.1rem; }
@media (min-width: 900px) {
  .auth { flex-direction: row; }
  .auth-hero { flex: 1.25; min-height: 100vh; padding: 56px; justify-content: space-between; }
  .auth-hero h1 { font-size: 2.3rem; }
  .auth-panel { flex: 1; margin: 0; border-radius: 0; display: flex; flex-direction: column; justify-content: center; padding: 56px; box-shadow: none; max-width: 560px; }
}
/* ---- home banner and motion ---- */
.banner { position: relative; border-radius: 22px; overflow: hidden; min-height: 150px; padding: 18px 20px; color: #fff; display: flex; flex-direction: column; justify-content: flex-end;
  background: linear-gradient(180deg, rgba(8, 16, 40, .1) 0%, rgba(8, 16, 40, .85) 100%), url('/img/building.jpg') center 22% / cover; box-shadow: var(--shadow); }
.banner h1 { color: #fff; }
.banner .date { color: #e3d6b4; }
main > * { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { main > * { animation: none; } }
.sidebrand img { object-fit: cover; }

.shell.bare { padding-inline-start: 0; }
