:root {
  --bg: #f5f6fa; --card: #fff; --text: #1f2330; --muted: #6b7180; --line: #e6e8ef;
  --primary: #5b5bd6; --primary-d: #4646b8; --green: #1f9d55; --red: #d93d3d; --amber: #c77c02;
  --radius: 12px; --shadow: 0 1px 2px rgba(20,20,40,.05), 0 2px 8px rgba(20,20,40,.04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 18px 0 6px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.logo, .auth-logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff; font-size: 16px; }
.topbar nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar nav a:not(.btn) { color: var(--text); font-weight: 500; }
.topbar .who small { color: var(--muted); font-weight: 400; margin-left: 4px; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 20px; }
.wrap.narrow { max-width: 420px; padding-top: 8vh; }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.form-card { max-width: 640px; margin: 0 auto; }
.auth { text-align: center; }
.auth .auth-logo { width: 48px; height: 48px; font-size: 26px; border-radius: 14px; margin-bottom: 12px; }
.auth form { text-align: left; margin-top: 16px; }
.empty { text-align: center; padding: 48px 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; }
.section-title { margin: 24px 0 10px; font-size: 15px; }
.count { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 20px; background: #eceef4; color: var(--muted); font-size: 12px; text-align: center; font-weight: 600; }

.detail { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 14px; }
input, select, textarea { font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid #d5d8e2; border-radius: 9px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,91,214,.15); }
textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .row2 { grid-template-columns: 1fr; } }
.search input { width: 240px; }
@media (max-width: 600px) { .search, .search input { width: 100%; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 9px; border: 1px solid #d5d8e2; background: #fff;
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; }
.btn:hover { background: #f3f4f8; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff !important; }
.btn-primary:hover { background: var(--primary-d); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #188346; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #bd2f2f; }
.btn-ghost-danger { color: var(--red); border-color: transparent; background: transparent; }
.btn-ghost-danger:hover { background: #fdeeee; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 18px; font-size: 16px; }
.btn-block { width: 100%; }

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.flash-ok { background: #e7f6ed; color: #146c3b; border: 1px solid #c3e8d2; }
.flash-err { background: #fdeeee; color: #a42828; border: 1px solid #f6caca; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-grey { background: #eceef4; color: #555b6b; }
.b-blue { background: #e3edff; color: #2456c4; }
.b-red { background: #fde4e4; color: #b42323; }
.b-amber { background: #fff1d6; color: #9a5d00; }
.b-teal { background: #dcf5f1; color: #11766a; }
.b-purple { background: #efe6ff; color: #6b36c9; }
.b-green { background: #dff5e7; color: #157a40; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; background: #eceef4; color: var(--muted); font-size: 11px; font-weight: 600; }
.tag-red { background: #fde4e4; color: #b42323; }

/* Board */
.board { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #eceef4; border-radius: var(--radius); padding: 10px; min-height: 120px; }
.col-head { font-weight: 700; font-size: 13px; padding: 4px 4px 10px; display: flex; justify-content: space-between; align-items: center; }
.col-head .count { background: #fff; }
.col-body { display: flex; flex-direction: column; gap: 8px; }
.col-empty { text-align: center; color: #b0b4c0; padding: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }

.tcard { display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; color: var(--text); box-shadow: var(--shadow); transition: transform .08s, box-shadow .08s; }
.tcard:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(20,20,40,.08); }
.tcard-act { border-left: 4px solid var(--primary); }
.tcard-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.tcard-title { font-weight: 600; margin-bottom: 6px; }
.tcard-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px rgba(91,91,214,.2); }
.overdue { color: var(--red) !important; font-weight: 600; }

/* Detail */
.title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.desc { background: #f8f9fc; border-radius: 9px; padding: 12px; white-space: normal; }
.facts { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 18px 0 0; }
.facts dt { color: var(--muted); font-weight: 600; font-size: 13px; }
.facts dd { margin: 0; word-break: break-word; }
.biglink { font-weight: 600; }
.stepper { list-style: none; display: flex; gap: 4px; padding: 0; margin: 18px 0 6px; counter-reset: s; }
.stepper li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); text-align: center; position: relative; }
.stepper li::before { content: ""; position: absolute; top: 14px; left: -50%; width: 100%; height: 2px; background: var(--line); z-index: 0; }
.stepper li:first-child::before { display: none; }
.stepper li span { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #eceef4; font-weight: 700; color: var(--muted); }
.stepper li.done span { background: var(--green); color: #fff; }
.stepper li.done::before, .stepper li.now::before { background: var(--green); }
.stepper li.now span { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(91,91,214,.2); }
.stepper li.now { color: var(--text); font-weight: 600; }

.action-card { border: 2px solid var(--primary); }
.waiting { text-align: center; color: var(--muted); }
.hint { color: var(--muted); margin: 0 0 12px; }
.or { text-align: center; color: var(--muted); font-size: 13px; margin: 10px 0; }
.fixbox { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.fixbox summary { cursor: pointer; color: var(--red); font-weight: 600; margin-bottom: 10px; }
.side-tools { display: flex; flex-direction: column; gap: 6px; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; }
.timeline time { color: #9aa0ad; font-size: 12px; margin-left: 4px; white-space: nowrap; }
.ev { font-size: 13px; color: var(--muted); padding-left: 14px; position: relative; }
.ev::before { content: ""; position: absolute; left: 2px; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: #c4c8d3; }
.ev b { color: var(--text); }
.cm { background: #f5f6fa; border-radius: 10px; padding: 10px 12px; }
.cm-me { background: #eef0ff; }
.cm-fix { background: #fff1f1; border: 1px solid #f6caca; }
.cm-head { font-size: 13px; margin-bottom: 3px; }
.cm-body { word-break: break-word; }
.comment-form { border-top: 1px solid var(--line); padding-top: 14px; }

/* Staff */
.staff-list { list-style: none; padding: 0; margin: 0; }
.staff-list li { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.staff-list li:first-child { border-top: 0; }
.staff-list li.inactive { opacity: .55; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #e3e4fb; color: var(--primary); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.grow { flex: 1; min-width: 0; }
details.mini summary { cursor: pointer; color: var(--primary); font-size: 13px; font-weight: 600; text-align: right; }
details.mini[open] { display: flex; flex-direction: column; gap: 6px; }
form.inline { display: flex; gap: 6px; }
form.inline input, form.inline select { padding: 6px 10px; font-size: 13px; width: 160px; }
form.inline .btn { white-space: nowrap; }

@media (max-width: 600px) {
  .wrap { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .topbar nav { gap: 12px; font-size: 14px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
  .stepper li { font-size: 10.5px; }
  .staff-list li { flex-wrap: wrap; }
}

/* ===== Jenama Serenity ===== */
:root { --primary: #13375b; --primary-d: #0d2843; }
.logo, .auth-logo { background: #13375b url(logo.png) center/cover no-repeat !important; color: transparent !important; overflow: hidden; }
.logo { width: 34px !important; height: 34px !important; }
.auth-logo { width: 120px !important; height: 120px !important; border-radius: 18px !important; }

/* ===== Forum ===== */
.topic-list { padding: 0; overflow: hidden; }
.topic-row { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line); color: var(--text); }
.topic-row:first-child { border-top: 0; }
.topic-row:hover { background: #f8f9fc; text-decoration: none; }
.topic-title { font-weight: 600; margin-bottom: 2px; }
.topic-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.forum-thread { max-width: 820px; }
.post-head { display: flex; align-items: center; gap: 10px; margin: 12px 0 10px; }
.reply .post-head { margin-top: 0; }
.post-body { word-break: break-word; line-height: 1.6; }
.post-tools { display: flex; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); }
.reply-me { border-left: 4px solid var(--primary); }

.logo { width: 42px !important; height: 42px !important; border-radius: 10px !important; background-size: 210% !important; background-position: 50% 33% !important; }