:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --nav: #0f172a;
  --accent: #2563eb;
  --accent-ink: #1d4ed8;
  --mech: #2563eb;
  --elec: #d97706;
  --ok: #15803d;
  --bad: #b91c1c;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a, a:hover, a:active, a:focus { color: var(--accent); text-decoration: none; }
.btn, .btn:hover, .btn:active, .btn:focus { text-decoration: none; }
h1 { font-size: 1.4rem; margin: .2rem 0 .8rem; }
h2 { font-size: 1.05rem; margin: 0 0 .9rem; }
code { background: #f1f5f9; padding: .1em .4em; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--nav); color: #fff; padding: .6rem 1rem;
  position: sticky; top: 0; z-index: 300; height: 52px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .25);
}
.topbar-left { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; font-weight: 600; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand:hover { text-decoration: none; color: #fff; opacity: .9; }
.brand-logo { height: 36px; width: auto; display: block; background: #fff; border-radius: 7px; padding: 3px 7px; }
.login-logo { display: block; width: min(220px, 70%); height: auto; margin: 0 auto .5rem; }
.topright { display: flex; align-items: center; gap: .7rem; }
.navtoggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: 0; border-radius: 7px;
  background: transparent; color: #cbd5e1; cursor: pointer;
}
.navtoggle:hover { background: #1e293b; color: #fff; }
.topicon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  background: #1e293b; color: #cbd5e1; border: 1px solid #334155;
}
a.topicon:hover { background: #334155; color: #fff; text-decoration: none; }

/* sidebar */
.sidebar {
  position: fixed; top: 52px; left: 0; bottom: 0; z-index: 250;
  width: 236px; background: #fff; border-right: 1px solid var(--line);
  overflow-y: auto; padding: .8rem .7rem;
  transition: left .25s ease;
}
.snav { display: flex; flex-direction: column; gap: 2px; }
.snav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .75rem; border-radius: 8px;
  color: #334155; font-size: .92rem; font-weight: 500;
}
.snav a svg { flex: 0 0 auto; color: #64748b; }
.snav a:hover { background: #f1f5f9; color: var(--ink); }
.snav a.active { background: #eff6ff; color: var(--accent-ink); font-weight: 600; }
.snav a.active svg { color: var(--accent-ink); }
.sgroup {
  margin: 1rem .75rem .3rem; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.backdrop {
  position: fixed; inset: 0; z-index: 240; background: rgba(15, 23, 42, .45);
}

.wrap { margin-left: 236px; padding: 1.4rem 1.6rem; max-width: 1500px; transition: margin-left .25s ease; }
.foot { margin-left: 236px; text-align: center; font-size: .8rem; padding: 1.4rem 0; transition: margin-left .25s ease; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.25rem 1.4rem; margin-bottom: 1.2rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
  overflow-x: auto; /* keeps wide tables usable on small screens */
}
.cards { display: flex; gap: 1rem; flex-wrap: wrap; }
.card.stat { flex: 1 1 160px; display: block; text-align: center; color: var(--ink); }
.card.stat:hover { text-decoration: none; border-color: var(--accent); }
.card.stat b { display: block; font-size: 1.9rem; color: var(--accent); }
.card.stat span { color: var(--muted); font-size: .85rem; }

.subnav { display: none; }

/* ---------- tabs ---------- */
.tabbar {
  display: flex; gap: .25rem; margin-bottom: 1rem;
  border-bottom: 1px solid var(--line); overflow-x: auto;
}
.tabbtn {
  border: 0; background: none; padding: .55rem 1rem; font: inherit;
  font-size: .92rem; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabbtn:hover { color: var(--ink); }
.tabbtn.active { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabpane > .card:last-child { margin-bottom: 1.2rem; }
.subtabs .tabbar { margin-top: .4rem; }

.grid-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 1.2rem; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- forms ---------- */
label { display: block; margin-bottom: .85rem; font-size: .88rem; font-weight: 600; }
label .muted { font-weight: 400; }
input[type="text"], input[type="password"], input[type="url"], select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .5rem .65rem;
  border: 1px solid #cbd5e1; border-radius: 7px; font: inherit; font-weight: 400;
  background: #fff;
}
textarea { resize: vertical; }
table input[type="text"], table select { margin-top: 0; padding: .35rem .5rem; font-size: .88rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37, 99, 235, .35); border-color: var(--accent); }
.check { font-weight: 400; display: flex; align-items: center; gap: .5rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.4rem; }
.form-grid .btnrow, .form-grid .note { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.note { font-size: .83rem; margin-top: .8rem; }
.btnrow { display: flex; gap: .6rem; margin-top: .4rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; padding: .45rem 1rem; border-radius: 7px;
  border: 1px solid #cbd5e1; background: #fff; color: var(--ink);
  font: inherit; font-size: .9rem; cursor: pointer;
}
.btn:hover { text-decoration: none; background: #f1f5f9; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-danger { background: #fff; border-color: #fca5a5; color: var(--bad); }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; border-color: #475569; color: #cbd5e1; }
.wrap .btn-ghost { color: var(--ink); border-color: #cbd5e1; }
.btn-sm { padding: .22rem .65rem; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; margin-top: .4rem; }
.back { margin-bottom: .9rem; }
form.inline { display: inline; }
.actions { white-space: nowrap; text-align: right; }
.actions form { margin-left: .35rem; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table-fixed { table-layout: fixed; }
.table-fixed td { overflow-wrap: break-word; }
.desc-cell { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.desc-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more-btn {
  border: 0; background: none; color: var(--accent); cursor: pointer;
  font: inherit; font-size: .8rem; padding: 0; flex: 0 0 auto;
}
.more-btn:hover { color: var(--accent-ink); }
.field-full {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px;
  padding: .8rem 1rem; margin-bottom: .9rem; font-size: .92rem;
  white-space: pre-wrap; overflow-wrap: break-word; max-height: 50vh; overflow-y: auto;
}
.field-rows { margin-bottom: .9rem; max-height: 55vh; overflow-y: auto; }
.field-row {
  display: grid; grid-template-columns: 115px 1fr; gap: .75rem;
  padding: .65rem 0; border-bottom: 1px solid var(--line); font-size: .92rem;
  align-items: start;
}
.field-row:last-child { border-bottom: 0; }
.field-row b {
  color: var(--muted); font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; padding-top: .35rem;
}
.field-row span { overflow-wrap: break-word; white-space: pre-wrap; line-height: 1.55; padding-top: .2rem; }
.field-row input[type="text"], .field-row input[type="date"] {
  width: 100%; max-width: 280px; margin-top: 0;
}
.uwrap { overflow-wrap: break-word; }

/* ---------- profile ---------- */
.profile-card { max-width: 560px; }
.profile-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.1rem; }
.profile-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 50%;
  background: #eff6ff; color: var(--accent-ink); border: 2px solid #bfdbfe;
  flex: 0 0 auto;
}
.profile-head .chip { margin: .35rem .25rem 0 0; }
.table th { text-align: left; padding: .55rem .7rem; border-bottom: 2px solid var(--line); color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; background: #f8fafc; }
.table td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); }
.table tbody tr:hover { background: #f8fafc; }
.qty { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.empty { text-align: center; padding: 1.5rem 0; }

/* ---------- chips / alerts ---------- */
.chip { display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.chip-mechanical { background: #dbeafe; color: #1d4ed8; }
.chip-electrical { background: #fef3c7; color: #b45309; }
.chip-role-superadmin { background: #ede9fe; color: #6d28d9; }
.chip-role-admin { background: #dbeafe; color: #1d4ed8; }
.chip-role-user { background: #f1f5f9; color: #475569; }
.alert { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alert-ok { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #0f172a 0%, #1e3a5f 100%); }
.login-card { width: 380px; padding: 2rem 1.8rem; border: 0; box-shadow: 0 20px 50px rgba(2, 8, 23, .45); }
.login-head { text-align: center; margin-bottom: 1.2rem; color: var(--nav); }
.login-head h1 { font-size: 1.1rem; margin: .5rem 0 .3rem; }
.login-title { font-size: 1.25rem; font-weight: 700; color: var(--ink); margin: 0 0 .2rem; }
.login-form label { display: block; font-size: .82rem; font-weight: 600; color: #334155; margin-bottom: .85rem; }
.login-form label > span { display: block; margin-bottom: .35rem; }
.lg-inp {
  display: flex; align-items: center; gap: .55rem;
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: .65rem .8rem; background: #f8fafc; color: var(--muted);
}
.lg-inp:focus-within { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); color: var(--accent); }
.lg-inp input { border: 0; background: none; outline: none; flex: 1; font: inherit; font-size: .95rem; color: var(--ink); box-shadow: none; padding: 0; }
.lg-inp input:focus { border: 0; box-shadow: none; }
.login-form .btn-block { padding: .7rem; font-size: .95rem; font-weight: 600; border-radius: 10px; }
.quick-login { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px dashed var(--line); text-align: center; }
.quick-login p { margin: 0 0 .6rem; font-size: .8rem; }
.quick-login button { margin: 0 .2rem; }

/* ---------- plan ---------- */
.plan-head { display: flex; align-items: baseline; gap: 1.2rem; flex-wrap: wrap; margin-bottom: .8rem; }
.plan-head p { margin: 0; }
.legend { margin-left: auto; display: flex; gap: 1rem; font-size: .85rem; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: .35rem; vertical-align: -2px; }
.sw-mech { background: rgba(37, 99, 235, .25); border: 2px solid var(--mech); }
.sw-elec { background: rgba(217, 119, 6, .2); border: 2px solid var(--elec); }
.plan-box { padding: .8rem; overflow-x: auto; }
.plan { width: 100%; min-width: 900px; height: auto; display: block; }
.outline { fill: #fbfdff; stroke: #0f172a; stroke-width: 5; }

.sec rect { stroke-width: 2.5; cursor: pointer; }
.sec.mechanical rect { fill: rgba(37, 99, 235, .18); stroke: var(--mech); }
.sec.electrical rect { fill: rgba(217, 119, 6, .15); stroke: var(--elec); }
.sec.mechanical:hover rect { fill: rgba(37, 99, 235, .42); }
.sec.electrical:hover rect { fill: rgba(217, 119, 6, .4); }
.sec text { text-anchor: middle; pointer-events: none; fill: var(--ink); }
.sec-code { font-size: 26px; font-weight: 700; }
.sec-name { font-size: 15px; fill: #475569; }
.sec-name-sm { font-size: 13px; }

.dims line { stroke: #dc2626; stroke-width: 2.5; }
.dims .tick { stroke-width: 1.5; stroke-dasharray: 5 4; }
.dims text { fill: #dc2626; font-size: 22px; font-weight: 600; text-anchor: middle; }

.tip {
  position: fixed; z-index: 100; pointer-events: none;
  background: #0f172a; color: #fff; padding: .45rem .75rem; border-radius: 7px;
  font-size: .85rem; box-shadow: 0 4px 14px rgba(0,0,0,.3); max-width: 280px;
}
.tip b { display: block; }
.tip small { color: #94a3b8; }

.ref { padding: .8rem 1.4rem; }
.ref summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.ref img { max-width: 100%; margin-top: .8rem; border: 1px solid var(--line); border-radius: 8px; }

.sec-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: .6rem; }
.sec-head h1 { margin-bottom: .35rem; }

/* ---------- section toolbar: search + view toggle ---------- */
.toolbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search svg { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; padding: .5rem .65rem .5rem 2.2rem;
  border: 1px solid #cbd5e1; border-radius: 7px; font: inherit; background: #fff;
}
.search input:focus { outline: 2px solid rgba(37, 99, 235, .35); border-color: var(--accent); }
.viewtoggle { display: inline-flex; border: 1px solid #cbd5e1; border-radius: 7px; overflow: hidden; }
.viewtoggle button {
  border: 0; background: #fff; padding: .48rem .95rem; font: inherit; font-size: .88rem;
  color: var(--muted); cursor: pointer;
}
.viewtoggle button.active { background: var(--accent); color: #fff; font-weight: 600; }
.viewtoggle button:not(.active):hover { background: #f1f5f9; }

/* ---------- grid view (photo cards) ---------- */
.kgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 1rem; }
.kcard {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff;
}
.kcard:hover { box-shadow: 0 4px 14px rgba(15, 23, 42, .12); }
.kimg { display: block; width: 100%; aspect-ratio: 400 / 260; object-fit: cover; background: #f1f5f9; }
.kbody { padding: .7rem .85rem .8rem; }
.ktitle {
  font-weight: 600; font-size: .9rem; line-height: 1.3; min-height: 2.3em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.kmeta { display: flex; justify-content: space-between; align-items: center; margin-top: .55rem; }
.kunit {
  background: #f1f5f9; color: #475569; border-radius: 5px;
  padding: .12rem .5rem; font-size: .76rem; font-weight: 600; text-transform: uppercase;
}
.kqty b { font-size: 1.15rem; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.kqty small { color: var(--muted); font-size: .72rem; }

/* ---------- implementation project ---------- */
.grp {
  display: inline-block; background: var(--nav); color: #fff; border-radius: 7px;
  padding: .12rem .55rem; font-size: .8rem; margin-right: .3rem; vertical-align: 2px;
}
.grp-prog { float: right; font-size: .82rem; font-weight: 400; margin-top: .3rem; }
.grp-tools { float: right; display: inline-flex; align-items: center; gap: .3rem; margin-left: .5rem; }
.drag-handle { cursor: grab; color: var(--muted); font-size: .8rem; letter-spacing: -1px; user-select: none; padding: 0 .2rem; }
.drag-handle:active { cursor: grabbing; }
.grp-handle { margin-right: .4rem; }
.drag-cell { padding: .45rem .2rem !important; text-align: center; }
tr.dragging, .card.dragging { opacity: .4; }
.archived-card { border-style: dashed; }
.arch-row { display: flex; align-items: center; gap: .7rem; padding: .5rem 0; border-top: 1px solid var(--line); }
.arch-row .arch-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .92rem; }
.modal-xl { max-width: 900px; width: 92vw; }
.prev-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.prev-head h2 { margin: 0; font-size: 1rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prev-body { background: #f1f5f9; border: 1px solid var(--line); border-radius: 8px; min-height: 200px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.prev-body img { max-width: 100%; max-height: 65vh; display: block; }
.prev-body iframe { width: 100%; height: 65vh; border: 0; display: block; }
.plan-wrap { position: relative; display: inline-flex; align-items: center; min-width: 98px; padding: .3rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: .88rem; }
.plan-txt { pointer-events: none; }
.plan-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; margin: 0; }
.plan-input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.plan-wrap:has(.plan-input.saved) { border-color: var(--ok); box-shadow: 0 0 0 2px rgba(22, 163, 74, .18); }
.ck-text {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.45;
}
.h2-ico { vertical-align: -2px; margin-right: .4rem; color: var(--muted); }
.modal-box label:not([class]) { display: block; font-size: .85rem; font-weight: 600; margin: .7rem 0; }
.modal-box label:not([class]) input:not([type="checkbox"]):not([type="radio"]),
.modal-box label:not([class]) textarea { display: block; width: 100%; margin-top: .3rem; font-weight: 400; }
.cktable td { vertical-align: top; }
.ck-done { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; margin-top: .2rem; }
.ck-done:disabled { cursor: default; opacity: .55; }
.row-done { background: #f0fdf4; }
.row-done:hover { background: #dcfce7 !important; }
.row-done .ck-label { color: var(--muted); }
.row-late { background: #fef2f2; }
.row-late:hover { background: #fee2e2 !important; }
.row-pending { background: #eff6ff; }
.row-pending:hover { background: #dbeafe !important; }
.row-done td:first-child, .row-late td:first-child, .row-pending td:first-child { border-left: 3px solid transparent; }
.row-done td:first-child { border-left-color: var(--ok); }
.row-late td:first-child { border-left-color: #f87171; }
.row-pending td:first-child { border-left-color: #60a5fa; }
.ck-doneat { font-size: .74rem; margin-top: .15rem; }

/* multi-select (Action by) */
.msel { position: relative; display: inline-block; }
.msel-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid #cbd5e1; border-radius: 7px; background: #fff;
  padding: .35rem .55rem; font: inherit; font-size: .85rem; cursor: pointer;
  max-width: 170px;
}
.msel-btn:hover { border-color: var(--accent); }
.msel-btn.saved { outline: 2px solid #86efac; }
.msel-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msel-caret { color: var(--muted); font-size: .75rem; }
.msel-pop {
  position: fixed; z-index: 400;
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .15);
  padding: .35rem; min-width: 140px;
}
.msel-sep { border-top: 1px solid var(--line); margin: .3rem 0; }
.msel-all b { font-weight: 600; }
.msel-opt {
  display: flex; align-items: center; gap: .45rem; padding: .35rem .45rem;
  border-radius: 6px; font-weight: 400; font-size: .85rem; cursor: pointer; margin: 0;
}
.msel-opt:hover { background: #f1f5f9; }
.msel-opt input { margin: 0; accent-color: var(--accent); }
.im-by {
  display: inline-flex; align-items: center; gap: .4rem;
  margin: 0 .5rem .45rem 0; padding: .3rem .75rem;
  border: 1px solid #cbd5e1; border-radius: 999px; background: #fff;
  font-weight: 500; font-size: .83rem; color: var(--muted); cursor: pointer;
}
.im-by input { margin: 0; accent-color: var(--accent); }
.im-by:hover { border-color: var(--accent); }
.im-by:has(input:checked) {
  border-color: var(--accent); background: #eff6ff;
  color: var(--accent-ink); font-weight: 600;
}
@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; gap: .15rem; }
  .field-row b { padding-top: 0; }
  .field-row span { padding-top: 0; }
}
.ck-files { max-width: 230px; }
.file {
  display: inline-flex; align-items: center; gap: .25rem;
  background: #f1f5f9; border: 1px solid var(--line); border-radius: 6px;
  padding: .14rem .5rem; margin: 0 .2rem .25rem 0; font-size: .78rem; max-width: 100%;
}
.file a { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-del { border: 0; background: none; color: var(--bad); cursor: pointer; font-size: .95rem; line-height: 1; padding: 0 .1rem; }
.file-del:hover { color: var(--bad); }
.file-add { padding: .1rem .5rem; font-size: .75rem; }
.chip-done, .chip-st-done { background: #dcfce7; color: #166534; }
.chip-late { background: #fee2e2; color: #b91c1c; }
.chip-pending { background: #dbeafe; color: #1d4ed8; }
.chip-st-in_progress { background: #fef3c7; color: #b45309; }
.chip-st-not_started { background: #f1f5f9; color: #475569; }
.cktable input[type="text"], .cktable input[type="date"], .cktable select,
.sched-field { padding: .35rem .5rem; font-size: .85rem; margin-top: 0; }
.prog { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin: .4rem 0 1rem; }
.prog-fill { height: 100%; background: var(--ok); border-radius: 99px; }
select.sched-field.st-done { background: #dcfce7; color: #166534; border-color: #86efac; font-weight: 600; }
select.sched-field.st-in_progress { background: #fef3c7; color: #b45309; border-color: #fcd34d; font-weight: 600; }
select.sched-field.st-not_started { background: #f1f5f9; color: #475569; font-weight: 600; }
td input.saved, td select.saved { outline: 2px solid #86efac; outline-offset: 0; }
.sched-add { margin-top: .8rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.sched-table td.sched-date { white-space: nowrap; }
.sched-table .sched-phase { font-weight: 500; }
.sched-table .sched-handle { font-size: .9rem; }
/* date entry in the schedule dialog: typed dd-Mon-yyyy plus a calendar picker */
.date-pair { display: flex; gap: .4rem; align-items: center; margin-top: .3rem; }
.date-pair .date-txt { flex: 1; min-width: 0; margin-top: 0; }
.date-pair .date-pick { width: 44px; padding: .3rem; margin-top: 0; cursor: pointer; }
.date-txt.bad { border-color: #b91c1c; }
.notes ul { margin: 0; padding-left: 1.2rem; }
.notes li { margin-bottom: .4rem; font-size: .9rem; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 200; padding: 1rem;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  width: min(480px, 100%); margin: 0; max-height: 90vh; overflow-y: auto;
}
.modal-lg { width: min(700px, 100%); }
.modal-box h2 { margin-bottom: .35rem; }
.modal-desc { margin: 0 0 1rem; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.modal-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 auto; white-space: nowrap; text-align: center; }

/* file drop-zone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  border: 2px dashed #cbd5e1; border-radius: 10px; padding: 1.1rem 1rem;
  text-align: center; cursor: pointer; background: #f8fafc; margin-bottom: 1rem;
  font-weight: 600;
}
.dropzone:hover { border-color: var(--accent); background: #eff6ff; }
.dropzone svg { color: var(--accent); margin-bottom: .1rem; }
.dropzone small { font-weight: 400; color: var(--muted); font-size: .78rem; }
.dropzone .dz-count { color: var(--accent-ink); font-weight: 700; font-size: .85rem; }
.dropzone input { display: none; }

.modal-err {
  margin: 0 0 .8rem; padding: .55rem .8rem; border-radius: 7px;
  background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; font-size: .85rem;
}

/* details button + modal body */
.det-btn {
  display: inline-flex; align-items: center; gap: .25rem; margin-left: .5rem;
  border: 1px solid #c7d2fe; background: #eef2ff; color: var(--accent-ink);
  border-radius: 999px; padding: .1rem .55rem; font-size: .72rem; font-weight: 600;
  cursor: pointer; vertical-align: 1px;
}
.det-btn:hover { background: #e0e7ff; }
.det-body { font-size: .92rem; line-height: 1.6; }
.det-body h3 { font-size: .98rem; color: var(--accent-ink); margin: 1rem 0 .4rem; }
.det-body h3:first-child { margin-top: 0; }
.det-body p { margin: 0 0 .7rem; }
.det-body ul, .det-body ol { margin: 0 0 .9rem; padding-left: 1.3rem; }
.det-body li { margin-bottom: .35rem; }

/* ---------- secrets ---------- */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid #cbd5e1; background: #fff; color: var(--muted);
  border-radius: 6px; width: 28px; height: 26px; cursor: pointer; padding: 0;
  vertical-align: middle;
}
.icon-btn:hover { color: var(--accent-ink); border-color: var(--accent); }
.secret-pw {
  display: inline-block; min-width: 90px; font-family: ui-monospace, Consolas, monospace;
  letter-spacing: .5px; margin-right: .25rem; vertical-align: middle;
}
.secret-pw.shown { color: var(--accent-ink); font-weight: 600; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 2.4rem; }
.pw-wrap .pw-eye { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); border: 0; width: 26px; }
.copy-btn.copied, .icon-btn.copied { color: var(--ok); border-color: var(--ok); }

/* ---------- users bulk bar ---------- */
.bulkbar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 8px;
  padding: .5rem .8rem; margin-bottom: .8rem; font-size: .88rem;
}
.bulkbar > span { margin-right: auto; color: var(--accent-ink); }
.usr-sel, #selAll { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .sidebar { left: -260px; box-shadow: none; }
  .sidebar.open { left: 0; box-shadow: 4px 0 24px rgba(15, 23, 42, .25); }
  .wrap, .foot { margin-left: 0; }
}
@media (min-width: 961px) {
  .backdrop { display: none !important; }
  body.sb-closed .sidebar { left: -260px; }
  body.sb-closed .wrap, body.sb-closed .foot { margin-left: 0; }
}
@media (max-width: 760px) {
  .topbar { padding: .6rem .7rem; height: 48px; }
  .brand { flex: 1; min-width: 0; }
  .brand span { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; }
  .sidebar { top: 48px; }
  .topright { gap: .45rem; }
  .topicon { width: 34px; height: 34px; }
  .wrap { padding: .9rem .7rem; }
  .card { padding: .9rem; }
  h1 { font-size: 1.2rem; }
  .sec-head { flex-direction: column; gap: .2rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search { max-width: none; flex: 0 0 auto; }
  .viewtoggle { align-self: flex-start; }
  .plan-head { gap: .5rem; }
  .legend { margin-left: 0; width: 100%; }
  .login-card { width: min(360px, 94vw); }
  .kgrid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .7rem; }
  .table { font-size: .85rem; }
  .table th, .table td { padding: .45rem .5rem; }
  .actions { text-align: left; }
  .modal { align-items: center; padding: 1rem; }
  .modal-box { border-radius: 12px; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; white-space: normal; }

  /* stacked tables: each row becomes a labeled card */
  .stack-sm thead { display: none; }
  .stack-sm, .stack-sm tbody, .stack-sm tr, .stack-sm td { display: block; }
  .stack-sm { border: 0; }
  .stack-sm tr {
    border: 1px solid var(--line); border-radius: 10px;
    margin-bottom: .7rem; padding: .55rem .8rem;
  }
  .stack-sm td { border: 0; padding: .3rem 0; }
  .stack-sm td[data-label]::before {
    content: attr(data-label);
    display: block; font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
    margin-bottom: .15rem;
  }
  .stack-sm .desc-text { white-space: normal; overflow-wrap: break-word; }
  .stack-sm .qty { text-align: left; }
  .stack-sm .actions { white-space: normal; }
}

@media (max-width: 480px) {
  .topbar { padding: .6rem .7rem; height: 48px; }
  .sidebar { top: 48px; }
}
