@font-face { font-family: Vazirmatn; src: url(/static/fonts/Vazirmatn-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(/static/fonts/Vazirmatn-Medium.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(/static/fonts/Vazirmatn-Bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #f4f6f5; --card: #fff; --ink: #1c2421; --muted: #66736e; --line: #e2e7e5;
  --brand: #0f766e; --brand-ink: #fff; --brand-soft: #e6f4f2;
  --warn: #b45309; --warn-soft: #fef3e2; --ok: #15803d; --ok-soft: #e8f6ec;
  --danger: #b91c1c; --danger-soft: #fdecec;
  --r: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; font-family: Vazirmatn, Tahoma, system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.6; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ---------- buttons ---------- */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: .6rem 1rem; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none; }
.btn.small { min-height: 38px; padding: .35rem .8rem; font-size: .9rem; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
.btn.primary:disabled { opacity: .6; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.icon { width: 48px; padding: 0; font-size: 1.3rem; }
.btn:focus-visible, .chip:focus-visible, .card:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(15,118,110,.35); outline-offset: 2px; }

/* ---------- login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, #e6f4f2, #f4f6f5 60%); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 20px; padding: 2rem 1.5rem; box-shadow: var(--shadow); text-align: center; }
.login-card h1 { margin: .5rem 0 0; font-size: 1.3rem; }
.login-card form { text-align: right; margin-top: 1.2rem; }
.login-logo { width: 56px; height: 56px; margin: 0 auto; border-radius: 16px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 1.8rem; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--brand); color: #fff; padding-top: env(safe-area-inset-top); }
.topbar-inner { max-width: 960px; margin: 0 auto; padding: .7rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.topbar h1 { margin: 0; font-size: 1.1rem; }
.topbar .sub { font-size: .8rem; opacity: .85; }
.who { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.who small { opacity: .8; }
.who .btn { color: #fff; border-color: rgba(255,255,255,.4); }
.tabs { max-width: 960px; margin: 0 auto; display: flex; gap: .25rem; padding: 0 .75rem; overflow-x: auto; }
.tab { background: none; border: 0; color: rgba(255,255,255,.8); padding: .55rem .8rem; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; text-decoration: none; font-size: .95rem; }
.tab.active { color: #fff; border-bottom-color: #fff; font-weight: 700; }

/* ---------- project switch ---------- */
.sheet-switch { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .3rem; background: #e3e9e7; padding: .3rem; border-radius: 14px; margin-bottom: .8rem; }
.sw { border: 0; background: transparent; border-radius: 11px; min-height: 44px; font-weight: 700; cursor: pointer; color: var(--muted); font-size: 1rem; }
.sw.active { background: var(--card); color: var(--brand); box-shadow: var(--shadow); }

/* ---------- list ---------- */
.wrap { max-width: 960px; margin: 0 auto; padding: 1rem 1rem 6.5rem; }
.toolbar { display: flex; gap: .5rem; }
.toolbar input { flex: 1; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 0 1rem; background: var(--card); }
.chips { display: flex; gap: .5rem; margin: .8rem 0; overflow-x: auto; padding-bottom: 2px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .35rem .9rem; min-height: 38px; cursor: pointer; white-space: nowrap; }
.chip b { font-weight: 500; color: var(--muted); margin-inline-start: .2rem; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.active b { color: #cfd8d4; }
.status { padding: .8rem 1rem; border-radius: 12px; background: var(--card); color: var(--muted); text-align: center; }
.status.error { background: var(--danger-soft); color: var(--danger); }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: .65rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .cards { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.cards > li { min-width: 0; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: .9rem 1rem; cursor: pointer; border: 1px solid transparent; display: flex; flex-direction: column; gap: .35rem; text-align: right; width: 100%; min-width: 0; overflow: hidden; }
.card:hover { border-color: var(--line); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-name { font-weight: 700; font-size: 1.02rem; min-width: 0; overflow-wrap: anywhere; }
.card-top .badge { flex-shrink: 0; }
.card-line { font-size: .9rem; color: var(--muted); display: flex; gap: .4rem; align-items: baseline; min-width: 0; }
.card-line .v { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-line .ltr { direction: ltr; unicode-bidi: isolate; }
.card-addr { font-size: .88rem; color: var(--muted); line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.badge { font-size: .75rem; border-radius: 999px; padding: .1rem .55rem; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.missing { font-size: .8rem; color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 2rem 0; }

.fab { position: fixed; inset-inline-start: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 6; background: var(--brand); color: #fff; border: 0; border-radius: 999px; padding: .85rem 1.3rem; font-weight: 700; box-shadow: 0 6px 18px rgba(15,118,110,.35); cursor: pointer; font-size: 1rem; }

/* ---------- editor ---------- */
dialog#editor { border: 0; padding: 0; width: 100%; max-width: 560px; max-height: 100%; height: 100%; margin: 0 auto; background: var(--bg); color: var(--ink); }
@media (min-width: 720px) { dialog#editor { height: auto; max-height: 92vh; margin: auto; border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.25); } }
dialog#editor::backdrop { background: rgba(10,20,18,.45); }
#form { display: flex; flex-direction: column; height: 100%; max-height: inherit; }
.ed-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: calc(.5rem + env(safe-area-inset-top)) .75rem .5rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.ed-head h2 { margin: 0; font-size: 1.05rem; }
.ed-spacer { width: 70px; }
.ed-body { padding: 1rem; overflow-y: auto; flex: 1; }
.ed-foot { padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); }
.ed-foot .btn { min-height: 52px; font-size: 1.05rem; }

.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-weight: 500; margin-bottom: .3rem; font-size: .95rem; }
.field i { color: var(--danger); font-style: normal; }
.field input:not([type=radio]), .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; background: var(--card); min-height: 48px; font-size: 16px; }
.field textarea { resize: vertical; line-height: 1.8; }
.field input[dir=ltr] { text-align: left; }
.field.invalid input, .field.invalid textarea, .field.invalid .affix { border-color: var(--danger); }
.err { color: var(--danger); font-size: .85rem; display: block; min-height: 0; }
.err:empty { display: none; }
.group { border: 1px solid var(--line); border-radius: var(--r); padding: .8rem 1rem .2rem; margin: 0 0 1rem; background: rgba(255,255,255,.5); }
.group legend { padding: 0 .4rem; font-weight: 700; color: var(--brand); }
.affix { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--card); overflow: hidden; }
.affix b { padding: 0 .2rem 0 .9rem; color: var(--muted); font-weight: 500; }
.field .affix input { border: 0; border-radius: 0; padding-left: .2rem; }
.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: -.4rem 0 1rem; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; }
.seg input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 700; }
.seg input:focus-visible + span { outline: 3px solid rgba(15,118,110,.35); }

.alert { background: var(--danger-soft); color: var(--danger); border-radius: 12px; padding: .7rem 1rem; margin-bottom: 1rem; font-size: .92rem; }

/* ---------- log ---------- */
.log { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.log li { background: var(--card); border-radius: 12px; padding: .7rem 1rem; box-shadow: var(--shadow); font-size: .9rem; }
.log .meta { color: var(--muted); font-size: .8rem; }
.log .proj { display: inline-block; background: var(--brand-soft); color: var(--brand); border-radius: 6px; padding: 0 .4rem; font-size: .75rem; font-weight: 700; margin-inline-end: .3rem; }
.log .diff { margin-top: .2rem; word-break: break-word; }
.log del { color: var(--danger); text-decoration: line-through; }
.log ins { color: var(--ok); text-decoration: none; }

.toast { position: fixed; bottom: calc(5.5rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7rem 1.2rem; border-radius: 12px; z-index: 50; box-shadow: var(--shadow); max-width: calc(100% - 2rem); text-align: center; }
.toast.error { background: var(--danger); }

@media (max-width: 420px) { .fab span { display: none; } .fab { padding: .8rem 1.1rem; font-size: 1.3rem; } .who-name { display: none; } }
