:root {
  --sidebar: #0b1220;
  --sidebar-2: #151e31;
  --sidebar-text: #c9d1e1;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e6e9f0;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2447e6;
  --primary-2: #1d3bc4;
  --primary-soft: #eef2ff;
  --green: #16a34a; --green-soft: #e9f9ef;
  --orange: #d97706; --orange-soft: #fff6e5;
  --red: #dc2626; --red-soft: #fdecec;
  --purple: #7c3aed; --purple-soft: #f3edff;
  --blue: #2563eb; --blue-soft: #eaf1ff;
  --gray: #6b7280; --gray-soft: #f1f3f6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
img { max-width: 100%; }
body { font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: var(--text); background: var(--sidebar); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
.ic { flex-shrink: 0; vertical-align: middle; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text); padding: 22px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; transition: width .2s; }
.brand { padding: 0 6px 18px; position: relative; }
.brand-link { display: block; color: inherit; text-decoration: none !important; }
.brand-mark { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { height: 36px; width: auto; max-width: 120px; object-fit: contain; border-radius: 8px; flex-shrink: 0; }
.brand-name { font-size: 22px; font-weight: 600; color: #fff; letter-spacing: .5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn.sidebar-close, .icon-btn.search-toggle, .sidebar-backdrop { display: none; }
.brand-sub { font-size: 11.5px; color: #aeb7c9; margin-top: 4px; line-height: 1.35; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8.5px 12px; border-radius: 8px; color: var(--sidebar-text); font-size: 13.5px; white-space: nowrap; }
.nav a:hover { background: var(--sidebar-2); text-decoration: none; color: #fff; }
.nav a.active { background: #1f2a40; color: #fff; }
.collapse-btn { margin: 16px auto 0; width: 32px; height: 32px; border-radius: 50%; border: 0; background: #1f2a40; color: #fff; cursor: pointer; display: grid; place-items: center; }
.app.collapsed .sidebar { width: 68px; }
.app.collapsed .sidebar .nav span, .app.collapsed .brand-sub { display: none; }
.app.collapsed .brand-name { font-size: 13px; }
.app.collapsed .brand-logo { height: 32px; max-width: 40px; margin: 0 auto; }
.app.collapsed .brand-logo + .brand-name { display: none; }
.app.collapsed .collapse-btn svg { transform: rotate(180deg); }
.main { flex: 1; min-width: 0; background: var(--bg); display: flex; flex-direction: column; border-radius: 14px 0 0 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--border); border-radius: 14px 0 0 0; position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 21px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 24px 28px 40px; flex: 1; }
.topbar .mobile-menu { display: none; }

.gsearch { position: relative; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 9px; padding: 0 12px; width: 280px; color: var(--muted); background: #fff; }
.gsearch input { border: 0; outline: 0; padding: 9px 0; width: 100%; font: inherit; background: transparent; }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; color: #374151; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--gray-soft); }
.icon-btn .dot { position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--red); color: #fff; font-size: 10px; display: grid; place-items: center; }
.avatar-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--primary-soft); color: var(--primary); cursor: pointer; display: grid; place-items: center; }
.menu-wrap { position: relative; }
.dropdown { display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 260px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 30px rgba(16, 24, 40, .12); z-index: 50; padding: 6px; max-height: 420px; overflow-y: auto; }
.dropdown.right { left: auto; right: 0; min-width: 300px; }
.dropdown.open { display: block; }
.dropdown a, .dropdown .dd-item { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 7px; color: var(--text); font-size: 13px; }
.dropdown a:hover { background: var(--gray-soft); text-decoration: none; }
.dd-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; }
.dd-head small { color: var(--muted); }
.dd-group { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 8px 10px 4px; }
.gsearch .dropdown { width: 100%; min-width: 340px; }

/* ---------- components ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h3 { font-size: 16px; }
.card-body { padding: 16px 20px; }
.grid { display: grid; gap: 20px; }
.grid > *, .split > * { min-width: 0; }
.cols-2 { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; }
.layout-side { grid-template-columns: 250px minmax(0, 1fr); align-items: start; }
.filter-grid { grid-template-columns: 1fr 180px 1fr auto; align-items: end; }
.dash-row { grid-template-columns: 1.25fr 1fr .9fr; }
.gap0 { gap: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 20px; align-items: start; }
.mb { margin-bottom: 20px; }
.mt { margin-top: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

.stat { padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.stat .label { font-size: 16px; font-weight: 600; }
.stat .value { font-size: 34px; font-weight: 700; letter-spacing: -.5px; }
.stat a { font-size: 13px; font-weight: 500; }
.stat .stat-ic { position: absolute; right: 18px; top: 16px; width: 46px; height: 46px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.stat.tint-green { background: #ecfdf7; } .stat.tint-purple { background: #f3f1ff; } .stat.tint-orange { background: #fff9ec; } .stat.tint-pink { background: #fff1f5; }
.stat.tint-green .stat-ic { background: transparent; color: #059669; } .stat.tint-purple .stat-ic { background: transparent; color: #6d28d9; }
.stat.tint-orange .stat-ic { background: transparent; color: #b45309; } .stat.tint-pink .stat-ic { background: transparent; color: #db2777; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--gray-soft); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.green { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.outline-primary { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .6; cursor: default; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 500; border: 1px solid transparent; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); border-color: #c9efd7; }
.badge.orange { background: var(--orange-soft); color: var(--orange); border-color: #f8e0b0; }
.badge.red { background: var(--red-soft); color: var(--red); border-color: #f7c9c9; }
.badge.blue { background: var(--blue-soft); color: var(--blue); border-color: #cddcff; }
.badge.purple { background: var(--purple-soft); color: var(--purple); border-color: #e1d4ff; }
.badge.gray { background: var(--gray-soft); color: var(--gray); border-color: #e2e5ea; }
.text-green { color: var(--green); } .text-orange { color: var(--orange); } .text-blue { color: var(--blue); } .text-red { color: var(--red); }

/* tables */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 600; font-size: 13px; color: #1f2937; padding: 12px 16px; border-bottom: 1px solid var(--border); background: #fafbfc; white-space: nowrap; }
.tbl th.sortable { cursor: pointer; }
.tbl td { padding: 13px 16px; border-bottom: 1px solid #eef0f4; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td, .tbl tr.selected td { background: color-mix(in srgb, var(--primary) 5%, #fff); }
.tbl td.actions { white-space: nowrap; text-align: right; width: 1%; }
.tbl .clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act { width: 30px; height: 30px; border: 0; border-radius: 7px; background: transparent; color: #4b5563; cursor: pointer; display: inline-grid; place-items: center; }
.act:hover { background: var(--gray-soft); color: var(--primary); }
.act.del:hover { color: var(--red); background: var(--red-soft); }
.act.wa:hover { color: #16a34a; background: var(--green-soft); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

.crud-toolbar { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.crud-toolbar .title { font-weight: 600; font-size: 16px; margin-right: auto; }
.search-input { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; color: var(--muted); background: #fff; }
.search-input input { border: 0; outline: 0; padding: 8px 0; font: inherit; width: 200px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }

/* forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 6px; color: #1f2937; }
.field .req { color: var(--red); }
.field .help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.input, .field input[type=text], .field input[type=email], .field input[type=tel], .field input[type=number], .field input[type=date], .field input[type=time], .field input[type=password], .field input[type=search], .field select, .field textarea, select.input {
  width: 100%; padding: 9px 12px; border: 1px solid #d9dde5; border-radius: 8px; font: inherit; color: var(--text); background: #fff; outline: none;
}
.field textarea { resize: vertical; min-height: 70px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.field input[type=color] { width: 56px; height: 40px; padding: 3px; border: 1px solid #d9dde5; border-radius: 8px; background: #fff; cursor: pointer; }
.field input[type=file] { max-width: 100%; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.file-field { display: flex; align-items: center; gap: 12px; border: 1px solid #d9dde5; border-radius: 8px; padding: 6px; }
.file-field .btn { padding: 6px 12px; background: var(--gray-soft); }
.file-field .fname { color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-error { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; white-space: pre-line; }
.label-row { display: grid; grid-template-columns: 160px 1fr; align-items: center; gap: 12px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 50px 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 680px; box-shadow: 0 25px 60px rgba(0, 0, 0, .25); }
.modal.lg { max-width: 920px; } .modal.sm { max-width: 440px; } .modal.xl { max-width: 1120px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: #fafbfc; border-radius: 0 0 14px 14px; }

.toast-wrap { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #111827; color: #fff; padding: 11px 16px; border-radius: 9px; box-shadow: 0 8px 20px rgba(0,0,0,.2); max-width: 380px; font-size: 13.5px; animation: tin .2s; }
.toast.error { background: #b91c1c; } .toast.success { background: #15803d; }
.toast a { color: #bfdbfe; text-decoration: underline; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

.tabs { display: flex; flex-wrap: wrap; gap: 0 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs button, .tabs a { background: none; border: 0; padding: 11px 16px; font: inherit; font-weight: 500; color: #4b5563; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs .active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; } .tab-panel.active { display: block; }

/* dashboard */
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; font-size: 13.5px; }
.notif-list .bullet { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; background: var(--green); }
.bullet.orange { background: var(--orange); } .bullet.red { background: var(--red); } .bullet.blue { background: var(--blue); }
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda li { display: flex; gap: 14px; padding: 12px 0; font-size: 13.5px; }
.agenda .t { width: 78px; flex-shrink: 0; color: #374151; }

.mini-cal .cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.mini-cal .cal-head b { font-size: 15px; }
.mini-cal table { width: 100%; border-collapse: collapse; text-align: center; font-size: 12.5px; }
.mini-cal th { font-weight: 500; color: var(--muted); padding: 4px 0; font-size: 11px; }
.mini-cal td { padding: 2px 0; }
.mini-cal td span { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; position: relative; }
.mini-cal td span:hover { background: var(--gray-soft); }
.mini-cal td.other span { color: #b6bcc8; }
.mini-cal td.today span { background: var(--primary); color: #fff; }
.mini-cal td.has span::after { content: ""; position: absolute; bottom: 2px; width: 4px; height: 4px; border-radius: 50%; background: var(--orange); }

/* big calendar */
.big-cal { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.big-cal th { font-weight: 500; color: var(--muted); padding: 10px 0; font-size: 13px; }
.big-cal td { height: 92px; vertical-align: top; padding: 6px; border-top: 1px solid #eef0f4; cursor: pointer; }
.big-cal td:hover { background: #fafbff; }
.big-cal td .d { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-size: 15px; }
.big-cal td.other .d { color: #c0c5cf; }
.big-cal td.today .d { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.big-cal td.sel .d { background: var(--primary); color: #fff; }
.cal-chip { display: block; font-size: 11px; padding: 2px 6px; border-radius: 4px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--blue-soft); color: var(--blue); }
.cal-chip.Hearing { background: var(--blue-soft); color: var(--blue); }
.cal-chip.Limitation { background: var(--red-soft); color: var(--red); }
.cal-chip.Deadline { background: var(--orange-soft); color: var(--orange); }
.cal-chip.Client.Meeting, .cal-chip.Meeting { background: var(--purple-soft); color: var(--purple); }
.cal-chip.Task { background: var(--green-soft); color: var(--green); }
.ev-list .ev { display: grid; grid-template-columns: 110px 1fr auto; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--border); align-items: center; }
.ev-list .ev .when { border-right: 1px solid var(--border); font-size: 13px; color: #374151; }

/* profile */
.profile-head { display: flex; align-items: center; gap: 16px; padding-bottom: 16px; }
.profile-avatar { width: 62px; height: 62px; border-radius: 50%; background: var(--purple-soft); color: var(--purple); display: grid; place-items: center; }
.profile-head h2 { font-size: 18px; }
.info-list { list-style: none; padding: 0; margin: 0; }
.info-list li { display: flex; gap: 12px; align-items: center; padding: 8px 0; color: #1f2937; }
.info-list li .ic { color: #4b5563; }
.section-title { font-weight: 600; margin: 18px 0 8px; display: flex; align-items: center; justify-content: space-between; }
.divider { border-top: 1px solid var(--border); margin: 14px 0; }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.doc-row .ic { color: var(--primary); }
.doc-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-ic { color: #dc2626 !important; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { position: relative; display: grid; grid-template-columns: 100px 1fr auto; gap: 14px; padding: 0 0 30px 26px; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 3px; width: 11px; height: 11px; border-radius: 50%; border: 3px solid #1f2937; background: #fff; }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 19px; bottom: 0; width: 2px; background: #c9cfdb; }
.timeline li:last-child::after { display: none; }
.timeline li:last-child { padding-bottom: 6px; }
.timeline .tl-date { color: #1f2937; }
.timeline .tl-notes { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* draft library */
.tpl-card { padding: 28px 16px; text-align: center; cursor: pointer; position: relative; transition: box-shadow .15s, transform .15s; }
.tpl-card:hover { box-shadow: 0 8px 22px rgba(16, 24, 40, .1); transform: translateY(-2px); }
.tpl-card .tpl-ic { width: 52px; height: 52px; border-radius: 12px; border: 1px solid var(--border); background: #f8f9fb; display: grid; place-items: center; margin: 0 auto 16px; }
.tpl-card b { font-size: 14.5px; }
.tpl-card .tpl-actions { position: absolute; top: 8px; right: 8px; display: none; }
.tpl-card:hover .tpl-actions { display: flex; }
.draft-paper { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 48px 56px; min-height: 700px; font-family: "Times New Roman", Georgia, serif; font-size: 15.5px; line-height: 1.65; white-space: pre-wrap; outline: none; max-width: 860px; margin: 0 auto; }
.draft-paper .ph { background: #fff4c2; border-radius: 3px; }

/* documents */
.folder-list { padding: 10px; }
.folder-list a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 8px; color: #1f2937; font-size: 14px; }
.folder-list a:hover { background: var(--gray-soft); text-decoration: none; }
.folder-list a.active { background: var(--primary-soft); color: var(--primary); }
.folder-list .count { margin-left: auto; font-size: 12px; color: var(--muted); }

/* judgments */
.jlist .jitem { padding: 18px 20px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; gap: 12px; align-items: center; }
.jlist .jitem:hover, .jlist .jitem.active { background: #f5f7ff; }
.jlist .jitem h4 { font-size: 15.5px; margin-bottom: 4px; }
.jdetail dt { color: #374151; font-size: 13px; margin-top: 14px; font-weight: 500; }
.jdetail dd { margin: 4px 0 0; }

/* calculators */
.result-row { display: flex; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid #f0f2f5; }
.result-total { display: flex; justify-content: space-between; align-items: center; padding: 18px 0 4px; font-weight: 600; }
.result-total .amt { color: var(--primary); font-size: 24px; font-weight: 700; }
.note-box { display: flex; gap: 10px; background: #eef3ff; border: 1px solid #d9e3ff; border-radius: 10px; padding: 14px 16px; color: #1f2937; font-size: 13.5px; }
.note-box .ic { color: var(--primary); }

/* e-filing */
.gen-item { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border); cursor: pointer; }
.gen-item:hover { background: #fafbff; }
.gen-item .ic { color: var(--primary); }
.gen-item small { display: block; color: var(--muted); margin-top: 2px; }
.check-item { display: flex; align-items: center; gap: 12px; padding: 11px 20px; border-bottom: 1px solid #f0f2f5; }
.check-item .spacer { flex: 1; }
.tick { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #9ca3af; display: grid; place-items: center; cursor: pointer; background: #fff; color: #fff; }
.tick.on { background: var(--green); border-color: var(--green); }

/* security */
.sec-item { display: flex; align-items: center; gap: 18px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.sec-item .sec-ic { width: 50px; height: 50px; border-radius: 10px; background: #eef1f8; display: grid; place-items: center; color: #1e3a8a; }
.sec-item .ok { width: 32px; height: 32px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; }
.sec-item .no { width: 32px; height: 32px; border-radius: 50%; background: #d1d5db; color: #fff; display: grid; place-items: center; }
.switch { position: relative; width: 46px; height: 26px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d1d5db; border-radius: 26px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(20px); }

/* staff directory */
.person { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f2f5; }
.person .pav { width: 38px; height: 38px; border-radius: 50%; background: #e5e7eb; color: #374151; display: grid; place-items: center; }
.person small { display: block; color: var(--muted); }

.bar { height: 8px; background: var(--gray-soft); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }

/* login */
.auth-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0b1220, #1a2a52); padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 34px; box-shadow: 0 30px 70px rgba(0, 0, 0, .35); }
.auth-card .brand-name { color: var(--sidebar); font-size: 26px; }
.auth-card .brand-sub { color: var(--muted); margin-bottom: 24px; }
.auth-card .field { margin-bottom: 14px; }
.hint { background: var(--primary-soft); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: #1e3a8a; margin-top: 16px; }

/* print */
@media print {
  .sidebar, .topbar, .no-print, .crud-toolbar, .pager, .tbl td.actions, .tbl th.actions { display: none !important; }
  body, .main { background: #fff; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
  .draft-paper { border: 0; padding: 0; min-height: 0; }
  .draft-paper .ph { background: none; }
}


.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; }
.app.collapsed .nav-badge { display: none; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px !important; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; background: transparent; color: #6b7280; cursor: pointer; border-radius: 6px; display: grid; place-items: center; }
.pw-toggle:hover { background: var(--gray-soft); color: var(--primary); }

/* ---------- branding settings ---------- */
.logo-preview { width: 96px; height: 96px; border: 1px dashed #cfd5e1; border-radius: 12px; display: grid; place-items: center; background: #fafbfc; overflow: hidden; flex-shrink: 0; color: var(--muted); }
.logo-preview img { max-width: 88px; max-height: 88px; object-fit: contain; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #d9dde5; cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }
.brand-preview { background: var(--sidebar); border-radius: 12px; padding: 16px; color: #fff; }
.brand-preview .brand-sub { color: #aeb7c9; }

/* ---------- chat ---------- */
.chat-page { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100vh - 120px); min-height: 460px; overflow: hidden; }
.chat-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.chat-list-head { padding: 12px; border-bottom: 1px solid var(--border); }
.chat-list-head .search-input input { width: 100%; }
.chat-threads { flex: 1; overflow-y: auto; }
.thread { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid #f0f2f5; color: var(--text); text-decoration: none !important; }
.thread:hover { background: var(--gray-soft); }
.thread.active { background: var(--primary-soft); }
.thread-av { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }
.thread.active .thread-av { background: var(--primary); color: #fff; }
.thread-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.thread-top { display: flex; justify-content: space-between; gap: 8px; }
.thread-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.thread-top small { color: var(--muted); font-size: 11.5px; flex-shrink: 0; }
.thread-prev { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread.unread .thread-prev { color: var(--text); font-weight: 500; }
.thread-badge { background: var(--green); color: #fff; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px; display: grid; place-items: center; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-who { display: flex; flex-direction: column; min-width: 0; }
.chat-who b, .chat-who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-back { display: none; }
#chatThread { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-placeholder { display: grid !important; place-items: center; background: #f8f9fc; }
.chat-empty-big { text-align: center; color: var(--muted); padding: 20px; }
.chat-empty-big .ic { color: #c3c9d6; }
.chat { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; background: #f5f7fb; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 280px; font-size: 13.5px; }
.chat-day { text-align: center; margin: 10px 0 4px; }
.chat-day span { background: #e8ebf2; color: #4b5563; font-size: 11.5px; padding: 3px 10px; border-radius: 10px; }
.msg { max-width: min(78%, 520px); padding: 8px 12px 6px; border-radius: 14px; background: #fff; border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; box-shadow: 0 1px 1px rgba(16, 24, 40, .04); }
.msg.mine { align-self: flex-end; background: var(--primary); border-color: var(--primary); color: #fff; border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
.msg-name { font-size: 11.5px; font-weight: 600; color: var(--primary); margin-bottom: 2px; }
.msg-body { white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.msg.mine a { color: #fff; text-decoration: underline; }
.msg-meta { font-size: 10.5px; opacity: .7; text-align: right; margin-top: 2px; }
.msg-tick { letter-spacing: -2px; margin-left: 2px; }
.msg.mine.read .msg-tick { color: #b9f6ca; opacity: 1; }
.msg-img img { display: block; max-width: 240px; max-height: 240px; border-radius: 10px; margin-bottom: 4px; }
.msg-file { display: inline-block; padding: 6px 10px; border-radius: 8px; background: rgba(0, 0, 0, .06); margin-bottom: 4px; word-break: break-all; }
.chat-compose { border-top: 1px solid var(--border); padding: 10px 12px; background: #fff; }
.chat-input-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-input-row textarea { flex: 1; resize: none; border: 1px solid #d9dde5; border-radius: 20px; padding: 9px 14px; font: inherit; line-height: 1.4; max-height: 140px; outline: none; min-width: 0; }
.chat-input-row textarea:focus { border-color: var(--primary); }
.chat-attach, .chat-send { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; cursor: pointer; border: 0; }
.chat-attach { color: #4b5563; background: var(--gray-soft); }
.chat-attach:hover { color: var(--primary); }
.chat-send { background: var(--primary); color: #fff; }
.chat-send:hover { background: var(--primary-2); }
.chat-send:disabled { opacity: .6; }
.chat-file { display: flex; align-items: center; gap: 8px; font-size: 12.5px; background: var(--primary-soft); color: var(--primary); padding: 6px 10px; border-radius: 8px; margin-bottom: 8px; }
.chat-file span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-file-x { border: 0; background: none; color: inherit; cursor: pointer; }
.chat-wa { font-size: 12.5px; font-weight: 400; margin-bottom: 8px; color: #374151; }

/* portal floating chat box */
.chat-fab { position: fixed; right: 20px; bottom: 20px; z-index: 90; height: 54px; padding: 0 20px 0 16px; border-radius: 27px; border: 0; background: var(--primary); color: #fff; display: flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; cursor: pointer; box-shadow: 0 10px 24px rgba(16, 24, 40, .25); }
.chat-fab:hover { background: var(--primary-2); }
.chat-fab .fab-badge { position: absolute; top: -4px; right: -2px; background: var(--red); color: #fff; font-size: 11px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px; display: grid; place-items: center; border: 2px solid #fff; }
.chat-pop { position: fixed; right: 20px; bottom: 86px; z-index: 95; width: 380px; height: min(580px, calc(100vh - 110px)); background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(16, 24, 40, .28); display: flex; flex-direction: column; overflow: hidden; }
.chat-pop-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--sidebar); color: #fff; }
.chat-pop-head .thread-av { background: rgba(255, 255, 255, .15); color: #fff; overflow: hidden; }
.chat-pop-head .thread-av img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.chat-pop-head small { color: #aeb7c9; display: block; font-size: 12px; }
.chat-pop-head .icon-btn { color: #fff; margin-left: auto; }
.chat-pop-head .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.chat-pop .chat { flex: 1; }

/* touch screens have no hover */
@media (hover: none) {
  .tpl-card .tpl-actions { display: flex; }
}

/* ---------- tablet ---------- */
@media (max-width: 1200px) {
  .dash-row { grid-template-columns: 1fr 1fr; }
  .dash-row > :last-child { grid-column: 1 / -1; }
  .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .chat-page { grid-template-columns: 280px minmax(0, 1fr); }
}

/* ---------- small tablet / phone ---------- */
@media (max-width: 900px) {
  body { background: var(--bg); }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 70; transform: translateX(-105%); visibility: hidden; transition: transform .22s ease, visibility .22s; width: 270px !important; }
  .app.mobile-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .app.collapsed .sidebar .nav span, .app.collapsed .brand-sub { display: block; }
  .app.collapsed .brand-logo + .brand-name { display: block; }
  .app.collapsed .brand-name { font-size: 22px; }
  .app.collapsed .brand-logo { height: 36px; max-width: 120px; margin: 0; }
  .app.collapsed .nav-badge { display: grid; }
  .collapse-btn { display: none; }
  .icon-btn.sidebar-close { display: grid; position: absolute; top: -6px; right: -4px; color: #fff; }
  .sidebar-close:hover { background: var(--sidebar-2); }
  .brand { padding-right: 40px; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 65; }
  .app.mobile-open .sidebar-backdrop { display: block; }
  .main, .topbar { border-radius: 0; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar .mobile-menu { display: grid; }
  .topbar h1 { font-size: 17px; }
  .top-actions { gap: 4px; }
  .icon-btn.search-toggle { display: grid; }
  .gsearch { display: none; }
  .topbar.search-open .gsearch { display: flex; position: absolute; left: 12px; right: 12px; top: calc(100% + 6px); width: auto; box-shadow: 0 12px 30px rgba(16, 24, 40, .18); z-index: 30; }
  .gsearch .dropdown { min-width: 0; left: -1px; right: -1px; width: auto; }
  .dropdown.right { position: fixed; top: 58px; left: 10px; right: 10px; min-width: 0; }
  .content { padding: 16px 12px 32px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button, .tabs a { padding: 10px 12px; }

  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { gap: 14px; }
  .mb { margin-bottom: 14px; }
  .layout-side, .filter-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .label-row { grid-template-columns: 1fr; }

  .stat { padding: 16px; }
  .stat .label { font-size: 14px; padding-right: 44px; }
  .stat .value { font-size: 26px; }
  .stat .stat-ic { width: 38px; height: 38px; right: 12px; top: 12px; }
  .stat .stat-ic .ic { width: 20px; height: 20px; }
  .card-pad { padding: 16px; }
  .card-head { padding: 14px 16px; }
  .card-body { padding: 14px 16px; }

  .crud-toolbar { padding: 12px; gap: 8px; }
  .crud-toolbar .title { flex: 1 1 100%; }
  .crud-toolbar .search-input { flex: 1 1 100%; }
  .crud-toolbar .search-input input { width: 100%; }
  .crud-toolbar select.input, .crud-toolbar input[type=date] { flex: 1 1 140px; width: auto !important; }
  .crud-toolbar .extra:empty { display: none; }
  .crud-toolbar .btn { flex: 1 1 auto; }
  .pager { padding: 10px 12px; }

  /* folders become a horizontal strip */
  .folder-list { display: flex; gap: 6px; overflow-x: auto; padding: 10px; }
  .folder-list a { flex-shrink: 0; white-space: nowrap; padding: 8px 12px; border: 1px solid var(--border); }
  .folder-list .count { margin-left: 6px; }

  .modal-back { padding: 12px 8px; }
  .modal-head { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; flex-wrap: wrap; }
  .toast-wrap { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }

  .big-cal td { height: 56px; padding: 4px 2px; text-align: center; }
  .big-cal td .d { width: 28px; height: 28px; font-size: 13.5px; }
  .big-cal .cal-chip, .big-cal td .small { display: none; }
  .big-cal td:has(.cal-chip) .d { box-shadow: inset 0 -3px 0 var(--orange); }
  .ev-list .ev { grid-template-columns: 86px minmax(0, 1fr) auto; gap: 10px; padding: 12px 14px; }
  .timeline li { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding-bottom: 22px; }
  .timeline li .tl-date { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
  .draft-paper { padding: 20px 16px; font-size: 14.5px; min-height: 420px; }
  .sec-item { flex-wrap: wrap; padding: 16px; gap: 12px; }
  .sec-item > div { flex: 1 1 200px !important; }
  .jlist .jitem { padding: 14px 16px; }
  .cols-2.gap0 > :first-child { border-right: 0 !important; border-bottom: 1px solid var(--border); }
  .profile-head { flex-wrap: wrap; }
  .result-total .amt { font-size: 21px; }
  .auth-card { padding: 26px 22px; }

  .chat-page { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 92px); height: calc(100dvh - 92px); min-height: 380px; }
  .chat-page .chat-main { display: none; }
  .chat-page.show-thread .chat-main { display: flex; }
  .chat-page.show-thread .chat-list { display: none; }
  .chat-list { border-right: 0; }
  .chat-back { display: grid; margin-left: -8px; }
  .hide-sm { display: none; }
}

/* ---------- phone: tables become cards ---------- */
@media (max-width: 640px) {
  .dash-row { grid-template-columns: minmax(0, 1fr); }
  .g4 { gap: 10px; }
  .g4 .stat .value { font-size: 22px; }
  table.tbl.has-head:not(.no-stack), .tbl.has-head:not(.no-stack) tbody, .tbl.has-head:not(.no-stack) tr { display: block; width: 100%; }
  .tbl.has-head:not(.no-stack) thead { display: none; }
  .tbl.has-head:not(.no-stack) tr { padding: 12px 16px; border-bottom: 1px solid #eef0f4; }
  .tbl.has-head:not(.no-stack) tr:last-child { border-bottom: 0; }
  .tbl.has-head:not(.no-stack) td { display: flow-root; padding: 3px 0; border: 0; text-align: right; overflow-wrap: anywhere; min-height: 26px; }
  .tbl.has-head:not(.no-stack) td::before { content: attr(data-label); float: left; color: var(--muted); font-size: 12.5px; padding-right: 12px; text-align: left; max-width: 48%; }
  .tbl.has-head:not(.no-stack) td:first-child { text-align: left; font-weight: 600; font-size: 14.5px; padding-bottom: 6px; }
  .tbl.has-head:not(.no-stack) td:first-child::before, .tbl.has-head:not(.no-stack) td.actions::before, .tbl.has-head:not(.no-stack) td.empty::before, .tbl.has-head:not(.no-stack) td:not([data-label])::before { display: none; }
  .tbl.has-head:not(.no-stack) td:empty { display: none; }
  .tbl.has-head:not(.no-stack) td.actions { width: auto; padding-top: 8px; margin-top: 4px; border-top: 1px dashed #eef0f4; }
  .tbl.has-head:not(.no-stack) td.empty { text-align: center; }
  .tbl.has-head:not(.no-stack) tr.clickable:hover td, .tbl.has-head:not(.no-stack) tr.selected td { background: transparent; }
  .tbl.has-head:not(.no-stack) tr.selected { background: color-mix(in srgb, var(--primary) 6%, #fff); box-shadow: inset 3px 0 0 var(--primary); }
  .tbl .clip { max-width: 100%; white-space: normal; }
  .tbl:not(.has-head) td, .tbl.no-stack td, .tbl.no-stack th { padding: 10px 12px; }
  .act { width: 36px; height: 36px; }

  .modal-foot .btn { flex: 1 1 auto; }
  .doc-row { flex-wrap: wrap; row-gap: 4px; }
  .doc-row .name { flex: 1 1 calc(100% - 40px); white-space: normal; overflow-wrap: anywhere; }
  .doc-row > .small { flex: 1; padding-left: 30px; }
  .chat-fab { right: 14px; bottom: 14px; height: 52px; padding: 0 16px; }
  .chat-fab .fab-label { display: none; }
  .chat-pop { inset: 0; width: auto; height: auto; border-radius: 0; }
  .msg { max-width: 86%; }
  .msg-img img { max-width: 200px; }
}

@media print {
  .chat-fab, .chat-pop, .sidebar-backdrop { display: none !important; }
}
.auth-brand { margin-bottom: 4px; }
.auth-brand .brand-logo { height: 46px; max-width: 160px; }

/* notifications dropdown */
.dropdown.right { text-align: left; }
.notif-head { flex-direction: row !important; align-items: center; justify-content: space-between; gap: 12px; }
.notif-head .link-btn { font-weight: 500; white-space: nowrap; }
.notif-head .link-btn:disabled { opacity: .5; }
.dropdown a.notif { align-items: flex-start; line-height: 1.4; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.dropdown a.notif.unread { font-weight: 500; background: color-mix(in srgb, var(--primary) 5%, #fff); margin-bottom: 2px; }
.dropdown a.notif.read { color: var(--muted); }
.dropdown a.notif.read .notif-dot { opacity: .35; }
