:root {
  color-scheme: light;
  --ink: #15202b;
  --muted: #77828f;
  --line: #e6e9ee;
  --panel: #ffffff;
  --canvas: #f5f7f9;
  --blue: #2868f0;
  --blue-soft: #edf3ff;
  --green: #168463;
  --green-soft: #e7f7f1;
  --amber: #9a6800;
  --amber-soft: #fff4d7;
  --red: #b64152;
  --shadow: 0 14px 40px rgba(25, 38, 54, .08);
  font-family: "Noto Sans SC", "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top right, #e8efff, transparent 45%), var(--canvas); }
.login-card { width: min(420px, 100%); padding: 42px; background: var(--panel); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; color: #fff; background: var(--ink); border-radius: 15px; font-weight: 700; font-size: 22px; }
.brand-mark.small { width: 34px; height: 34px; border-radius: 11px; font-size: 17px; }
.eyebrow { margin: 0 0 8px; color: var(--blue); letter-spacing: .13em; font-size: 11px; font-weight: 700; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(27px, 4vw, 36px); letter-spacing: -.04em; }
h2 { margin-bottom: 7px; font-size: 22px; letter-spacing: -.03em; }
h3 { margin-bottom: 5px; font-size: 16px; }
.muted-copy { color: var(--muted); line-height: 1.65; font-size: 13px; }
.stack-form { display: grid; gap: 16px; margin-top: 30px; }
.stack-form label, .member-search { display: grid; gap: 8px; color: #4e5b68; font-size: 12px; font-weight: 600; }
input { width: 100%; padding: 12px 13px; color: var(--ink); background: #fbfcfd; border: 1px solid var(--line); border-radius: 10px; outline: none; transition: border-color .18s, box-shadow .18s; }
input:focus { border-color: #8eafff; box-shadow: 0 0 0 3px rgba(40, 104, 240, .12); }
.primary-button, .secondary-button, .ghost-button { border: 0; border-radius: 10px; padding: 12px 16px; font-weight: 700; transition: transform .15s, box-shadow .15s, background .15s; }
.primary-button { color: white; background: var(--blue); box-shadow: 0 8px 18px rgba(40, 104, 240, .22); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); }
.secondary-button { color: var(--blue); background: var(--blue-soft); }
.ghost-button { color: var(--muted); background: transparent; }
.ghost-button:hover { color: var(--ink); background: #eef1f5; }
.full-width { width: 100%; }
.compact { padding: 10px 14px; font-size: 12px; }
.form-error { margin: 0; color: var(--red); font-size: 12px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 18px; color: #dbe3ed; background: #111923; }
.brand-lockup { display: flex; align-items: center; gap: 11px; padding: 0 9px; }
.brand-lockup strong { display: block; }
.brand-lockup strong { color: #fff; font-size: 14px; }
.side-nav { display: grid; gap: 5px; margin-top: 56px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 12px 13px; color: #8f9bab; border-radius: 10px; text-decoration: none; font-size: 13px; }
.side-nav a.active { color: #fff; background: #253244; }
.nav-icon { width: 20px; text-align: center; font-size: 17px; }
.connection-dot { display: flex; align-items: center; gap: 8px; padding: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
.connection-dot i { width: 7px; height: 7px; background: #43d59d; border-radius: 50%; box-shadow: 0 0 0 4px rgba(67, 213, 157, .12); }

.content-shell { min-width: 0; min-height: 100vh; display: flex; flex-direction: column; padding: 0 clamp(22px, 4vw, 60px) 70px; }
.display-area { min-width: 0; flex: 1; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 88px; padding: 18px 0; margin-bottom: 32px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin-bottom: 0; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.header-account-picker { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 700; }
.header-account-picker select { min-width: 145px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; }
.header-button { white-space: nowrap; }
.account-label { color: var(--muted); font-size: 12px; }
.icon-button { width: 38px; height: 38px; color: #566474; background: #fff; border: 1px solid var(--line); border-radius: 10px; font-size: 20px; }
.icon-button:hover { color: var(--blue); border-color: #b8caf5; }
.toast { position: fixed; top: 24px; right: 24px; z-index: 20; padding: 12px 16px; color: #fff; background: #1b2938; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { background: var(--red); }
.overview-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { min-height: 136px; padding: 21px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.stat-card span, .stat-card small { display: block; color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin: 16px 0 4px; font-size: 32px; letter-spacing: -.05em; }
.accent-card { color: #fff; background: var(--blue); border-color: var(--blue); }
.accent-card span, .accent-card small { color: #cedcff; }
.default-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px 26px; margin-bottom: 42px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.default-panel p:last-child { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.command-panel { padding: 24px 26px; margin-bottom: 42px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.command-heading { align-items: flex-start; margin-bottom: 18px; }
.command-heading p { margin-bottom: 0; }
.command-editor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 17px; }
.command-card { padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: #fbfcfd; }
.command-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.command-card-heading h3 { margin: 0; }
.command-card-heading span { color: var(--muted); font-size: 11px; }
.trigger-list { display: grid; gap: 7px; }
.trigger-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.trigger-row input { padding: 9px 10px; background: #fff; }
.remove-trigger { padding: 0 9px; color: var(--red); background: #fff0f1; border: 0; border-radius: 8px; font-size: 11px; }
.add-trigger { margin: 9px 0 14px; }
.command-field { display: grid; gap: 6px; margin-top: 11px; color: #4e5b68; font-size: 11px; font-weight: 600; }
.command-field select, .command-field textarea { width: 100%; padding: 9px 10px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: 12px; }
.command-field textarea { min-height: 73px; resize: vertical; line-height: 1.5; }
.command-field select:focus, .command-field textarea:focus { border-color: #8eafff; outline: none; box-shadow: 0 0 0 3px rgba(40, 104, 240, .12); }
.command-editor [disabled] { cursor: not-allowed; opacity: .55; }
.toggle-wrap { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 12px; cursor: pointer; }
.toggle-wrap input { position: absolute; opacity: 0; width: 0; }
.toggle { display: inline-flex; align-items: center; width: 48px; height: 28px; padding: 3px; background: #dce1e8; border-radius: 20px; transition: background .18s; }
.toggle i { width: 22px; height: 22px; background: #fff; border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,.16); transition: transform .18s; }
.toggle-wrap input:checked + .toggle { background: var(--blue); }
.toggle-wrap input:checked + .toggle i { transform: translateX(20px); }
.toggle-wrap b { min-width: 44px; color: var(--ink); font-size: 12px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-heading h2 { margin-bottom: 0; }
.search-box, .member-search { display: flex; align-items: center; gap: 8px; min-width: 245px; padding: 0 12px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.search-box input, .member-search input { padding: 10px 0; border: 0; box-shadow: none; background: transparent; }
.group-list-header, .group-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(88px, auto) minmax(112px, auto) minmax(115px, auto) 58px; align-items: center; gap: 18px; }
.group-list-header { padding: 0 19px 9px; color: var(--muted); font-size: 11px; font-weight: 700; }
.groups-list { display: grid; gap: 10px; }
.group-row { padding: 17px 19px; background: #fff; border: 1px solid var(--line); border-radius: 13px; transition: border-color .15s, transform .15s, box-shadow .15s; }
.group-row:hover { border-color: #c7d2e5; box-shadow: 0 8px 22px rgba(25, 38, 54, .05); transform: translateY(-1px); }
.group-title { min-width: 0; }
.group-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-title strong { font-size: 14px; }
.group-actions { display: flex; justify-content: flex-end; }
.tag, .status-badge, .count-pill { display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; border-radius: 99px; font-size: 11px; font-weight: 700; }
.tag { padding: 5px 8px; color: var(--muted); background: #f0f2f5; }
.tag.openchat { color: var(--blue); background: var(--blue-soft); }
.tag.admin { color: var(--green); background: var(--green-soft); }
.tag.no-admin { color: var(--muted); background: #f0f2f5; }
.status-badge { padding: 6px 10px; color: var(--muted); background: #f0f2f5; }
.status-badge.on { color: var(--red); background: #fff0f1; }
.status-badge.inherit { color: var(--amber); background: var(--amber-soft); }
.status-badge.off { color: var(--green); background: var(--green-soft); }
.detail-button { padding: 8px 11px; color: var(--blue); background: transparent; border: 1px solid #cbd8f4; border-radius: 8px; font-size: 12px; font-weight: 700; }
.detail-button:hover { background: var(--blue-soft); }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-icon { margin-bottom: 12px; font-size: 32px; color: #a8b2be; }
.empty-state h3 { color: var(--ink); }
.empty-state p { margin-bottom: 0; font-size: 13px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 22px; background: rgba(10, 18, 29, .48); backdrop-filter: blur(5px); }
.detail-modal { position: relative; width: min(650px, 100%); max-height: min(850px, 92vh); overflow: auto; padding: 30px; background: #fff; border-radius: 20px; box-shadow: 0 25px 80px rgba(10, 18, 29, .25); }
.line-login-modal { position: relative; width: min(480px, 100%); max-height: min(850px, 92vh); overflow: auto; padding: 30px; background: #fff; border-radius: 20px; box-shadow: 0 25px 80px rgba(10, 18, 29, .25); }
.modal-close { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; color: var(--muted); background: #f3f5f7; border: 0; border-radius: 50%; font-size: 22px; line-height: 1; }
.detail-header { display: flex; align-items: center; gap: 14px; padding-right: 34px; margin-bottom: 25px; }
.detail-avatar { display: grid; place-items: center; width: 54px; height: 54px; color: var(--blue); background: var(--blue-soft); border-radius: 16px; font-size: 22px; font-weight: 700; }
.detail-header h2 { margin-bottom: 3px; }
.detail-header .eyebrow { margin-bottom: 5px; }
.mono { font-family: "DM Sans", monospace; font-size: 11px; }
.inline-notice { padding: 12px 14px; margin-bottom: 18px; color: var(--amber); background: var(--amber-soft); border-radius: 10px; font-size: 12px; line-height: 1.6; }
.detail-section { padding-top: 23px; margin-top: 23px; border-top: 1px solid var(--line); }
.detail-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.detail-section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.count-pill { min-width: 25px; padding: 5px 8px; color: var(--blue); background: var(--blue-soft); }
.radio-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 14px; }
.radio-card { position: relative; display: block; cursor: pointer; }
.radio-card input { position: absolute; opacity: 0; }
.radio-card span { display: block; height: 100%; padding: 13px 11px; border: 1px solid var(--line); border-radius: 10px; }
.radio-card b, .radio-card small { display: block; }
.radio-card b { font-size: 12px; }
.radio-card small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.radio-card input:checked + span { color: var(--blue); background: var(--blue-soft); border-color: #9eb8f5; }
.radio-card input:disabled + span { cursor: not-allowed; opacity: .45; }
.selected-admins { display: flex; flex-wrap: wrap; gap: 7px; min-height: 16px; margin-bottom: 12px; }
.admin-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; color: #31465b; background: #eef3f8; border-radius: 8px; font-size: 11px; }
.admin-chip button { padding: 0; color: #738395; background: none; border: 0; font-size: 15px; line-height: 1; }
.member-search { min-width: 0; margin-bottom: 9px; }
.member-results { display: grid; gap: 4px; max-height: 210px; overflow: auto; padding: 4px; margin-bottom: 13px; border: 1px solid var(--line); border-radius: 10px; }
.member-result { display: flex; align-items: center; gap: 10px; padding: 9px; border-radius: 8px; cursor: pointer; }
.member-result:hover { background: #f5f7fa; }
.member-result input { width: auto; accent-color: var(--blue); }
.member-result strong, .member-result small { display: block; }
.member-result strong { font-size: 12px; }
.member-result small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.login-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; margin-bottom: 20px; background: #f1f4f7; border-radius: 10px; }
.login-tab { padding: 9px; color: var(--muted); background: transparent; border: 0; border-radius: 7px; font-size: 12px; font-weight: 700; }
.login-tab.active { color: var(--ink); background: #fff; box-shadow: 0 2px 8px rgba(25, 38, 54, .08); }
.line-login-panel { min-height: 300px; }
.qr-placeholder, .line-qr-image { display: grid; place-items: center; width: 280px; height: 280px; margin: 0 auto 15px; border-radius: 14px; }
.qr-placeholder { color: var(--muted); background: #f5f7f9; border: 1px dashed #cfd6de; text-align: center; font-size: 12px; }
.line-qr-image { object-fit: contain; border: 1px solid var(--line); }
.center-copy { text-align: center; }
.pincode { padding: 10px 12px; margin: 10px 0; color: var(--amber); background: var(--amber-soft); border-radius: 8px; text-align: center; font-size: 12px; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; min-height: auto; padding: 15px 18px; }
  .side-nav { display: none; }
  .overview-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 650px) {
  .content-shell { padding: 26px 16px 50px; }
  .topbar, .section-heading, .default-panel { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .header-account-picker { flex: 1 1 100%; }
  .header-account-picker select { flex: 1; }
  .search-box { width: 100%; }
  .command-editor { grid-template-columns: 1fr; }
  .group-list-header { display: none; }
  .group-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .group-row > :nth-child(2), .group-row > :nth-child(3), .group-row > :nth-child(4) { grid-column: 1; justify-self: start; }
  .group-row > :nth-child(2) { grid-row: 2; }
  .group-row > :nth-child(3) { grid-row: 3; }
  .group-row > :nth-child(4) { grid-row: 4; }
  .group-row > :last-child { grid-row: 1 / span 4; grid-column: 2; align-self: center; }
  .radio-grid { grid-template-columns: 1fr; }
  .detail-modal { padding: 24px 18px; }
}
