/* StarMaker Family Hub — UI styles. Uses logical properties (inline-start/end) so RTL works by flipping <html dir>. */
:root {
  --bg: #f7f7fb; --surface: #ffffff; --surface-2: #fafafd; --border: #e9e8f1; --border-strong: #d9d7e6;
  --text: #17142b; --text-2: #565370; --text-3: #8a87a3;
  --brand: #7c3aed; --brand-2: #e8338a; --brand-soft: #f3ecff; --brand-ink: #5b21b6;
  --grad: linear-gradient(135deg, #7c3aed 0%, #c026d3 55%, #ec4899 100%);
  --green: #12a150; --green-bg: #e7f7ee; --yellow: #b7860b; --yellow-bg: #fdf5d8; --orange: #d9620b; --orange-bg: #fdeedd;
  --red: #dc2640; --red-bg: #fde8eb; --blue: #2563eb; --blue-bg: #e7efff; --gray-bg: #f0eff5;
  --gold-1: #f9d976; --gold-2: #e5a823; --gold-ink: #6b4a00;
  --radius: 14px; --radius-sm: 10px; --shadow: 0 1px 2px rgba(23,20,43,.04), 0 2px 8px rgba(23,20,43,.04);
  --shadow-lg: 0 12px 40px rgba(23,20,43,.14); --sidebar: 248px; --sidebar-collapsed: 72px; --topbar: 60px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-ink); text-decoration: none; }
button { font-family: inherit; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }
.muted { color: var(--text-3); } .small { font-size: 12px; } .nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- boot / login ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--text-3); }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--surface); }
.login-art { background: var(--grad); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::after { content: ''; position: absolute; inset-inline-end: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; background: rgba(255,255,255,.12); }
.login-art h1 { font-size: 40px; line-height: 1.1; max-width: 420px; }
.login-art p { opacity: .85; max-width: 420px; font-size: 15px; }
.login-form { display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 24px; margin-bottom: 6px; }
@media (max-width: 860px) { .login-wrap { grid-template-columns: 1fr; } .login-art { display: none; } }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 15px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; color: #fff; flex: none; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand small { display: block; font-weight: 600; font-size: 11px; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: var(--surface); border-inline-end: 1px solid var(--border); position: fixed; inset-block: 0; inset-inline-start: 0; display: flex; flex-direction: column; z-index: 60; transition: width .2s ease; }
.sidebar .brand { padding: 14px 18px; height: var(--topbar); border-bottom: 1px solid var(--border); }
.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--text-2); font-weight: 600; font-size: 13.5px; position: relative; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand-ink); }
.nav a.active::before { content: ''; position: absolute; inset-inline-start: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--grad); }
.nav .count { margin-inline-start: auto; background: var(--red-bg); color: var(--red); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; }
.nav-foot { padding: 10px; border-top: 1px solid var(--border); }
.collapse-btn { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 0; background: none; color: var(--text-3); border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13px; }
.collapse-btn:hover { background: var(--surface-2); }
.shell.collapsed .sidebar { width: var(--sidebar-collapsed); }
.shell.collapsed .nav a span, .shell.collapsed .brand-text, .shell.collapsed .collapse-btn span, .shell.collapsed .nav .count { display: none; }
.shell.collapsed .nav a, .shell.collapsed .collapse-btn { justify-content: center; }
.shell.collapsed .collapse-btn svg { transform: scaleX(-1); }
.main { flex: 1; margin-inline-start: var(--sidebar); min-width: 0; transition: margin .2s ease; }
.shell.collapsed .main { margin-inline-start: var(--sidebar-collapsed); }
.topbar { height: var(--topbar); background: rgba(255,255,255,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; padding: 0 24px; position: sticky; top: 0; z-index: 50; }
.topbar h1 { font-size: 17px; font-weight: 750; white-space: nowrap; }
.topbar .mobile-brand { display: none; }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.page { padding: 24px; max-width: 1480px; margin: 0 auto; }

/* ---------- search ---------- */
.gsearch { position: relative; width: min(420px, 38vw); margin-inline-start: 18px; }
.gsearch input { width: 100%; height: 38px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding-inline: 36px 12px; outline: none; }
.gsearch input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--brand-soft); }
.gsearch > svg { position: absolute; inset-inline-start: 11px; top: 11px; color: var(--text-3); }
.dropdown { position: absolute; top: calc(100% + 6px); background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 400; overflow: hidden; }
.gsearch .dropdown { inset-inline: 0; max-height: 70vh; overflow-y: auto; }
.sr-item { display: flex; gap: 10px; align-items: center; padding: 10px 14px; cursor: pointer; color: var(--text); border-bottom: 1px solid var(--border); }
.sr-item:last-child { border-bottom: 0; }
.sr-item:hover, .sr-item.sel { background: var(--surface-2); }
.sr-type { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); width: 62px; flex: none; }

/* ---------- icon buttons / user ---------- */
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: #fff; display: grid; place-items: center; cursor: pointer; color: var(--text-2); position: relative; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .dot { position: absolute; top: -4px; inset-inline-end: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--brand-2); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; border: 2px solid #fff; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; padding: 3px 6px 3px 3px; border-radius: 12px; }
.user-btn:hover { background: var(--surface-2); }
.user-btn .meta { text-align: start; line-height: 1.2; }
.user-btn .meta b { font-size: 13px; display: block; } .user-btn .meta small { color: var(--text-3); font-size: 11px; text-transform: capitalize; }
.menu { min-width: 220px; padding: 6px; inset-inline-end: 0; }
.menu button, .menu a { display: flex; width: 100%; gap: 10px; align-items: center; padding: 9px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--text); font-size: 13.5px; text-align: start; }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.notif-panel { width: 380px; inset-inline-end: 0; max-height: 70vh; display: flex; flex-direction: column; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-list { overflow-y: auto; }
.notif { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: #fcfaff; }
.notif.unread .n-title::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-2); margin-inline-end: 6px; vertical-align: middle; }
.n-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.n-title { font-weight: 650; font-size: 13px; } .n-msg { font-size: 12px; color: var(--text-2); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border-strong); background: #fff; color: var(--text); font-weight: 650; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background .15s, box-shadow .15s, transform .1s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--grad); color: #fff; border: 0; box-shadow: 0 4px 14px rgba(192,38,211,.25); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--red); border-color: #f5c2ca; } .btn.danger:hover { background: var(--red-bg); }
.btn.danger-solid { background: var(--red); color: #fff; border: 0; }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--gray-bg); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { width: 32px; padding: 0; height: 32px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- cards / grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 0; }
.card-h h3 { font-size: 14.5px; font-weight: 750; }
.card-b { padding: 16px 18px 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: border-color .15s, transform .15s; }
.stat:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.stat .s-top { display: flex; align-items: center; justify-content: space-between; }
.stat .s-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.stat .s-val { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.stat .s-ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; }
.stat.hl { background: linear-gradient(135deg, #faf5ff, #fff0f7); border-color: #ecdcfb; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; font-weight: 800; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }

/* ---------- lists in cards ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover .li-title { color: var(--brand-ink); }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 650; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.b-green { background: var(--green-bg); color: var(--green); } .b-yellow { background: var(--yellow-bg); color: var(--yellow); }
.b-orange { background: var(--orange-bg); color: var(--orange); } .b-red { background: var(--red-bg); color: var(--red); }
.b-blue { background: var(--blue-bg); color: var(--blue); } .b-gray { background: var(--gray-bg); color: var(--text-2); }
.b-purple { background: var(--brand-soft); color: var(--brand-ink); }
.top-badge { display: inline-flex; align-items: center; gap: 4px; height: 21px; padding: 0 8px 0 6px; border-radius: 6px; font-size: 10.5px; font-weight: 800; letter-spacing: .06em;
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2)); color: var(--gold-ink); box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 2px 6px rgba(229,168,35,.35); white-space: nowrap; vertical-align: middle; }
.top-badge.lg { height: 26px; font-size: 12px; padding: 0 10px 0 8px; }
.top-toggle { border: 1px dashed var(--border-strong); background: #fff; height: 26px; border-radius: 6px; padding: 0 8px; font-size: 11px; font-weight: 700; color: var(--text-3); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.top-toggle:hover { border-color: var(--gold-2); color: var(--gold-ink); }
.top-toggle.on { border: 0; background: linear-gradient(135deg, var(--gold-1), var(--gold-2)); color: var(--gold-ink); }
.fam-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.fam-name:hover { color: var(--brand-ink); }
.pill-count { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 6px; font-weight: 700; font-size: 12px; background: var(--gray-bg); color: var(--text-3); }
.pill-count.warn { background: var(--red-bg); color: var(--red); } .pill-count.info { background: var(--yellow-bg); color: var(--yellow); }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search-in { position: relative; flex: 1 1 240px; max-width: 360px; }
.search-in input { width: 100%; height: 38px; padding-inline: 34px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; outline: none; }
.search-in input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search-in svg { position: absolute; inset-inline-start: 11px; top: 11px; color: var(--text-3); }
.sel, .toolbar select { height: 38px; border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: 0 30px 0 12px; outline: none; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a87a3' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
[dir=rtl] .sel, [dir=rtl] .toolbar select { background-position: left 10px center; padding: 0 12px 0 30px; }
.sel:focus, .toolbar select:focus { border-color: var(--brand); }
.toolbar select { max-width: 220px; }
.chip-filter { height: 32px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--border); background: #fff; font-weight: 650; font-size: 12.5px; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip-filter.on { background: var(--text); color: #fff; border-color: var(--text); }
.chip-filter.gold.on { background: linear-gradient(135deg, var(--gold-1), var(--gold-2)); color: var(--gold-ink); border: 0; }
.segmented { display: inline-flex; background: var(--gray-bg); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: none; height: 30px; padding: 0 12px; border-radius: 8px; font-weight: 650; font-size: 12.5px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.segmented button.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; }
.dt th { text-align: start; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; user-select: none; }
.dt th.sortable { cursor: pointer; } .dt th.sortable:hover { color: var(--text); }
.dt th .arrow { margin-inline-start: 4px; opacity: .8; }
.dt td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.dt tbody tr { transition: background .1s; }
.dt tbody tr:hover { background: #fcfbff; }
.dt tbody tr.clickable { cursor: pointer; }
.dt tr.row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; gap: 10px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; }
.mobile-cards { display: none; }
.m-card { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.m-card .m-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.m-card .m-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 12.5px; }
.m-card .m-rows .k { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.m-card .m-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- empty / loading ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty .e-ic { width: 54px; height: 54px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 12px; }
.empty h4 { font-size: 15px; margin-bottom: 4px; color: var(--text); }
.empty p { margin: 0 0 14px; font-size: 13px; }
.empty.sm { padding: 22px 10px; } .empty.sm .e-ic { width: 40px; height: 40px; border-radius: 12px; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
.loading { display: grid; place-items: center; padding: 48px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, #f1f0f6 25%, #f8f7fb 50%, #f1f0f6 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(23,20,43,.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 500; animation: fade .15s ease; }
.modal-overlay.critical { z-index: 600; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 620px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
.modal.lg { max-width: 860px; } .modal.sm { max-width: 440px; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); gap: 12px; }
.modal-h h3 { font-size: 17px; font-weight: 750; }
.modal-b { padding: 20px 22px; overflow-y: auto; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 18px 18px; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 650; color: var(--text-2); margin-bottom: 6px; }
.field label .req { color: var(--brand-2); }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 12px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; min-height: 40px; }
.field textarea { min-height: 86px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field .hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.field.err input, .field.err select, .field.err textarea { border-color: var(--red); }
.field .err-msg { font-size: 12px; color: var(--red); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 22px; transition: .2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; inset-inline-start: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(16px); }
[dir=rtl] .switch input:checked + span::before { transform: translateX(-16px); }
.alert { padding: 11px 14px; border-radius: 10px; font-size: 13px; display: flex; gap: 9px; align-items: flex-start; }
.alert.error { background: var(--red-bg); color: #9b1c2e; } .alert.info { background: var(--blue-bg); color: #1e40af; } .alert.warn { background: var(--yellow-bg); color: #7a5a05; }

/* ---------- tags ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--border-strong); background: #fff; font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer; transition: all .12s; }
.tag:hover { border-color: var(--brand); color: var(--brand-ink); }
.tag.on { background: var(--brand-soft); border-color: #d6c1fb; color: var(--brand-ink); }
.tag.on.static { cursor: default; }
.tag .x { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; margin-inline-end: -4px; }
.tag .x:hover { background: rgba(91,33,182,.15); }
.tag-add { display: inline-flex; gap: 6px; }
.tag-add input { height: 30px; border: 1px dashed var(--border-strong); border-radius: 20px; padding: 0 12px; outline: none; font-size: 12.5px; width: 170px; }
.tag-add input:focus { border-style: solid; border-color: var(--brand); }
.info-section { padding: 18px 0; border-bottom: 1px solid var(--border); }
.info-section:last-child { border-bottom: 0; }
.info-section h4 { font-size: 14px; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.info-section > p { margin: 0 0 12px; font-size: 12.5px; color: var(--text-3); }
.pref-group { margin-bottom: 14px; } .pref-group:last-child { margin-bottom: 0; }
.pref-group .pg-label { font-size: 12px; font-weight: 700; color: var(--text-2); margin-bottom: 7px; }

/* ---------- profile ---------- */
.profile-head { padding: 22px; display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; position: relative; overflow: hidden; }
.profile-head::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--grad); }
.profile-head.is-top::before { background: linear-gradient(90deg, var(--gold-1), var(--gold-2)); height: 4px; }
.p-avatar { width: 64px; height: 64px; border-radius: 18px; background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 24px; font-weight: 800; flex: none; }
.p-main { flex: 1; min-width: 240px; }
.p-main h2 { font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.p-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; color: var(--text-2); font-size: 13px; }
.p-meta span b { color: var(--text); font-weight: 650; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; margin: 18px 0; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 650; font-size: 13.5px; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 7px; align-items: center; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--brand-ink); border-bottom-color: var(--brand); }
.tabs .tc { font-size: 11px; background: var(--gray-bg); color: var(--text-2); border-radius: 10px; padding: 0 7px; line-height: 18px; }
.tabs button.on .tc { background: var(--brand-soft); color: var(--brand-ink); }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 12px; }
.mini-stat { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.mini-stat b { display: block; font-size: 22px; font-weight: 800; } .mini-stat span { font-size: 12px; color: var(--text-2); font-weight: 600; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-3); font-weight: 600; } .kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* ---------- timeline / history ---------- */
.timeline { position: relative; padding-inline-start: 26px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; inset-inline-start: -26px; top: 1px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 2px solid var(--border-strong); }
.tl-dot svg { width: 10px; height: 10px; }
.tl-desc { font-weight: 600; font-size: 13.5px; }
.tl-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.tl-note { margin-top: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; font-size: 13px; white-space: pre-wrap; color: var(--text-2); }
.date-sep { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin: 6px 0 12px -26px; }

/* ---------- record cards (comms, notes) ---------- */
.rec { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.rec:last-child { border-bottom: 0; }
.rec-h { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.rec-title { font-weight: 700; font-size: 14px; }
.rec-meta { font-size: 12px; color: var(--text-3); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.rec-body { margin-top: 8px; font-size: 13.5px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.rec-body b { color: var(--text); font-weight: 650; }

/* ---------- attachments ---------- */
.att-list { display: flex; flex-direction: column; gap: 8px; }
.att { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.att .a-ic { width: 32px; height: 32px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; overflow: hidden; }
.att .a-ic img { width: 100%; height: 100%; object-fit: cover; }
.att .a-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 14px; text-align: center; color: var(--text-3); font-size: 13px; cursor: pointer; transition: all .15s; }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }

/* ---------- charts ---------- */
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; }
.chart-empty { height: 100%; display: grid; place-items: center; color: var(--text-3); font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-inline-end: 6px; }
.big-num { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.progress { height: 8px; background: var(--gray-bg); border-radius: 8px; overflow: hidden; }
.progress > div { height: 100%; background: var(--grad); border-radius: 8px; }
.rank { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.rank:last-child { border-bottom: 0; }
.rank .r-n { width: 22px; height: 22px; border-radius: 6px; background: var(--gray-bg); display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--text-2); }
.rank:nth-child(1) .r-n { background: linear-gradient(135deg, var(--gold-1), var(--gold-2)); color: var(--gold-ink); }
.rank .r-bar { flex: 1; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 22px; inset-inline-end: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 700; }
.toast { min-width: 260px; max-width: 380px; background: var(--text); color: #fff; padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; animation: pop .2s ease; }
.toast.error { background: #b4142c; } .toast.success .t-ic { color: #6ee7a8; }

/* ---------- settings ---------- */
.settings-layout { display: grid; grid-template-columns: 230px 1fr; gap: 18px; align-items: start; }
.side-tabs { padding: 8px; position: sticky; top: calc(var(--topbar) + 16px); }
.side-tabs button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 9px 12px; border: 0; background: none; border-radius: 9px; font-weight: 650; font-size: 13px; color: var(--text-2); cursor: pointer; text-align: start; }
.side-tabs button:hover { background: var(--surface-2); }
.side-tabs button.on { background: var(--brand-soft); color: var(--brand-ink); }
.side-tabs .grp { font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); padding: 12px 12px 4px; }
.cat-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.cat-row:last-child { border-bottom: 0; }
.cat-row .c-name { flex: 1; font-weight: 600; }
.cat-row.off .c-name { color: var(--text-3); text-decoration: line-through; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }

/* ---------- import ---------- */
.imp-table td, .imp-table th { padding: 8px 10px; font-size: 12.5px; }
.imp-table tr.st-error td { background: #fff6f7; } .imp-table tr.st-duplicate td { background: #fffbeb; }

/* ---------- bottom nav (mobile) ---------- */
.bottom-nav { display: none; }
.more-sheet { display: none; }

@media (max-width: 1100px) { .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main, .shell.collapsed .main { margin-inline-start: 0; }
  .topbar { padding: 0 12px; height: 54px; gap: 8px; }
  .topbar h1 { display: none; }
  .topbar .mobile-brand { display: flex; }
  .gsearch { width: auto; flex: 1; margin-inline-start: 4px; }
  .user-btn .meta { display: none; }
  .page { padding: 16px 14px 96px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 13px; } .stat .s-val { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .field input, .field select, .field textarea { font-size: 16px; }
  .desktop-table { display: none; }
  .mobile-cards { display: block; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal, .modal.lg, .modal.sm { max-width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; }
  .modal-f { border-radius: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .modal-f .btn { flex: 1; height: 44px; }
  .notif-panel { position: fixed; top: 58px; inset-inline: 8px; width: auto; }
  .settings-layout { grid-template-columns: 1fr; }
  .side-tabs { position: static; display: flex; overflow-x: auto; gap: 4px; }
  .side-tabs .grp { display: none; }
  .side-tabs button { width: auto; white-space: nowrap; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dd { margin-bottom: 10px; }
  .perm-grid { grid-template-columns: 1fr; }
  .toasts { inset-inline: 12px; bottom: 84px; } .toast { max-width: none; }
  .page-head h2 { font-size: 19px; }
  .toolbar { padding: 12px; } .search-in { max-width: none; flex-basis: 100%; }
  .btn { min-height: 40px; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; inset-inline: 0; height: calc(64px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); background: #fff; border-top: 1px solid var(--border); z-index: 300; justify-content: space-around; align-items: center; }
  .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 650; color: var(--text-3); border: 0; background: none; padding: 6px 0; min-height: 48px; cursor: pointer; }
  .bottom-nav a.active { color: var(--brand-ink); }
  .bottom-nav .fab { width: 50px; height: 50px; border-radius: 16px; background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(192,38,211,.35); margin-top: -18px; flex: none; }
  .more-sheet { display: block; position: fixed; inset: 0; z-index: 299; background: rgba(23,20,43,.4); }
  .more-sheet .sheet { position: absolute; bottom: 0; inset-inline: 0; background: #fff; border-radius: 20px 20px 0 0; padding: 10px 12px calc(76px + env(safe-area-inset-bottom, 0px)); animation: up .2s ease; }
  .more-sheet .sheet a, .more-sheet .sheet button { display: flex; gap: 12px; align-items: center; padding: 14px 12px; border-radius: 12px; font-weight: 650; color: var(--text); width: 100%; border: 0; background: none; font-size: 15px; min-height: 48px; }
  .more-sheet .sheet a:active, .more-sheet .sheet button:active { background: var(--surface-2); }
}
@keyframes up { from { transform: translateY(100%); } }
@media (max-width: 400px) { .stats { grid-template-columns: 1fr 1fr; } .stat .s-val { font-size: 21px; } }
@media (min-width: 769px) { .bottom-nav, .more-sheet, .mobile-cards { display: none !important; } }
