:root {
  --brand: #4338ca; --brand-dark: #3730a3; --brand-soft: #e0e7ff;
  --bg: #f4f7f6; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --red: #dc2626; --red-soft: #fee2e2; --amber: #b45309; --amber-soft: #fef3c7;
  --green: #15803d; --green-soft: #dcfce7; --blue: #1d4ed8; --blue-soft: #dbeafe;
  --radius: 10px; --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: .8rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* buttons & inputs */
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); padding: .5rem .9rem; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
button:hover, .btn:hover { border-color: #cbd5e1; background: #f9fafb; }
.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.danger { color: var(--red); border-color: #fecaca; }
.danger:hover { background: var(--red-soft); }
.danger-fill { background: var(--red); border-color: var(--red); }
.danger-fill:hover { background: #b91c1c; border-color: #b91c1c; }
.wa { background: #16a34a; border-color: #16a34a; color: #fff; }
.wa:hover { background: #15803d; }
.sm { padding: .3rem .6rem; font-size: .85rem; }
.lg { padding: .75rem 1.3rem; font-size: 1.05rem; }
button:disabled { opacity: .55; cursor: default; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea { font: inherit; width: 100%; padding: .5rem .65rem; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: .75rem; }
.check { display: flex; gap: .5rem; align-items: center; color: var(--text); font-size: .95rem; }
.check input, input[type=checkbox], input[type=radio] { width: auto; }
.err { color: var(--red); font-size: .9rem; min-height: 1.2em; }

/* cards & tables */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f9fafb; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f9fafb; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }

/* chips */
.chip { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #f3f4f6; color: #374151; white-space: nowrap; }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.teal { background: var(--brand-soft); color: var(--brand-dark); }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tabs button { border-radius: 999px; padding: .35rem .8rem; font-size: .9rem; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs .count { background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 .4rem; font-size: .78rem; }

/* staff layout */
.topbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-in { max-width: 1200px; margin: 0 auto; padding: .55rem 1rem; display: flex; align-items: center; gap: 1rem; }
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; }
.logo { width: 28px; height: 28px; border-radius: 7px; background: #fff; display: grid; place-items: center; flex: none; }
.logo svg { width: 18px; height: 18px; }
.nav { display: flex; gap: .2rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { color: #e0e7ff; text-decoration: none; padding: .4rem .7rem; border-radius: 7px; white-space: nowrap; font-size: .95rem; position: relative; }
.nav a.on, .nav a:hover { background: rgba(255,255,255,.15); color: #fff; }
.badge { background: #f59e0b; color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .38rem; margin-left: .25rem; font-weight: 700; }
.topbar .who { font-size: .85rem; color: #e0e7ff; white-space: nowrap; }
.topbar button { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.topbar button:hover { background: rgba(255,255,255,.12); }
main { max-width: 1200px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.page-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.warn-banner { background: var(--amber-soft); color: var(--amber); padding: .6rem 1rem; text-align: center; font-size: .9rem; }

/* dashboard tiles */
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; text-decoration: none; color: var(--text); display: block; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--brand); }
.tile .n { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.tile .l { color: var(--muted); font-size: .85rem; }
.tile.red .n { color: var(--red); } .tile.amber .n { color: var(--amber); } .tile.blue .n { color: var(--blue); } .tile.teal .n { color: var(--brand); }
.list-row { display: flex; gap: .6rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }

/* order sheet */
.add-line { display: grid; grid-template-columns: 2.2fr .7fr 1.4fr 1.4fr auto; gap: .5rem; align-items: end; }
.supplier-head td { background: #eef2ff; font-weight: 600; color: var(--brand-dark); }
td select.status { width: auto; padding: .25rem .4rem; font-size: .85rem; }
tr.done td { color: var(--muted); }
tr.done td.name { text-decoration: line-through; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); gap: .5rem; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-head .x { border: 0; font-size: 1.4rem; line-height: 1; padding: .2rem .5rem; }
.modal-body { padding: 1.1rem; }
.modal-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .8rem 1.1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
#toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 60; }
#toast div { background: #111827; color: #fff; padding: .6rem 1rem; border-radius: 8px; margin-top: .4rem; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
#toast div.bad { background: var(--red); }
.rx-img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
fieldset { border: 1px dashed #cbd5e1; border-radius: 8px; padding: .8rem; margin: .5rem 0 .8rem; }
legend { font-size: .85rem; color: var(--muted); padding: 0 .3rem; }

/* public site */
.pub-head { background: linear-gradient(135deg, #4338ca, #6d28d9); color: #fff; }
.pub-head-in { max-width: 980px; margin: 0 auto; padding: .8rem 1rem; display: flex; align-items: center; gap: .8rem; }
.pub-head .login-link { white-space: nowrap; color: #e0e7ff; text-decoration: none; font-size: .9rem; border: 1px solid rgba(255,255,255,.35); padding: .3rem .7rem; border-radius: 7px; }
.hero { max-width: 980px; margin: 0 auto; padding: 2.2rem 1rem 2.6rem; }
.hero h1 { font-size: 2rem; margin-bottom: .4rem; }
.hero p { color: #e0e7ff; margin: 0 0 1.2rem; max-width: 560px; }
.hero .btn { border: 0; }
.hero .btn.light { background: rgba(255,255,255,.15); color: #fff; }
.pub-main { max-width: 980px; margin: -1.4rem auto 0; padding: 0 1rem 3rem; position: relative; }
.steps { counter-reset: s; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; }
.steps div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; }
.steps b { display: block; margin-bottom: .2rem; }
.steps b::before { counter-increment: s; content: counter(s); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); font-size: .8rem; margin-right: .4rem; }
.result { display: flex; gap: .6rem; align-items: center; padding: .6rem .2rem; border-bottom: 1px solid var(--line); }
.result:last-child { border-bottom: 0; }
.search-pop { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,.12); z-index: 10; max-height: 300px; overflow-y: auto; }
.search-pop .result { padding: .55rem .7rem; cursor: pointer; }
.search-pop .result:hover { background: #eef2ff; }
.rel { position: relative; }
.cart-line, .cart-head { display: grid; grid-template-columns: 1fr 160px 70px auto; gap: .5rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.cart-head { padding: 0 0 .2rem; }
.cart-head span:last-child { width: 34px; }
.drop { border: 2px dashed #cbd5e1; border-radius: 10px; padding: 1rem; text-align: center; cursor: pointer; color: var(--muted); }
.drop:hover { border-color: var(--brand); color: var(--brand); }
.timeline { display: flex; gap: .3rem; margin: 1rem 0; }
.timeline div { flex: 1; text-align: center; font-size: .8rem; color: var(--muted); padding-top: .5rem; border-top: 4px solid var(--line); }
.timeline div.on { border-color: var(--brand); color: var(--brand-dark); font-weight: 600; }
.code-big { font-size: 2rem; font-weight: 800; letter-spacing: .15em; color: var(--brand); }
footer.pub .row { justify-content: center; }
footer.pub { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem; }

#o-form .err { margin: .3rem 0 0; min-height: 0; }
.grid + .card { margin-top: 1rem; }

.stepper { display: flex; align-items: center; }
.stepper button { padding: .45rem .65rem; font-weight: 700; }
.stepper button:first-child { border-radius: 8px 0 0 8px; }
.stepper button:last-child { border-radius: 0 8px 8px 0; }
.stepper input { width: 52px; text-align: center; border-radius: 0; border-left: 0; border-right: 0; padding: .45rem .2rem; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.cart-line, .cart-head { grid-template-columns: 1fr 160px 130px auto; }
.bill-table td { vertical-align: middle; padding: .4rem .45rem; }
.bill-table input { padding: .35rem .5rem; }
.bill-total { font-size: 1.25rem; font-weight: 700; color: var(--brand-dark); padding: .35rem 0; }
.bill-check { background: var(--blue-soft); padding: .6rem .8rem; border-radius: 8px; margin-bottom: .8rem; }

@media (max-width: 760px) {
  .cart-line { grid-template-columns: 1fr 130px auto; }

  .cart-line > div:first-child { grid-column: 1 / -1; }
  .cart-head { display: none; }
  .page-head > button, .page-head > .btn { font-size: .85rem; padding: .4rem .6rem; }
  .pub-head .brand span { font-size: .95rem; }
  .pub-head-in { gap: .5rem; }
  .add-line { grid-template-columns: 1fr 1fr; }
  .add-line .wide { grid-column: 1 / -1; }
  .topbar-in { flex-wrap: wrap; gap: .5rem; }
  .nav { order: 3; flex-basis: 100%; }
  .topbar .who { display: none; }
  .hero h1 { font-size: 1.6rem; }
  .hide-sm { display: none; }
}
@media print {
  .topbar, .no-print, #toast { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .table-wrap { border: 0; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* property manager */
.chip.purple { background: #ede9fe; color: #6d28d9; }
.chip.gray { background: #f3f4f6; color: #4b5563; }
.prop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .8rem; }
.prop-card { background: #fff; border: 1px solid var(--line); border-left: 5px solid #9ca3af; border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: .35rem; }
.prop-card:hover { border-color: var(--brand); }
.prop-card.st-occupied { border-left-color: var(--green); }
.prop-card.st-vacant { border-left-color: var(--red); }
.prop-card.st-notice { border-left-color: var(--amber); }
.prop-card.st-maint { border-left-color: var(--blue); }
.prop-card h3 { margin: 0; font-size: 1.05rem; }
.prop-card .meta { color: var(--muted); font-size: .85rem; }
.prop-card .tenant-line { font-size: .9rem; border-top: 1px dashed var(--line); padding-top: .4rem; margin-top: .2rem; }
.group-title { margin: 1.2rem 0 .5rem; font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }
.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .1rem 1rem; }
.details div { padding: .4rem 0; border-bottom: 1px solid #f3f4f6; }
.details dt { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.details dd { margin: 0; font-weight: 500; word-break: break-word; }
.details dd.none { color: #d1d5db; font-weight: 400; }
.details dd.req-missing { color: var(--red); font-weight: 400; }
.section-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; flex-wrap: wrap; }
.section-head h2 { margin: 0; flex: 1; }
.missing-box { background: var(--red-soft); color: #991b1b; border-radius: 8px; padding: .6rem .8rem; margin-bottom: .8rem; font-size: .9rem; }
.ok-box { background: var(--green-soft); color: var(--green); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .8rem; font-size: .9rem; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; }
.doc { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fafafa; position: relative; }
.doc a.thumb { display: grid; place-items: center; height: 100px; background: #f3f4f6; text-decoration: none; font-size: 2rem; }
.doc img { width: 100%; height: 100px; object-fit: cover; display: block; }
.doc .cap { padding: .3rem .45rem; font-size: .78rem; display: flex; gap: .3rem; align-items: center; }
.doc .cap span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .cap button { padding: 0 .35rem; border: 0; background: none; color: var(--red); font-size: 1rem; }
.doc-need { border: 2px dashed #fca5a5; border-radius: 8px; display: grid; place-items: center; text-align: center; padding: .5rem; color: var(--red); font-size: .8rem; min-height: 125px; cursor: pointer; background: #fff; }
.doc-need:hover { background: var(--red-soft); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 .8rem; }
.form-grid .full { grid-column: 1 / -1; }
.req::after { content: ' *'; color: var(--red); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: .4rem; }
.bar > div { height: 100%; background: var(--green); }
.login-wrap { max-width: 400px; margin: 8vh auto; padding: 0 1rem; }
.login-wrap .logo-big { width: 56px; height: 56px; border-radius: 14px; background: var(--brand); display: grid; place-items: center; margin: 0 auto 1rem; }
.login-wrap .logo-big svg { width: 32px; height: 32px; }
@media (max-width: 760px) {
  .toolbar input, .toolbar select { flex: 1; min-width: 0; }
  .details { grid-template-columns: 1fr 1fr; }
}
.grid-lists { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
@media (max-width: 760px) { .grid-lists { grid-template-columns: 1fr; } }

/* categories, photos */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .8rem; }
.cat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow); text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: .45rem; }
.cat-card:hover { border-color: var(--brand); }
.cat-ic { font-size: 1.5rem; line-height: 1; }
.cat-name { font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-n { font-size: 1.6rem; font-weight: 700; color: var(--brand); line-height: 1; }
.cat-card .bar { margin-top: 0; }
.prop-card { overflow: hidden; }
.prop-card .cover { display: block; margin: -.85rem -1rem .35rem; width: calc(100% + 2rem); height: 150px; object-fit: cover; background: #eef2ff; }
.prop-card .cover.none { display: grid; place-items: center; height: 70px; font-size: 2rem; }
.gallery { display: flex; gap: .5rem; overflow-x: auto; margin-bottom: 1rem; scroll-snap-type: x mandatory; }
.gallery a { flex: none; scroll-snap-align: start; }
.gallery img { height: 220px; max-width: 85vw; width: auto; border-radius: var(--radius); object-fit: cover; display: block; border: 1px solid var(--line); }
.gallery-empty { display: flex; align-items: center; gap: .8rem; justify-content: center; border: 2px dashed #c7d2fe; border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1rem; cursor: pointer; color: var(--brand-dark); background: #fff; }
.gallery-empty > span:first-child { font-size: 2rem; }
.gallery-empty:hover { background: #eef2ff; }
@media (max-width: 760px) { .gallery img { height: 180px; } .prop-card .cover { height: 130px; } }
@media (max-width: 760px) { .toolbar #search, .toolbar #ts { flex-basis: 100%; } }

/* hostel / PG, lease, food */
.chip.purple, .tile.purple .n { color: #6d28d9; } .chip.purple { background: #ede9fe; }
.prop-card.st-partly { border-left-color: #7c3aed; }
.beds-summary { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .6rem; }
.beds-summary div { background: #f9fafb; border: 1px solid var(--line); border-radius: 8px; padding: .4rem .8rem; text-align: center; min-width: 74px; }
.beds-summary b { display: block; font-size: 1.2rem; }
.beds-summary span { font-size: .75rem; color: var(--muted); }
.beds-summary .ok b { color: var(--green); } .beds-summary .free b { color: var(--red); }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .7rem; }
.room { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; background: #fff; display: flex; flex-direction: column; gap: .35rem; }
.room.full { background: #f0fdf4; border-color: #bbf7d0; }
.room-head { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.room-head .x-btn { border: 0; padding: .1rem .3rem; background: none; }
.bed { display: flex; align-items: center; gap: .45rem; padding: .35rem .5rem; border-radius: 7px; font-size: .9rem; text-decoration: none; color: var(--text); }
.bed.taken { background: #eef2ff; }
.bed.taken:hover { background: #e0e7ff; }
.bed.free { border: 1px dashed #fca5a5; background: #fff; color: var(--red); justify-content: center; width: 100%; font-size: .85rem; }
.bed.free:hover { background: var(--red-soft); }
.bed-no { background: #fff; border: 1px solid #c7d2fe; border-radius: 5px; padding: 0 .35rem; font-size: .75rem; font-weight: 700; color: var(--brand-dark); min-width: 22px; text-align: center; }
.bed-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.red { background: var(--red); } .dot.green { background: var(--green); } .dot.amber { background: #f59e0b; }
.profit { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; background: var(--green-soft); border-radius: 10px; padding: .7rem 1rem; margin-bottom: .8rem; }
.profit.loss { background: var(--red-soft); }
.profit div { display: flex; flex-direction: column; }
.profit b { font-size: 1.15rem; }
.profit div:last-child b { color: var(--green); } .profit.loss div:last-child b { color: var(--red); }
.profit .op { font-size: 1.3rem; color: var(--muted); }
.plan-row { display: grid; grid-template-columns: 1fr 130px auto; gap: .4rem; margin-bottom: .4rem; }
@media (max-width: 760px) { .plan-row { grid-template-columns: 1fr 100px auto; } .room-grid { grid-template-columns: 1fr; } }
[hidden] { display: none !important; }
