@font-face { font-family: "Tajawal"; src: url("/static/fonts/Tajawal-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("/static/fonts/Tajawal-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --bg: #f3f5f8; --card: #ffffff; --text: #1c2430; --muted: #6b7684; --line: #dfe4ea;
  --primary: #1f4e78; --primary-2: #2e6da4; --success: #1e8e5a; --danger: #c0392b; --warn: #b7791f;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 6px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; overflow-x: hidden; background: var(--bg); color: var(--text); font-family: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif; font-size: 16px; line-height: 1.5; }
a { color: var(--primary-2); text-decoration: none; }
[x-cloak] { display: none !important; }
.mono { font-family: ui-monospace, Consolas, monospace; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.inline { display: inline; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: .5rem .9rem; gap: .5rem; padding-top: max(.5rem, env(safe-area-inset-top)); }
.brand { color: #fff; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1 1 auto; }
.brand-title, .brand-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 420px) { .brand-sub { display: none; } .brand-title { font-size: .95rem; } }
.brand-title { font-weight: 700; font-size: 1.05rem; } .brand-sub { font-size: .72rem; opacity: .85; }
.topnav { display: flex; align-items: center; gap: .2rem; flex: none; }
.topnav a { color: #fff; padding: .35rem .55rem; border-radius: 8px; font-size: .9rem; }
.topnav a:hover { background: rgba(255,255,255,.12); }
.topnav .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); white-space: nowrap; max-width: 38vw; overflow: hidden; text-overflow: ellipsis; display: inline-block; line-height: 1.9; }
.topnav a { white-space: nowrap; }
.brand-sub { white-space: nowrap; }

.container { max-width: 900px; margin: 0 auto; padding: .8rem .8rem 4rem; }
.h1 { font-size: 1.35rem; margin: .2rem 0 .8rem; } .h3 { font-size: 1rem; margin: 0 0 .5rem; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem; margin-bottom: .8rem; }
.card.empty { color: var(--muted); text-align: center; }
.section { margin-top: .8rem; }
.note { background: #fff8e6; border-right: 3px solid var(--warn); padding: .4rem .6rem; border-radius: 6px; margin: .4rem 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; border: 1px solid transparent; border-radius: 10px; padding: .55rem .95rem; font: inherit; font-weight: 700; cursor: pointer; background: #e9edf2; color: var(--text); min-height: 44px; }
.btn-primary { background: var(--primary); color: #fff; } .btn-primary:hover { background: var(--primary-2); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: #fdecea; color: var(--danger); border-color: #f5c6c2; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-sm { padding: .4rem .7rem; min-height: 38px; font-size: .9rem; }
.btn-xs { padding: .2rem .5rem; min-height: 30px; font-size: .8rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.actions.center { justify-content: center; }
.actions-cell { white-space: nowrap; }

/* forms */
.form .field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .7rem; }
.field > span { font-size: .85rem; color: var(--muted); font-weight: 700; }
input:not([type=checkbox]):not([type=file]), select, textarea { width: 100%; font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); min-height: 44px; }
textarea { min-height: 60px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-2); outline-offset: 1px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .6rem; }
@media (max-width: 480px) { .row-3 { grid-template-columns: 1fr 1fr; } }
.field-group { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; margin-bottom: .7rem; }
.field-group summary { cursor: pointer; font-weight: 700; color: var(--primary); }
.field-group .row-2 { margin-top: .5rem; }
.defect-group { margin: .5rem 0; }
.defect-group-title { font-weight: 700; font-size: .9rem; color: var(--muted); margin-bottom: .2rem; }
.check { display: flex; align-items: flex-start; gap: .45rem; padding: .3rem 0; font-size: .95rem; }
.check input { width: 20px; height: 20px; margin-top: .2rem; flex: none; }
.login-card { max-width: 420px; margin: 2rem auto; }

/* alerts & toast */
.alert { padding: .6rem .8rem; border-radius: 10px; margin: .5rem 0; }
.alert-error { background: #fdecea; color: #7f1d1d; border: 1px solid #f5c6c2; }
.alert-ok { background: #e6f6ee; color: #14532d; border: 1px solid #b7e4c7; }
.alert-warn { background: #fff8e6; color: #7c4a03; border: 1px solid #f6d58a; }
.alert ul { margin: .3rem 1rem 0 0; padding: 0; }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 50; width: min(92vw, 520px); pointer-events: none; }
.toast .alert { pointer-events: auto; box-shadow: 0 6px 24px rgba(0,0,0,.2); }

/* badges & chips */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #e9edf2; color: var(--text); white-space: nowrap; }
.chip { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; background: #eef2f6; border: 1px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0; }
.disc-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .5rem; }

.status-NOT_STARTED { background: #e9edf2; color: #4b5563; }
.status-IN_PROGRESS { background: #dbeafe; color: #1e40af; }
.status-COMPLETE { background: #dcfce7; color: #166534; }
.status-PARTIAL { background: #fef3c7; color: #92400e; }
.status-INACCESSIBLE { background: #fee2e2; color: #991b1b; }
.status-EXCLUDED { background: #f3e8ff; color: #6b21a8; }
.status-NOT_FOUND { background: #f3f4f6; color: #374151; text-decoration: line-through; }

.dstat-NOT_STARTED { background: #eceff3; color: #6b7280; }
.dstat-IN_PROGRESS { background: #dbeafe; color: #1e40af; }
.dstat-READY { background: #fef3c7; color: #92400e; }
.dstat-APPROVED { background: #dcfce7; color: #166534; }
.dstat-NA { background: #f3f4f6; color: #9ca3af; }

.disp-RETAIN { background: #dcfce7; color: #166534; } .disp-PROTECT { background: #d1fae5; color: #065f46; }
.disp-RELOCATE { background: #dbeafe; color: #1e40af; } .disp-REMOVE { background: #fee2e2; color: #991b1b; }
.disp-SALVAGE { background: #fef3c7; color: #92400e; } .disp-REUSE { background: #e0f2fe; color: #075985; }
.disp-RECYCLE { background: #ecfccb; color: #3f6212; } .disp-DISPOSE { background: #f3f4f6; color: #374151; }
.disp-REFER { background: #f3e8ff; color: #6b21a8; }
.cond-GOOD { background: #dcfce7; color: #166534; } .cond-FAIR { background: #fef9c3; color: #854d0e; }
.cond-POOR { background: #ffedd5; color: #9a3412; } .cond-DAMAGED { background: #fee2e2; color: #991b1b; } .cond-UNKNOWN { background: #f3f4f6; color: #6b7280; }

/* room list */
.filters { padding: .6rem; }
.filters-row { display: flex; gap: .4rem; margin-bottom: .4rem; }
.filters-row:last-child { margin-bottom: 0; }
.filters-row select, .filters-row input { min-width: 0; }
.group-title { font-size: 1rem; margin: 1rem 0 .4rem; color: var(--primary); }
.room-row { display: flex; justify-content: space-between; gap: .6rem; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .7rem .9rem; margin-bottom: .5rem; color: var(--text); }
.room-row:active { background: #f0f4f9; }
.room-row-main { min-width: 0; }
.room-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; flex: none; }
.room-code { font-family: ui-monospace, Consolas, monospace; direction: ltr; unicode-bidi: isolate; font-weight: 700; color: var(--primary); display: inline-block; }
.room-code.big { font-size: 1.25rem; }
.room-name { font-weight: 700; }
.disc-dots { display: flex; gap: .2rem; }
.dot { font-size: .65rem; font-weight: 700; padding: .05rem .3rem; border-radius: 6px; font-family: ui-monospace, monospace; }
.lock { font-size: .9rem; }

/* room header */
.room-head-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.room-title { font-size: 1.15rem; font-weight: 700; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .3rem .8rem; margin: .6rem 0 0; }
.kv > div { display: flex; gap: .4rem; align-items: baseline; }
.kv dt { color: var(--muted); font-size: .8rem; flex: none; } .kv dd { margin: 0; font-weight: 700; }
.kv.compact { margin-top: .3rem; } .kv.compact dd { font-weight: 400; }
.kv .small { white-space: nowrap; direction: ltr; unicode-bidi: isolate; }

/* tabs */
.tabs { display: flex; gap: .3rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: .4rem; -webkit-overflow-scrolling: touch; position: sticky; top: 54px; background: var(--bg); z-index: 10; padding-top: .3rem; }
.tab-btn { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .45rem .9rem; font: inherit; font-weight: 700; color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; min-height: 40px; }
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tab-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.1); }
.tab-dot.dstat-NOT_STARTED { background: #d1d5db; } .tab-dot.dstat-IN_PROGRESS { background: #3b82f6; } .tab-dot.dstat-READY { background: #f59e0b; } .tab-dot.dstat-APPROVED { background: #22c55e; } .tab-dot.dstat-NA { background: #e5e7eb; }
.disc-status-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .4rem; align-items: center; }

/* entries */
.entry { border-right: 4px solid var(--primary-2); }
.entry-top { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.asset-code { font-family: ui-monospace, Consolas, monospace; direction: ltr; unicode-bidi: isolate; font-size: .8rem; color: var(--muted); }
.entry-desc { font-weight: 700; font-size: 1.02rem; margin: .3rem 0; }

/* photos */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; margin: .4rem 0; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; background: #eee; }
.thumb { margin: 0; } .thumb figcaption { font-size: .7rem; line-height: 1.3; margin-top: .2rem; word-break: break-all; }
.photo-upload { display: flex; flex-direction: column; gap: .4rem; margin-top: .5rem; }
.upload-buttons { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.upload-buttons .btn { flex: 1; }
.htmx-indicator { display: none; } .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }
.spinner { color: var(--primary); font-weight: 700; }
form.htmx-request .upload-buttons .btn { opacity: .5; pointer-events: none; }

/* admin */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .5rem; margin-bottom: .8rem; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .7rem; text-align: center; display: flex; flex-direction: column; }
.stat-n { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.menu { display: flex; flex-wrap: wrap; gap: .5rem; }
.menu-item { flex: 1 1 220px; display: flex; flex-direction: column; margin: 0; color: var(--text); }
.menu-item.disabled { opacity: .55; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: right; padding: .45rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-size: .8rem; }
@media (max-width: 600px) { .table { display: block; overflow-x: auto; white-space: nowrap; } }

/* phase 2: supervisor panel, dashboard, pending uploads */
.sup-panel { border-right: 4px solid var(--warn); }
.sup-locked { align-items: start; }
.card-lite { border: 1px solid var(--line); border-radius: 10px; padding: .7rem; }
@media (max-width: 600px) { .sup-locked, .dash-cols { grid-template-columns: 1fr; } }
.room-head-badges { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }
.bar { background: #e9edf2; border-radius: 999px; height: 10px; overflow: hidden; min-width: 90px; }
.bar-fill { background: var(--success); height: 100%; border-radius: 999px; }
.bar-cell { min-width: 130px; }
.num { text-align: left; direction: ltr; font-family: ui-monospace, Consolas, monospace; }
.pending-uploads { position: fixed; bottom: 0; right: 0; left: 0; z-index: 40; background: #fff8e6; border-top: 2px solid var(--warn); color: #7c4a03; padding: .5rem .9rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-weight: 700; padding-bottom: max(.5rem, env(safe-area-inset-bottom)); }
.draft-bar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.table.audit td { max-width: 260px; word-break: break-word; }
.pending-uploads[hidden] { display: none; }
