/* Kish Housing Employee Portal — clean, large-control, phone-first UI */
:root {
  --brand: #1d4e89; --brand-dark: #143a68; --accent: #2e8b57;
  --bg: #f4f6f9; --card: #ffffff; --line: #dfe5ec;
  --text: #1c2733; --muted: #5b6b7c; --danger: #b03030; --warn: #a86a00;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 16px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
#app { max-width: 1080px; margin: 0 auto; padding: 12px; }

h1 { font-size: 1.5rem; margin: .4em 0; }
h2 { font-size: 1.2rem; margin: 1em 0 .4em; }
h3 { font-size: 1.02rem; margin: .8em 0 .3em; }
p.muted, span.muted, div.muted { color: var(--muted); }
.small { font-size: .87rem; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 4px; flex-wrap: wrap; }
.topbar .title { font-weight: 700; font-size: 1.15rem; color: var(--brand); flex: 1; min-width: 200px; }
.topbar .who { color: var(--muted); font-size: .9rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 12px 0; }
.center-card { max-width: 430px; margin: 8vh auto; }

button, .btn {
  font: inherit; border: 0; border-radius: 10px; cursor: pointer;
  padding: 12px 18px; background: var(--brand); color: #fff; font-weight: 600;
  min-height: 46px;
}
button:hover { background: var(--brand-dark); }
button.secondary { background: #e8edf3; color: var(--brand-dark); }
button.secondary:hover { background: #d8e1ea; }
button.danger { background: var(--danger); }
button.ghost { background: transparent; color: var(--brand); padding: 8px 10px; min-height: 0; }
button:disabled { opacity: .55; cursor: default; }
button.small { padding: 7px 12px; min-height: 0; font-size: .9rem; }

input, select, textarea {
  font: inherit; width: 100%; padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--text); min-height: 46px;
}
textarea { min-height: 80px; }
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: .92rem; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }
.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: box-shadow .15s; display: block; text-align: left;
  color: var(--text); font-weight: 400; min-height: 0;
}
.tile:hover { box-shadow: 0 3px 14px rgba(29, 78, 137, .15); background: var(--card); }
.tile .t-icon { font-size: 1.7rem; }
.tile .t-name { font-weight: 700; margin-top: 6px; color: var(--brand-dark); }
.tile .t-desc { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.tile.disabled { opacity: .5; cursor: default; }
.tile.disabled:hover { box-shadow: none; }

table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #eef3f8; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; border-radius: 20px; padding: 2px 11px; font-size: .8rem; font-weight: 600; }
.badge.pass, .badge.active, .badge.ok { background: #e2f3e8; color: #1e6b3c; }
.badge.fail, .badge.inactive, .badge.bad { background: #fae3e3; color: #9c2323; }
.badge.pending, .badge.warn { background: #fdf1dc; color: #8a5c00; }
.badge.role { background: #e6edf7; color: var(--brand-dark); }
.badge.conf { background: #f3e6f7; color: #6b1e8a; }

.msg { padding: 12px 14px; border-radius: 10px; margin: 10px 0; }
.msg.error { background: #fae3e3; color: #8c1f1f; }
.msg.ok { background: #e2f3e8; color: #1e6b3c; }
.msg.info { background: #e6edf7; color: var(--brand-dark); }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 14px 0; flex-wrap: wrap; }
.tabs button { background: transparent; color: var(--muted); border-radius: 8px 8px 0 0; padding: 10px 16px; min-height: 0; font-weight: 600; }
.tabs button.on { color: var(--brand); box-shadow: inset 0 -3px 0 var(--brand); }
.tabs button:hover { background: #eef3f8; }

.kv { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.codebox { font-family: ui-monospace, Consolas, monospace; background: #f0f3f7; border: 1px dashed var(--line); border-radius: 8px; padding: 10px 14px; font-size: 1.05rem; letter-spacing: .04em; }
.recovery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }

.crumb { color: var(--muted); font-size: .9rem; margin-bottom: 4px; }
.crumb a { color: var(--brand); text-decoration: none; cursor: pointer; }
.right { text-align: right; }
.mt0 { margin-top: 0; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); background: #fbfcfe; }
.dropzone.drag { border-color: var(--brand); background: #eef3f8; }
@media (max-width: 640px) {
  #app { padding: 8px; }
  .card { padding: 14px; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
}

/* ---------- smoothness & responsiveness additions ---------- */
.card, .tile, button, .msg { transition: box-shadow .15s, background .15s, opacity .2s; }
.view-fade { animation: fadein .18s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none;} }

#toasts { position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(420px, 92vw); }
.toast { background: #223142; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.25); animation: fadein .2s; font-size: .95rem; }
.toast.ok { background: #1e6b3c; } .toast.error { background: #9c2323; }

.bottomnav { display: none; }
@media (max-width: 719px) {
  #app { padding-bottom: 76px; }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: #fff; border-top: 1px solid var(--line); justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottomnav button { background: none; color: var(--muted); min-height: 0; padding: 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7rem; position: relative; }
  .bottomnav button .bn-icon { font-size: 1.35rem; }
  .bottomnav button.on { color: var(--brand); }
  .bottomnav .bdg { position: absolute; top: 0; right: 2px; background: var(--danger); color: #fff; border-radius: 10px; font-size: .65rem; padding: 0 5px; min-width: 16px; }
}
.tile { position: relative; }
.tile .bdg { position: absolute; top: 10px; right: 12px; background: var(--danger); color: #fff; border-radius: 12px; font-size: .78rem; padding: 1px 8px; }

.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: rot .7s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes rot { to { transform: rotate(360deg);} }
.skel { background: linear-gradient(90deg,#eef1f5 25%,#e2e7ee 50%,#eef1f5 75%); background-size: 200% 100%; animation: shim 1.2s infinite; border-radius: 8px; height: 16px; margin: 8px 0; }
@keyframes shim { to { background-position: -200% 0; } }

/* schedule */
.weekgrid { display: grid; grid-template-columns: 130px repeat(7, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; min-width: 760px; }
.weekgrid > div { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 6px; min-height: 46px; font-size: .82rem; background: #fff; }
.weekgrid .wg-head { background: #eef3f8; font-weight: 700; text-align: center; }
.weekgrid .wg-name { font-weight: 600; background: #f7f9fc; }
.shift-chip { display: block; background: #e6edf7; border-left: 4px solid var(--brand); border-radius: 6px; padding: 3px 6px; margin: 2px 0; cursor: pointer; }
.shift-chip.unacked { border-left-color: var(--warn); }
.shift-chip:hover { background: #d8e3f2; }
.cal-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* chat */
.chat-layout { display: flex; gap: 12px; min-height: 60vh; }
.chat-list { flex: 0 0 300px; }
.chat-thread { flex: 1; display: flex; flex-direction: column; }
.chat-item { padding: 10px 12px; border-radius: 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.chat-item:hover, .chat-item.on { background: #eef3f8; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 10px 4px; display: flex; flex-direction: column; gap: 8px; max-height: 56vh; }
.bubble { max-width: 78%; padding: 9px 13px; border-radius: 16px; background: #eef1f5; align-self: flex-start; }
.bubble.mine { background: var(--brand); color: #fff; align-self: flex-end; }
.bubble .b-meta { font-size: .72rem; opacity: .75; margin-top: 3px; }
.bubble a { color: inherit; }
.chat-send { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.chat-send textarea { min-height: 48px; max-height: 130px; resize: none; flex: 1; }
.emergency-note { background: #fdf1dc; color: #8a5c00; border-radius: 10px; padding: 8px 12px; font-size: .82rem; margin-bottom: 8px; }
@media (max-width: 719px) {
  .chat-layout { flex-direction: column; }
  .chat-list { flex: none; }
  .chat-list.hidden-mobile { display: none; }
  .weekgrid { min-width: 680px; }
}

/* inventory */
.scan-video { width: 100%; max-height: 320px; border-radius: 12px; background: #000; }
.receipt { font-family: ui-monospace, Consolas, monospace; background: #f7f9fc; border: 1px dashed var(--line); border-radius: 10px; padding: 12px; }
.qty-in { width: 74px !important; min-width: 0 !important; text-align: center; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(20,30,40,.5); z-index: 55; display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal { background: #fff; border-radius: 14px; max-width: 560px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 18px; animation: fadein .15s; }

/* ---------- intuitive-design pass ---------- */
.greet h1 { margin: 8px 0 0; font-size: 1.65rem; }
.greet p { margin: 2px 0 14px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin-bottom: 18px; }
.sum-card { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--text); font-weight: 400; }
.sum-card:hover { background: #f2f6fb; box-shadow: 0 3px 14px rgba(29,78,137,.12); }
.sum-card.urgent { border-left: 5px solid var(--warn); }
.sum-card .sc-icon { font-size: 1.6rem; }
.sum-card .sc-body { display: flex; flex-direction: column; min-width: 0; }
.sum-card .sc-value { font-weight: 700; font-size: 1.02rem; line-height: 1.3; }
.sum-card .sc-label { color: var(--muted); font-size: .82rem; }
.sec-title { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; margin: 22px 0 8px; }
.t-chip { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.45rem; }
.c-blue { background: #e3ecfa; } .c-green { background: #e0f2e6; } .c-orange { background: #fdeeda; }
.c-purple { background: #ece5f8; } .c-red { background: #fbe3e3; } .c-teal { background: #dff2f1; } .c-gray { background: #eceff3; }

/* ---------- Keep It Simple House brand: charcoal & gold ---------- */
:root {
  --brand: #a87e00;            /* gold, darkened for readable text/links */
  --brand-dark: #8a6700;
  --ink: #414247;              /* logo charcoal */
  --gold: #f0b41c;             /* logo yellow */
  --bg: #f6f5f2;
}
.topbar { background: #ffffff; border: 1px solid var(--line); border-bottom: 3px solid var(--gold);
  border-radius: 14px; padding: 10px 16px; margin-bottom: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.topbar .title { color: var(--ink); }
.topbar .who { color: var(--muted); }
.topbar .who .badge.role { background: #ece9e2; color: #55565a; }
.topbar button.ghost { color: #8a6700; font-weight: 700; }
.topbar button.ghost:hover { background: #faf3dd; }
.brand-logo { height: 40px; width: auto; display: block; }
@media (max-width: 640px) { .brand-logo { height: 30px; } }
.login-logo { display: block; margin: 4px auto 14px; max-width: 240px; width: 80%; height: auto; }

button, .btn { background: var(--gold); color: #232323; }
button:hover, .btn:hover { background: #ddA415; }
button.secondary { background: #ebe9e4; color: #33342f; }
button.secondary:hover { background: #ded9d0; }
button.danger { background: var(--danger); color: #fff; }
button.ghost { background: transparent; color: var(--brand); }
button.ghost:hover { background: #f5edd8; }
.tile:hover, .sum-card:hover { box-shadow: 0 3px 14px rgba(240, 180, 28, .3); }
.tile .t-name, h1, .greet h1 { color: var(--ink); }
.tabs button.on { color: var(--ink); box-shadow: inset 0 -3px 0 var(--gold); }
.bottomnav button.on { color: var(--ink); }
.shift-chip { border-left-color: var(--gold); background: #faf3dd; }
.shift-chip:hover { background: #f5ead0; }
.bubble.mine { background: #3a3b41; color: #fff; }
.badge.role { background: #ece9e2; color: #55565a; }
.msg.info { background: #faf3dd; color: #6b5300; }
.chat-item:hover, .chat-item.on, tr.clickable:hover td { background: #f5efe0; }

/* ---------- dashboard (notification area) ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; }
.dash-card { margin: 0; }
.dash-card h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.viewall { font-size: .8rem; font-weight: 600; color: var(--brand); cursor: pointer; white-space: nowrap; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.mini-row:last-child { border-bottom: 0; }
button.mini-row { width: 100%; background: none; color: var(--text); font-weight: 400; min-height: 0; border-radius: 8px; }
button.mini-row:hover { background: #f5efe0; }
.mini-ann { padding: 9px 10px; border-radius: 10px; margin-bottom: 8px; border: 1px solid var(--line); }
.mini-ann.unread { background: #faf3dd; border-color: #ecd9a0; }
.attention-card { border-left: 5px solid var(--gold); padding: 8px 12px; }
.att-line { display: block; width: 100%; text-align: left; background: none; color: var(--ink); font-weight: 600; min-height: 0; padding: 8px 6px; border-radius: 8px; }
.att-line:hover { background: #f5efe0; }
.quicklinks { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px; }
.qlink { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; color: var(--text); font-weight: 400; text-decoration: none; cursor: pointer; text-align: left; min-height: 0; }
.qlink:hover { background: #fff; box-shadow: 0 3px 14px rgba(240,180,28,.3); }

/* ---------- barcode scanner ---------- */
.scan-wrap { position: relative; border-radius: 12px; overflow: hidden; background: #000; }
.scan-wrap .scan-video { display: block; width: 100%; max-height: 340px; object-fit: cover; }
.scan-reticle { position: absolute; inset: 0; pointer-events: none; display: flex; align-items: center; justify-content: center; }
.scan-reticle span { width: 78%; height: 42%; border: 3px solid rgba(240,180,28,.9); border-radius: 12px; box-shadow: 0 0 0 2000px rgba(0,0,0,.28); }
.scan-reticle.hit span { border-color: #35c759; box-shadow: 0 0 0 2000px rgba(53,199,89,.18); }

/* ---------- SOP library ---------- */
.sop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.sop-item { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px 4px 4px; background: var(--card); }
.sop-item:hover { background: #fff; box-shadow: 0 2px 10px rgba(240,180,28,.22); }
.sop-open { display: flex; align-items: center; gap: 10px; flex: 1; text-decoration: none; color: var(--text); padding: 6px 6px; min-width: 0; }
.sop-ico { font-size: 22px; flex: 0 0 auto; }
.sop-text { display: flex; flex-direction: column; min-width: 0; }
.sop-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sop-tools { display: flex; gap: 2px; flex: 0 0 auto; }
.sop-tools button { min-height: 0; padding: 4px 7px; }

/* ---------- SOP editor / web-page viewing ---------- */
button.sop-open { border:0; background:none; font:inherit; text-align:left; cursor:pointer; width:100%; }
.modal-wide { max-width:780px; width:96%; }
.sop-toolbar { display:flex; flex-wrap:wrap; gap:4px; margin:4px 0; }
.sop-toolbar button { min-height:0; padding:5px 10px; background:#f2f3f5; color:var(--ink); border:1px solid var(--line); border-radius:7px; font-weight:600; cursor:pointer; }
.sop-toolbar button:hover { background:#e9eaee; }
.sop-editor { min-height:240px; max-height:52vh; overflow:auto; border:1px solid var(--line); border-radius:10px; padding:12px 14px; background:#fff; font-size:15px; line-height:1.55; }
.sop-editor:focus { outline:2px solid var(--gold); }
.sop-editor h2 { font-size:19px; color:#3a2e05; } .sop-editor h3 { font-size:16px; color:#3a2e05; }
.sop-editor table { border-collapse:collapse; } .sop-editor td, .sop-editor th { border:1px solid #d1d5db; padding:4px 8px; }
.sop-upload { margin:10px 0 4px; padding:10px; border:1px dashed var(--line); border-radius:10px; }

/* ---------- in-app SOP reader ---------- */
.doc.sop-read-body { font-size:15.5px; line-height:1.6; color:var(--ink); }
.doc.sop-read-body h1 { font-size:22px; color:#3a2e05; }
.doc.sop-read-body h2 { font-size:19px; color:#3a2e05; margin:14px 0 4px; }
.doc.sop-read-body h3 { font-size:16px; color:#3a2e05; margin:12px 0 4px; }
.doc.sop-read-body ul, .doc.sop-read-body ol { padding-left:22px; }
.doc.sop-read-body table { border-collapse:collapse; width:100%; margin:10px 0; }
.doc.sop-read-body td, .doc.sop-read-body th { border:1px solid #d1d5db; padding:6px 9px; text-align:left; vertical-align:top; }
.doc.sop-read-body img { max-width:100%; height:auto; }

/* ---------- html5-qrcode scanner ---------- */
.scan-reader { width: 100%; min-height: 260px; border-radius: 12px; overflow: hidden; background: #000; }
.scan-reader video { width: 100% !important; border-radius: 12px; display: block; }
.scan-reader img { display: none; }            /* hide the library's info/scan icons */
#scan-ctrls .on { background: var(--gold); color: #3a2e05; }

/* ---------- incident photo picker ---------- */
.photo-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.photo-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; background: var(--card); }
.photo-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; background: #eee; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.photo-item .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
