/* TLGM shared UI */
.tlgm-stats-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tlgm-stat-pill { background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.tlgm-stat-pill .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.tlgm-stat-pill .dot.dps { background: #e05252; }
.tlgm-stat-pill .dot.tank { background: #5294e0; }
.tlgm-stat-pill .dot.healer { background: #52c87a; }
.tlgm-search-wrap input { width: 100%; max-width: 360px; }
.tlgm-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.tlgm-members-table { width: 100%; min-width: 900px; border-collapse: collapse; font-size: 13px; }
.tlgm-members-table th, .tlgm-members-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tlgm-members-table th { font-size: 11px; text-transform: uppercase; color: var(--text-muted); background: var(--surface); }
.tlgm-members-table th.sortable { cursor: pointer; }
.tlgm-members-table td.num, .tlgm-members-table th.num { text-align: right; }
.tlgm-members-table { table-layout: auto; }
.tlgm-col-avatar { width: 48px; }
.tlgm-col-name { min-width: 120px; max-width: 200px; }
.tlgm-name-cell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tlgm-col-class, .tlgm-col-guild-role { white-space: nowrap; }
.tlgm-col-guild { min-width: 120px; white-space: nowrap; }
.tlgm-col-weapons { min-width: 110px; white-space: nowrap; }
.tlgm-col-activity { min-width: 100px; }
.tlgm-col-rsvp { width: 42px; }
.tlgm-col-points { width: 56px; }
.tlgm-col-actions { width: 118px; }
.tlgm-guild-tag { white-space: nowrap; display: inline-block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.tlgm-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
}
.tlgm-icon-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    flex-shrink: 0;
}
.tlgm-owner-mark { flex-shrink: 0; font-size: 14px; line-height: 1; }
.tlgm-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.tlgm-avatar-img { object-fit: cover; display: block; padding: 0; font-size: 0; background: var(--surface); }
.tlgm-avatar-tank { background: rgba(82,148,224,.2); color: #5294e0; }
.tlgm-avatar-dps { background: rgba(224,82,82,.2); color: #e05252; }
.tlgm-avatar-healer { background: rgba(82,200,122,.2); color: #52c87a; }
.tlgm-avatar-none { background: var(--surface); color: var(--text-muted); }
.tlgm-avatar-sm { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.tlgm-role-badge, .tlgm-gr-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; display: inline-block; }
.tlgm-role-tank { background: rgba(82,148,224,.15); color: #5294e0; }
.tlgm-role-dps { background: rgba(224,82,82,.15); color: #e05252; }
.tlgm-role-healer { background: rgba(82,200,122,.15); color: #52c87a; }
.tlgm-role-none { background: var(--surface); color: var(--text-muted); }
.tlgm-gr-leader { background: rgba(201,162,39,.15); color: #c9a227; }
.tlgm-gr-advisor { background: rgba(139,107,255,.15); color: #8b6bff; }
.tlgm-gr-guardian { background: rgba(82,148,224,.15); color: #5294e0; }
.tlgm-gr-member { background: var(--surface); color: var(--text-muted); }
.tlgm-guild-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.tlgm-guild-tag.tlgm-unassigned { color: var(--text-muted); border-color: var(--border); }
.tlgm-points-badge { font-size: 12px; font-weight: 700; color: #c9a227; background: rgba(201,162,39,.12); border: 1px solid rgba(201,162,39,.3); padding: 2px 9px; border-radius: 20px; }
.tlgm-points-badge.negative { color: #e05252; background: rgba(224,82,82,.12); border-color: rgba(224,82,82,.3); }
.tlgm-activity { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.tlgm-activity-bar { width: 64px; height: 6px; border-radius: 4px; background: var(--surface); overflow: hidden; }
.tlgm-activity-fill { height: 100%; border-radius: 4px; }
.tlgm-act-high { background: #52c87a; } .tlgm-act-mid { background: #c9a227; } .tlgm-act-low { background: #e05252; }
.tlgm-role-selector { display: flex; gap: 8px; margin: 8px 0 12px; }
.tlgm-role-opt { flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: center; font-size: 13px; }
.tlgm-role-opt-dps.selected { border-color: #e05252; background: rgba(224,82,82,.1); color: #e05252; }
.tlgm-role-opt-tank.selected { border-color: #5294e0; background: rgba(82,148,224,.1); color: #5294e0; }
.tlgm-role-opt-healer.selected { border-color: #52c87a; background: rgba(82,200,122,.1); color: #52c87a; }
.tlgm-log-entry { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.tlgm-log-delta { min-width: 44px; text-align: center; font-weight: 700; padding: 4px 8px; border-radius: var(--radius); }
.tlgm-log-delta.positive { background: rgba(82,200,122,.15); color: #52c87a; }
.tlgm-log-delta.negative { background: rgba(224,82,82,.15); color: #e05252; }
.tlgm-empty { text-align: center; padding: 32px 16px; color: var(--text-muted); }
.tlgm-guilds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.tlgm-guild-card { border: 1px solid var(--guild-color, var(--border)); border-left: 4px solid var(--guild-color, var(--border)); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.tlgm-guild-card-head { display: flex; align-items: center; gap: 8px; padding: 12px; background: var(--surface); flex-wrap: wrap; }
.tlgm-guild-icon { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); background: var(--surface); }
.tlgm-guild-name { font-weight: 700; flex: 1; min-width: 120px; }
.tlgm-guild-discord-ok { font-size: 11px; color: #52c87a; white-space: nowrap; }
.tlgm-guild-active-ok { font-size: 11px; color: #52c87a; white-space: nowrap; }
.tlgm-guild-inactive { font-size: 11px; color: var(--muted); white-space: nowrap; }
.tlgm-guild-card-inactive { opacity: 0.88; }
.tlgm-guild-setup-wrap {
    display: inline-flex;
    align-items: center;
}
.tlgm-guild-setup-wrap.is-disabled {
    cursor: help;
}
.tlgm-guild-setup.is-disabled,
.tlgm-guild-setup:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    filter: grayscale(0.85);
}
.tlgm-guild-invite-bar { margin-bottom: 12px; }
.tlgm-guild-invite-actions { gap: 8px; flex-wrap: wrap; }
.tlgm-guild-invite-actions a.primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius);
}
.tlgm-guild-invite-btn {
    flex-shrink: 0;
    min-width: 32px;
    padding: 0 8px;
}
.tlgm-guild-swatch { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.tlgm-guild-name { font-weight: 700; flex: 1; }
.tlgm-color-picker { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 12px; align-items: center; }
.tlgm-color-swatch.selected {
    box-shadow: 0 0 0 3px rgba(255,255,255,0.2);
}
.tlgm-party-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .tlgm-party-layout { grid-template-columns: 1fr; } }
.tlgm-parties-col { min-width: 0; }
.tlgm-party-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-3);
    align-items: start;
}
.tlgm-party-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    overflow: hidden;
    min-width: 0;
}
.tlgm-party-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-wrap: nowrap;
}
.tlgm-party-card-head .tlgm-ep-name { flex: 1; min-width: 0; }
.tlgm-pool-col { display: flex; flex-direction: column; gap: 12px; }
.tlgm-role-section { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tlgm-rsh { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 13px; font-weight: 700; color: #fff; }
.tlgm-rsh-tank { background: rgba(82,148,224,.35); }
.tlgm-rsh-dps { background: rgba(224,82,82,.35); }
.tlgm-rsh-healer { background: rgba(82,200,122,.35); }
.tlgm-rsh-vacation { background: rgba(91,163,224,.15); color: #5ba3e0; }
.tlgm-rsh-count { font-size: 11px; background: rgba(0,0,0,.2); padding: 2px 8px; border-radius: 20px; }
.tlgm-role-list { background: var(--surface-2); max-height: 220px; overflow-y: auto; }
.tlgm-role-list.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.tlgm-pool-member { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: grab; font-size: 13px; }
.tlgm-pool-member.dragging { opacity: .4; }
.tlgm-pm-tank { border-left: 3px solid #5294e0; }
.tlgm-pm-dps { border-left: 3px solid #e05252; }
.tlgm-pm-healer { border-left: 3px solid #52c87a; }
.tlgm-pm-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.tlgm-weapon-icons { font-size: 12px; opacity: .85; }
.tlgm-empty-role { font-size: 12px; color: var(--text-muted); padding: 14px; text-align: center; }
.tlgm-party-rows { display: flex; flex-direction: column; }
.tlgm-party-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); min-height: 38px; font-size: 13px; flex-wrap: nowrap; }
.tlgm-party-row.pr-tank { background: rgba(82,148,224,.18); }
.tlgm-party-row.pr-dps { background: rgba(224,82,82,.18); }
.tlgm-party-row.pr-healer { background: rgba(82,200,122,.18); }
.tlgm-party-row.pr-empty { color: var(--text-muted); }
.tlgm-party-row.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.tlgm-pr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.tlgm-battle-class-icon { height: 24px; width: auto; max-width: 52px; object-fit: contain; border-radius: 4px; flex-shrink: 0; }
.tlgm-pool-member .tlgm-battle-class-icon { margin-left: auto; }
.tlgm-slot-remove { border: none; background: none; color: var(--text-muted); cursor: pointer; opacity: 0; }
.tlgm-party-row:hover .tlgm-slot-remove { opacity: 1; }
.tlgm-add-party-card { border: 1px dashed var(--border); border-radius: var(--radius); min-height: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: transparent; color: var(--text-muted); cursor: pointer; }
.tlgm-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tlgm-status-dot.status-in { background: #52c87a; box-shadow: 0 0 4px #52c87a; }
.tlgm-status-dot.status-out { background: #e05252; box-shadow: 0 0 4px #e05252; }
.tlgm-status-dot.status-pending { background: var(--text-muted); }
.tlgm-drag-handle { color: var(--text-muted); font-size: 12px; }
.tlgm-ev-del { font-size: 9px; opacity: .6; margin-left: 4px; }
.tlgm-back-btn { border: none; background: none; color: var(--text-muted); cursor: pointer; margin-bottom: 12px; padding: 4px 8px; font: inherit; }
.tlgm-back-btn:hover { color: var(--text); background: var(--surface-2); border-radius: var(--radius); }
.tlgm-ed-badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px; text-transform: uppercase; }
.tlgm-ed-badge.gold { background: rgba(201,162,39,.15); color: #c9a227; }
.tlgm-ed-badge.muted-badge { background: var(--surface-2); color: var(--text-muted); }
.tlgm-ep-name { background: transparent; border: none; font-weight: 700; color: var(--accent); font: inherit; width: 100%; }
.tlgm-hint { font-size: 12px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); margin-bottom: 12px; }
.tlgm-filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tlgm-stats-toolbar { margin-bottom: 12px; padding: 12px 14px; }
.tlgm-stats-toolbar input[type="date"] { min-width: 150px; }
.tlgm-filter-tab { padding: 5px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; cursor: pointer; }
.tlgm-filter-tab.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.tlgm-vac-badge { font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.tlgm-vac-badge.badge-active { background: rgba(201,162,39,.18); color: #c9a227; }
.tlgm-vac-badge.badge-upcoming { background: rgba(139,107,255,.15); color: #8b6bff; }
.tlgm-vac-badge.badge-past { background: var(--surface); color: var(--text-muted); }
.tlgm-wl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.tlgm-item-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; gap: 10px; position: relative; background: var(--surface-2); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.tlgm-item-card:hover { border-color: rgba(139,107,255,.45); box-shadow: 0 0 0 1px rgba(139,107,255,.15); }
.tlgm-item-card.wishlisted { border-color: rgba(139,107,255,.4); }
.tlgm-item-icon { width: 52px; height: 52px; border-radius: var(--radius); display: grid; place-items: center; font-size: 22px; background: rgba(8,6,18,.55); border: 1px solid rgba(139,75,240,.35); flex-shrink: 0; overflow: hidden; }
.tlgm-item-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tlgm-item-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.tlgm-item-grade { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: rgba(139,75,240,.2); color: #b06aff; display: inline-block; margin-top: 4px; }
.tlgm-grade-51 { background: rgba(255,140,50,.2); color: #ffb347; }
.tlgm-grade-41 { background: rgba(139,75,240,.25); color: #c9a0ff; }
.tlgm-grade-31 { background: rgba(82,148,224,.2); color: #7eb8ff; }
.tlgm-grade-21 { background: rgba(82,200,122,.2); color: #7ddea0; }
.tlgm-grade-11 { background: rgba(180,180,180,.15); color: #bbb; }
.tlgm-wl-pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.tlgm-wish-star { position: absolute; top: 8px; right: 8px; border: none; background: none; cursor: pointer; font-size: 15px; z-index: 2; }
.tlgm-wish-star.active { color: #c9a227; }
.tlgm-wish-star.received { cursor: default; color: #4caf50; font-weight: 700; pointer-events: none; }
.tlgm-item-card.received { opacity: 0.85; }
.tlgm-item-detail-card { max-width: min(520px, 94vw); max-height: 88vh; overflow: auto; padding: 0; position: relative; }
.tlgm-item-detail-close { position: absolute; top: 10px; right: 10px; border: none; background: var(--surface); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; z-index: 2; }
.tlgm-item-detail-head { display: flex; gap: 14px; padding: 18px 18px 12px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.tlgm-item-detail-icon { width: 72px; height: 72px; border-radius: 10px; background: rgba(8,6,18,.55); border: 1px solid rgba(139,75,240,.35); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.tlgm-item-detail-icon img { width: 100%; height: 100%; object-fit: contain; }
.tlgm-item-detail-title { margin: 0 0 6px; font-size: 1.15rem; line-height: 1.25; }
.tlgm-item-detail-body { padding: 12px 18px 18px; }
.tlgm-item-detail-section { margin-top: 14px; }
.tlgm-item-detail-section:first-child { margin-top: 0; }
.tlgm-item-detail-section h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.tlgm-item-detail-stat { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 13px; }
.tlgm-item-detail-stat span:last-child { color: #52c87a; font-weight: 600; }
.tlgm-item-detail-box { padding: 10px 12px; border-radius: 8px; background: rgba(139,75,240,.1); border: 1px solid rgba(139,75,240,.2); font-size: 13px; }
.tlgm-item-detail-resonance { font-size: 12px; color: #7eb8ff; padding: 2px 0; }
.tlgm-item-detail-bonus { color: #52c87a; font-size: 13px; margin-top: 4px; }
.tlgm-wish-star.modal-wish { position: static; font-size: 22px; padding: 4px; }
.tlgm-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .tlgm-settings-grid { grid-template-columns: 1fr; } .tlgm-settings-grid .card[style*="span 2"] { grid-column: span 1 !important; } }
.tlgm-setting-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.tlgm-role-chip { font-size: 12px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); margin: 4px 4px 0 0; display: inline-block; }
.tlgm-roles-list { margin-top: 10px; }
.tlgm-admin-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 6px; }
.tlgm-access-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.tlgm-access-badge.pending { background: rgba(201, 162, 39, 0.15); color: #c9a227; }
.tlgm-access-badge.active { background: rgba(82, 200, 122, 0.15); color: #52c87a; }
body.product-tlgm main {
    max-width: none;
    padding-bottom: 20px;
}
@media (max-width: 900px) {
    .topbar {
        grid-template-columns: 1fr;
    }
    .product-switcher {
        justify-self: start;
    }
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
    overflow: hidden;
}
.topbar-brand > div {
    min-width: 0;
    overflow: hidden;
}
.topbar-brand h1 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #22d3ee);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    box-shadow: var(--shadow);
    letter-spacing: .02em;
}
h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    line-height: 1.2;
}
.topbar p {
    margin: 2px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}
.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.session-chip {
    font-size: 12.5px;
    color: var(--text-muted);
    white-space: nowrap;
}
.session-perms {
    font-size: 12px;
    color: var(--text-subtle);
    max-width: min(360px, 38vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (max-width: 720px) {
    .session-perms { display: none; }
}
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-height: 0;
    padding: 0;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.theme-toggle:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border-strong);
}
.theme-toggle svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

p { margin: 0 0 var(--space-3); color: var(--text-muted); }

.grid { display: grid; grid-template-columns: 1fr; gap: var(--space-4); }
.app-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: var(--space-4);
    align-items: start;
}
.sidebar { position: sticky; top: var(--space-4); }
.content-stack { display: grid; gap: var(--space-4); }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--duration) var(--ease), background-color var(--duration) var(--ease);
}
.card .row + .row { margin-top: var(--space-1); }

/* ---------- Rows / forms ---------- */
.row {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: var(--space-3);
}
.row:last-child { margin-bottom: 0; }
label {
    display: block;
    margin-bottom: var(--space-1);
    font-weight: 550;
    font-size: 12.5px;
    letter-spacing: .005em;
    color: var(--text-muted);
}
select,
input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="search"],
input[type="email"],
input[type="number"],
textarea,
button {
    font-family: inherit;
    font-size: 13.5px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 8px 12px;
    min-height: 36px;
    line-height: 1.4;
    transition: border-color var(--duration) var(--ease), background-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
select, input[type="text"], input[type="password"], input[type="date"], input[type="time"], input[type="search"], input[type="email"], input[type="number"], textarea {
    width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
input:focus,
select:focus,
textarea:focus,
button:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
    opacity: .55;
    cursor: not-allowed;
}
input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
select[multiple] {
    background-image: none;
    padding-right: 12px;
    min-height: 110px;
}

/* ---------- Enhanced inputs ---------- */
input[type="text"]:hover:not(:focus):not(:disabled),
input[type="password"]:hover:not(:focus):not(:disabled),
input[type="date"]:hover:not(:focus):not(:disabled),
input[type="time"]:hover:not(:focus):not(:disabled),
input[type="email"]:hover:not(:focus):not(:disabled),
input[type="number"]:hover:not(:focus):not(:disabled),
input[type="search"]:hover:not(:focus):not(:disabled),
textarea:hover:not(:focus):not(:disabled),
select:hover:not(:focus):not(:disabled) {
    border-color: var(--border-strong);
    background: var(--surface-2);
}

input[type="time"]::-webkit-calendar-picker-indicator,
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.6);
    cursor: pointer;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.field label { margin-bottom: 0; transition: color var(--duration) var(--ease); }
.field:focus-within > label { color: var(--accent-fg); }

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.input-wrap .input-icon {
    position: absolute;
    left: 11px;
    color: var(--text-subtle);
    font-size: 13px;
    pointer-events: none;
    transition: color var(--duration) var(--ease);
    z-index: 1;
}
.input-wrap:focus-within .input-icon { color: var(--accent); }
.input-wrap input,
.input-wrap textarea,
.input-wrap select { padding-left: 34px; }

.targets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-2);
}
.target-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-2) var(--space-3);
    background: var(--surface-2);
    cursor: pointer;
    transition: background-color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.target-item:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.target-item input[type="checkbox"] { margin: 0; }

/* ---------- Buttons ---------- */
button {
    cursor: pointer;
    font-weight: 550;
    letter-spacing: 0.005em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}
button:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--border-strong);
}
button:active:not(:disabled) {
    transform: translateY(1px);
}
button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
button.primary:hover:not(:disabled) {
    background: color-mix(in srgb, var(--accent) 88%, #000);
    border-color: color-mix(in srgb, var(--accent) 88%, #000);
}
button.success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
button.success:hover:not(:disabled) {
    background: color-mix(in srgb, var(--success) 88%, #000);
    border-color: color-mix(in srgb, var(--success) 88%, #000);
}
button.danger {
    background: transparent;
    border-color: var(--border);
    color: var(--danger-fg);
}
button.danger:hover:not(:disabled) {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger);
}

/* ---------- Tables ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
th, td {
    border-bottom: 1px solid var(--border);
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
}
th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--surface-2);
    position: sticky;
    top: 0;
}
tbody tr {
    transition: background-color var(--duration) var(--ease);
}
tbody tr:hover {
    background: var(--surface-2);
}
tbody tr:last-child td { border-bottom: 0; }

#inviteTable a {
    color: var(--link);
    word-break: break-all;
}

/* ---------- Status / utility ---------- */
.muted { color: var(--text-muted); }
.status-ok,
.status-warn,
.status-off {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    letter-spacing: .01em;
    text-transform: lowercase;
}
.status-ok::before,
.status-warn::before,
.status-off::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    background: currentColor;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 20%, transparent);
}
.status-ok { color: var(--success-fg); background: var(--success-soft); }
.status-warn { color: var(--warn-fg); background: var(--warn-soft); }
.status-off { color: var(--danger-fg); background: var(--danger-soft); }

/* ---------- Tabs ---------- */
.tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.sidebar .tab-bar {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 2px;
}
.tab-btn {
    min-width: 140px;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-weight: 500;
    justify-content: flex-start;
    min-height: 38px;
    padding: 8px 12px;
}
.tab-btn:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text);
    border-color: transparent;
}
.tab-btn.active {
    background: var(--accent-soft);
    color: var(--accent-fg);
    border-color: transparent;
    box-shadow: inset 2px 0 0 var(--accent);
}
:root[data-theme="light"] .tab-btn.active {
    background: var(--accent-soft);
    color: var(--accent-fg);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 220ms var(--ease); }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

.user-guild-select { width: 100%; min-height: 110px; }
.guild-icon { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--surface); border: 1px solid var(--border); }
.guild-icon-fallback { display: inline-grid; place-items: center; border-radius: 50%; font-size: 12px; font-weight: 700; color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); }
.guild-checkbox-list { display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow: auto; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.guild-checkbox-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.guild-checkbox-item:hover { background: rgba(139,75,240,.08); }
.guild-checkbox-item span { font-size: 13px; line-height: 1.2; }
.guild-checkbox-item input { margin: 0; }
.server-select-row { display: flex; align-items: center; gap: 10px; }
.server-select-row .guild-icon { width: 32px; height: 32px; }
.tlgm-guild-icon { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); background: var(--surface); }

/* ---------- Subpanels ---------- */
.subpanel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    background: var(--surface-2);
}
.subpanel:last-child { margin-bottom: 0; }
.actions-inline {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.config-actions {
    align-items: center;
    flex-wrap: nowrap;
}
.config-toolbar {
    justify-content: flex-end;
    margin-bottom: 12px;
}
.config-icon-only-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    min-width: 38px;
    padding: 0;
    line-height: 1;
}
.config-icon-only-btn .pi {
    font-size: 16px;
}
.config-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    min-width: 34px;
    padding: 0;
    line-height: 1;
}
.config-action-btn .pi {
    font-size: 14px;
}
.config-action-btn.copy-config-btn {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    color: var(--text);
}
.config-action-btn.copy-config-btn:hover:not(:disabled) {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-fg);
}

#configProfileTable th,
#configProfileTable td {
    vertical-align: middle;
}

#configProfileTable th:nth-child(1),
#configProfileTable td.config-profile-name {
    min-width: 180px;
    white-space: nowrap;
}

#configProfileTable th:nth-child(2),
#configProfileTable td.config-profile-server {
    min-width: 160px;
    white-space: nowrap;
}

#configProfileTable th:nth-child(3),
#configProfileTable td.config-profile-status {
    width: 56px;
    text-align: center;
    padding-top: 10px;
    padding-bottom: 10px;
}

#configProfileTable td.config-profile-status {
    line-height: 1;
}

.profile-status-dot {
    display: block;
    width: 10px;
    height: 10px;
    margin: 0 auto;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06);
}

.profile-status-dot--stopped {
    background: #e05252;
}

.profile-status-dot--running {
    background: #22c55e;
}

.profile-status-dot--starting {
    background: #f59e0b;
}

body.member-portal-mode #authCard,
body.member-portal-mode #appGrid,
body.member-portal-mode .product-switcher,
body.member-portal-mode #tlgmMain,
body.member-portal-mode .topbar-actions .session-chip,
body.member-portal-mode #changePasswordOpenBtn,
body.member-portal-mode #logoutBtn,
body.wishlist-portal-mode #authCard,
body.wishlist-portal-mode #appGrid,
body.wishlist-portal-mode .product-switcher,
body.wishlist-portal-mode #tlgmMain,
body.wishlist-portal-mode .topbar-actions .session-chip,
body.wishlist-portal-mode #changePasswordOpenBtn,
body.wishlist-portal-mode #logoutBtn {
    display: none !important;
}

#tlgmMemberPortal,
#tlgmWishlistPortal {
    display: none;
}

body.member-portal-mode #tlgmMemberPortal,
body.wishlist-portal-mode #tlgmWishlistPortal {
    display: block !important;
}

body.member-portal-mode #mpApp {
    max-width: 1200px;
    margin: 0 auto;
}

.mp-login-message {
    max-width: 420px;
    margin: 0 auto 16px;
}

.mp-event-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    margin-bottom: 8px;
}

.mp-activity-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.mp-activity-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    padding: 6px 8px;
    border-radius: var(--radius);
    background: var(--surface-2);
}

.mp-cal-weekdays {
    margin-bottom: 6px;
}

.mp-cal-weeks {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mp-cal-week {
    position: relative;
}

.mp-cal-week-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.mp-cal-week-vacations {
    position: absolute;
    top: 26px;
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    min-height: 20px;
    pointer-events: none;
    z-index: 1;
}

.mp-cal-vacation-bar {
    display: flex;
    align-items: center;
    min-height: 20px;
    padding: 2px 0;
    font-size: 10px;
    line-height: 1.2;
    background: rgba(224, 82, 82, 0.22);
    color: #f0a0a0;
    border-radius: 0;
    overflow: hidden;
    white-space: nowrap;
}

.mp-cal-vacation-label {
    padding: 0 6px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp-cal-vacation-bar.range-start {
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

.mp-cal-vacation-bar.range-end {
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.tlgm-cal-day.on-vacation {
    background: rgba(224, 82, 82, 0.08);
}

.tlgm-cal-day.mp-cal-day .tlgm-cal-day-num {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 2;
    margin-bottom: 0;
}

.tlgm-cal-day.mp-cal-day {
    position: relative;
    padding-top: 28px;
}

.mp-cal-event,
.tlgm-cal-day .tlgm-cal-event {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 2px;
    margin-bottom: 2px;
}

.tlgm-cal-event-btn {
    flex: 1;
    min-width: 0;
    text-align: left;
    border: none;
    background: transparent;
    padding: 2px 4px;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.tlgm-cal-event .tlgm-ev-del {
    flex-shrink: 0;
    padding: 0 4px;
    min-width: 20px;
    line-height: 1.4;
    font-size: 11px;
    opacity: .75;
}

.mp-cal-vacation-pill {
    display: none;
}

.mp-event-popover {
    position: fixed;
    z-index: 2000;
    min-width: 220px;
    max-width: 300px;
    padding: 14px 16px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.mp-event-popover::before {
    content: '';
    position: absolute;
    top: -7px;
    left: var(--mp-popover-arrow-left, 28px);
    width: 14px;
    height: 14px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
    transform: rotate(45deg);
}

.mp-event-popover.above::before {
    top: auto;
    bottom: -7px;
    border-left: 0;
    border-top: 0;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.mp-event-popover-close {
    position: absolute;
    top: 8px;
    right: 8px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 4px;
}

.mp-event-popover-footer {
    margin-top: 12px;
}

.mp-event-popover-actions {
    display: flex;
    gap: 8px;
}

.mp-event-popover-actions button {
    flex: 1;
    font-size: 12px;
    padding: 8px 10px;
}

.mp-event-popover-actions button.active {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.mp-event-card-btn {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    padding: 10px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
    color: inherit;
    text-align: left;
}

.mp-event-card-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.tlgm-cal-day.mp-cal-day.selected {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--accent);
}

.mp-cal-side {
    min-width: 260px;
}

.mp-cal-side-section + .mp-cal-side-section {
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.mp-vacation-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.mp-vacation-row:last-child {
    border-bottom: 0;
}

.mp-cal-event {
    display: block;
    width: 100%;
    text-align: left;
}

.mp-overview-profile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 16px 18px;
}

.mp-overview-identity {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.mp-overview-avatar {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    font-weight: 700;
    flex-shrink: 0;
}

.mp-overview-avatar-img {
    object-fit: cover;
    border: 2px solid var(--border-strong);
    background: var(--surface-2);
}

.mp-overview-discord {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
}

.mp-overview-rank {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.mp-rank-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(201, 162, 39, 0.14);
    border: 1px solid rgba(201, 162, 39, 0.35);
    color: #e8c04a;
    font-size: 13px;
    font-weight: 700;
}

.mp-rank-hint {
    font-size: 11.5px;
}

.mp-overview-points {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.mp-overview-stats {
    padding: 16px 18px;
}

.mp-overview-activity {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.mp-activity-bar {
    display: flex;
    width: 100%;
    max-width: 480px;
    height: 24px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
}

.mp-activity-seg {
    height: 100%;
    min-width: 0;
    transition: width 0.35s ease;
}

.mp-activity-green {
    background: linear-gradient(180deg, #34d399 0%, #22c55e 100%);
}

.mp-activity-red {
    background: linear-gradient(180deg, #f87171 0%, #ef4444 100%);
}

.mp-activity-legend {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    font-size: 12.5px;
    color: var(--text-muted);
}

.mp-activity-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.mp-activity-legend-item strong {
    color: var(--text);
}

.mp-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    flex-shrink: 0;
}

.mp-legend-green {
    background: #22c55e;
}

.mp-legend-red {
    background: #ef4444;
}

.mp-overview-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

@media (max-width: 720px) {
    .mp-overview-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.mp-overview-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 10px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    text-align: center;
}

.mp-overview-stat-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.mp-overview-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
}

.mp-overview-stat-label {
    font-size: 11px;
    color: var(--text-muted);
}

.mp-stat-in .mp-overview-stat-value { color: var(--success, #52c87a); }
.mp-stat-out .mp-overview-stat-value { color: var(--danger, #e05252); }
.mp-stat-pending .mp-overview-stat-value { color: var(--text-muted); }

.wl-portal-shell {
    padding: 20px;
}

.wl-portal-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.wl-portal-form {
    display: flex;
    justify-content: center;
    max-width: 420px;
}

.wl-portal-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.wl-holder-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 999px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    z-index: 2;
}

.wl-handover-badge {
    position: absolute;
    top: 8px;
    left: 38px;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--success-soft);
    color: var(--success-fg);
    font-size: 11px;
    font-weight: 700;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tlgm-item-card {
    position: relative;
}

.wl-holder-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wl-holder-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.wl-portal-modal-card {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow: auto;
}

.allowlist-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(160px, 1fr));
    gap: var(--space-2);
    margin-top: 6px;
}
.allowlist-actions button {
    width: 100%;
}
.allowlist-actions .remove-allow-user-btn {
    background: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 70%, transparent);
    color: var(--danger-fg);
}
.allowlist-actions .remove-allow-user-btn:hover:not(:disabled) {
    background: color-mix(in srgb, var(--danger-soft) 80%, var(--danger));
    border-color: var(--danger);
    color: #fff;
}
.allowlist-selected-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--surface) 92%, var(--bg));
}
.allowlist-selected-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
}
.allowlist-selected-item input {
    flex: 0 0 auto;
}
.allowlist-selected-empty {
    color: var(--muted-fg);
    font-size: 0.9rem;
}
.allowlist-picker-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: min(52vh, 420px);
    overflow: auto;
    margin-top: 10px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--surface) 92%, var(--bg));
}
.allowlist-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border-radius: var(--radius-sm);
}
.allowlist-picker-item:hover {
    background: color-mix(in srgb, var(--primary-soft) 55%, transparent);
}
.allowlist-picker-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    cursor: pointer;
}
.allowlist-picker-item.in-allowlist {
    opacity: 0.72;
}

/* ---------- Modal ---------- */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
.modal-header {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 32px;
    padding-right: 42px;
    margin-bottom: 16px;
}
.modal-close-btn {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    padding: 0;
    min-height: 0;
    border-radius: 7px;
    font-size: 16px;
    line-height: 1;
}
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.62);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    z-index: 1000;
    animation: fadeBg 180ms var(--ease);
}
:root[data-theme="light"] .modal-overlay { background: rgba(15, 23, 42, 0.45); }
@keyframes fadeBg {
    from { opacity: 0; }
    to { opacity: 1; }
}
.modal-overlay.open { display: flex; }
#allowlistPickerModal {
    z-index: 1100;
}
.modal-card {
    position: relative;
    width: min(1000px, 100%);
    max-height: calc(100vh - 60px);
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-lg);
    animation: pop 200ms var(--ease);
}
@keyframes pop {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to { opacity: 1; transform: none; }
}

/* ---------- Role dropdown ---------- */
.role-dropdown {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--duration) var(--ease);
}
.role-dropdown[open] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.role-dropdown summary {
    cursor: pointer;
    padding: 8px 12px;
    min-height: 36px;
    display: flex;
    align-items: center;
    list-style: none;
}
.role-dropdown summary::-webkit-details-marker { display: none; }
.role-dropdown summary::after {
    content: "";
    margin-left: auto;
    width: 8px; height: 8px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    transition: transform var(--duration) var(--ease);
}
.role-dropdown[open] summary::after { transform: rotate(-135deg); }
.role-options {
    border-top: 1px solid var(--border);
    padding: var(--space-2) var(--space-3);
    max-height: 220px;
    overflow: auto;
    display: grid;
    gap: 4px;
}
.role-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 13.5px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.role-option:hover { background: var(--surface-hover); }
.role-option input[type="checkbox"] { margin: 0; }

/* ---------- Messages ---------- */
.message {
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-top: var(--space-2);
    display: none;
    font-size: 13px;
    border: 1px solid transparent;
}
.message.ok {
    background: var(--success-soft);
    border-color: color-mix(in srgb, var(--success) 30%, transparent);
    color: var(--success-fg);
    display: block;
}
.message.err {
    background: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 30%, transparent);
    color: var(--danger-fg);
    display: block;
}

.toast-host {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.45;
    border: 1px solid transparent;
    box-shadow: 0 10px 32px rgba(2, 6, 23, 0.35);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: toast-in 180ms var(--ease);
}
:root[data-theme="light"] .toast {
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
}
.toast.ok {
    background: var(--success-soft);
    border-color: color-mix(in srgb, var(--success) 35%, transparent);
    color: var(--success-fg);
}
.toast.err {
    background: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 35%, transparent);
    color: var(--danger-fg);
}
.toast.warn {
    background: var(--warning-soft, color-mix(in srgb, #f59e0b 18%, var(--surface)));
    border-color: color-mix(in srgb, #f59e0b 35%, transparent);
    color: var(--warning-fg, #b45309);
}
.toast-text {
    flex: 1 1 auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.toast-close {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.72;
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
    padding: 0;
}
.toast-close:hover {
    opacity: 1;
}
@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(14px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ---------- Tiles ---------- */
.context-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-2);
}
.context-tile {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 10px 12px;
}
.context-tile strong {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: var(--space-2);
    margin: var(--space-3) 0;
}
.overview-tile {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: var(--space-3);
    transition: border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.overview-tile:hover { border-color: var(--border-strong); }
.overview-tile .label {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}
.overview-tile .value {
    margin-top: 6px;
    font-size: 1.1rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.validation-list { margin: 6px 0 0; padding-left: 18px; }
.validation-list li { margin: 3px 0; }

.live-table { width: 100%; border-collapse: collapse; margin-top: var(--space-3); }
.live-table th, .live-table td {
    border-bottom: 1px solid var(--border);
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
}

.legend-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-2);
    margin: var(--space-3) 0;
}
.legend-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 6px;
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    main { padding: var(--space-3); }
    .topbar { flex-wrap: wrap; }
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .sidebar .tab-bar {
        flex-direction: row;
        flex-wrap: wrap;
        overflow-x: auto;
    }
    .tab-btn {
        text-align: center;
        justify-content: center;
        min-width: max-content;
        box-shadow: none;
    }
    .tab-btn.active { box-shadow: inset 0 -2px 0 var(--accent); }
}
@media (max-width: 640px) {
    h1 { font-size: 1.15rem; }
    .topbar { padding: var(--space-2) 0 var(--space-3); }
    .modal-card { padding: var(--space-3); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0ms !important;
    }
}
