:root {
  --bg: #f2f4f8;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --text: #152033;
  --muted: #6d7787;
  --border: #dfe5ee;
  --accent: #246bfd;
  --accent-2: #174fc7;
  --success: #12835c;
  --warning: #a96700;
  --danger: #d64045;
  --shadow: 0 12px 35px rgba(27, 39, 61, .09);
  --in-msg: #eef2f8;
  --out-msg: #dce8ff;
}
html[data-theme="dark"] {
  --bg: #0d1118;
  --panel: #151b25;
  --panel-2: #1a2230;
  --text: #edf2fa;
  --muted: #98a4b7;
  --border: #293447;
  --accent: #6d9dff;
  --accent-2: #4a7de7;
  --success: #57c79c;
  --warning: #f0b45b;
  --danger: #ff777c;
  --shadow: 0 14px 38px rgba(0, 0, 0, .3);
  --in-msg: #202a38;
  --out-msg: #1d3f78;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.topbar { height: 64px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.brand, .topbar-actions, .section-title-row, .reply-actions, .chat-head { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 18px; background: linear-gradient(135deg, #f4b41a, #e97818); color: #17130a; font-size: 28px; font-weight: 900; box-shadow: var(--shadow); }
.brand-mark.small { width: 36px; height: 36px; border-radius: 12px; font-size: 19px; }
.app-grid { height: calc(100vh - 64px); padding: 12px; display: grid; grid-template-columns: 310px minmax(360px, 1fr) 340px; gap: 12px; }
.panel { min-width: 0; min-height: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.conversations-panel, .chat-panel, .tools-panel { display: flex; flex-direction: column; }
.panel-head { min-height: 72px; padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1, h2, h3, p { margin-top: 0; }
h2 { margin: 0; font-size: 18px; }
h3 { margin: 0; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.compact-input, input, textarea, select { width: 100%; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 11px; outline: none; }
.compact-input { max-width: 125px; padding: 8px 10px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { resize: vertical; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.btn { border: 1px solid var(--border); border-radius: 10px; padding: 9px 13px; background: var(--panel-2); color: var(--text); transition: .16s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-small { padding: 7px 9px; font-size: 12px; }
.full { width: 100%; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 18px; }
.conversation-list { overflow-y: auto; flex: 1; }
.conversation-item { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.conversation-item:hover, .conversation-item.active { background: var(--panel-2); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 20%, var(--panel-2)); color: var(--accent); font-weight: 800; }
.conversation-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; display: grid; place-items: center; background: var(--accent); color: white; font-size: 11px; }
.chat-head { justify-content: space-between; }
.server-actions { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.message-list { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: color-mix(in srgb, var(--panel-2) 65%, var(--panel)); }
.message { max-width: 78%; padding: 10px 12px; border-radius: 14px; line-height: 1.42; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.in { align-self: flex-start; background: var(--in-msg); border-bottom-left-radius: 4px; }
.message.out { align-self: flex-end; background: var(--out-msg); border-bottom-right-radius: 4px; }
.message.system { align-self: center; max-width: 90%; background: transparent; color: var(--muted); font-size: 12px; }
.message-time { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; text-align: right; }
.reply-box { padding: 12px; border-top: 1px solid var(--border); display: grid; gap: 9px; }
.reply-actions { justify-content: space-between; }
.reply-actions select { max-width: 280px; }
.tools-panel { overflow-y: auto; }
.tool-section { padding: 16px; display: grid; gap: 10px; border-bottom: 1px solid var(--border); }
.section-title-row { justify-content: space-between; }
.client-details { display: grid; gap: 8px; margin: 0; }
.client-details > div { display: flex; justify-content: space-between; gap: 10px; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.pill { padding: 4px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: 11px; }
.pill.active { background: color-mix(in srgb, var(--success) 18%, var(--panel)); color: var(--success); }
.pill.inactive { background: color-mix(in srgb, var(--danger) 18%, var(--panel)); color: var(--danger); }
.switch { display: inline-flex; }
.switch input { display: none; }
.switch span { width: 44px; height: 24px; border-radius: 999px; background: var(--border); position: relative; transition: .2s; }
.switch span::after { content: ""; width: 18px; height: 18px; border-radius: 50%; background: white; position: absolute; top: 3px; left: 3px; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.template-list { display: grid; gap: 8px; }
.template-item { padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); color: var(--text); text-align: left; width: 100%; cursor: pointer; }
.template-item strong { display: block; margin-bottom: 4px; }
.template-item span { margin: 0; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.template-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.template-item:hover { border-color: var(--accent); }
.template-help { margin: 8px 0; }
.reply-template-picker { display: grid; gap: 6px; min-width: 0; flex: 1; }
.reply-template-picker select { max-width: 100%; }
.reply-template-picker label { color: var(--text); }
.reply-actions { align-items: flex-end; }
.template-replace-confirm { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--accent); border-radius: 10px; background: var(--panel-2); }
.template-replace-confirm p { margin: 0; max-height: 110px; overflow: auto; font-size: 13px; white-space: pre-wrap; }
.template-replace-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.system-status { margin: 0; padding: 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); white-space: pre-wrap; font-size: 11px; max-height: 250px; overflow: auto; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warning); }
.status-dot.ok { background: var(--success); }
.status-dot.error { background: var(--danger); }
.empty-state { margin: auto; color: var(--muted); text-align: center; }
.toast-container { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast { max-width: 380px; padding: 11px 14px; border-radius: 11px; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.55); }
.modal-card { width: min(560px, 100%); padding: 18px; border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); display: grid; gap: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.checkbox-line { display: flex; align-items: center; gap: 8px; }
.checkbox-line input { width: auto; }
.hidden { display: none !important; }
.mobile-tabs { display: none; }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top, color-mix(in srgb, var(--accent) 25%, var(--bg)), var(--bg) 55%); }
.login-card { width: min(420px, 100%); padding: 28px; border: 1px solid var(--border); border-radius: 22px; background: var(--panel); box-shadow: var(--shadow); text-align: center; }
.login-card .brand-mark { margin: 0 auto 18px; }
.stack { display: grid; gap: 14px; text-align: left; }
.alert { padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; }
.alert-error { background: color-mix(in srgb, var(--danger) 15%, var(--panel)); color: var(--danger); border: 1px solid var(--danger); }
@media (max-width: 1150px) { .app-grid { grid-template-columns: 280px minmax(360px, 1fr); } .tools-panel { position: fixed; right: 12px; top: 76px; bottom: 12px; width: min(360px, calc(100vw - 24px)); z-index: 30; display: none; } .tools-panel.mobile-active { display: flex; } }
@media (max-width: 760px) {
  .topbar { height: 56px; padding: 0 10px; }
  .brand strong { font-size: 14px; }
  .topbar-actions .btn { display: none; }
  .mobile-tabs { display: grid; grid-template-columns: repeat(3, 1fr); position: sticky; top: 56px; z-index: 18; background: var(--panel); border-bottom: 1px solid var(--border); }
  .mobile-tabs button { padding: 10px 4px; border: 0; background: transparent; color: var(--muted); }
  .mobile-tabs button.active { color: var(--accent); border-bottom: 2px solid var(--accent); }
  .app-grid { height: calc(100vh - 96px); display: block; padding: 8px; }
  [data-mobile-panel] { display: none; height: 100%; }
  [data-mobile-panel].mobile-active { display: flex; }
  .tools-panel { position: static; width: auto; }
  .server-actions { max-width: 210px; }
  .panel-head { min-height: 64px; padding: 10px 12px; }
  .message { max-width: 90%; }
  .reply-actions { align-items: stretch; }
  .reply-actions select { max-width: none; }
}
.key-result-card { width: min(760px, 100%); }
.key-output {
  min-height: 210px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-all;
}

/* Media in support conversations */
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.message-media-link { display: block; }
.message-image, .message-video { display: block; width: min(100%, 460px); max-height: 520px; object-fit: contain; border-radius: 11px; background: #000; }
.message-audio { width: min(100%, 360px); }
.message-file { display: inline-flex; align-items: center; gap: 7px; padding: 9px 11px; border-radius: 9px; background: color-mix(in srgb, var(--panel) 60%, transparent); color: var(--text); text-decoration: none; }
.media-unavailable { padding: 9px; border-radius: 9px; border: 1px dashed var(--warning); color: var(--warning); font-size: 12px; }
.reply-compose { display: flex; gap: 8px; align-items: stretch; }
.reply-compose textarea { flex: 1; }
.attach-btn { flex: 0 0 42px; width: 42px; height: auto; min-height: 54px; }
.attachment-preview { position: relative; display: flex; align-items: center; gap: 10px; padding: 9px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2); }
.attachment-preview img, .attachment-preview video { width: 80px; height: 64px; object-fit: cover; border-radius: 8px; background: #000; }
.attachment-meta { min-width: 0; display: grid; gap: 4px; flex: 1; }
.attachment-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-meta span { color: var(--muted); font-size: 12px; }
.attachment-remove { flex: 0 0 auto; }

/* Broadcast centre */
.broadcast-modal { align-items: stretch; justify-items: stretch; padding: 12px; }
.broadcast-card { width: min(1280px, 100%); height: min(920px, calc(100vh - 24px)); margin: auto; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.sticky-modal-head { flex: 0 0 auto; padding: 16px 18px; border-bottom: 1px solid var(--border); background: var(--panel); }
.sticky-modal-head > div { display: grid; gap: 3px; }
.broadcast-layout { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.broadcast-editor { min-height: 0; overflow: auto; padding: 18px; display: grid; gap: 14px; }
.broadcast-history { min-height: 0; overflow: auto; padding: 18px; border-left: 1px solid var(--border); background: color-mix(in srgb, var(--panel-2) 55%, var(--panel)); }
.form-grid { display: grid; gap: 10px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.button-grid { grid-template-columns: minmax(120px, .8fr) minmax(180px, 1.4fr) auto; }
.audience-options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2); }
.audience-options .wide { flex-basis: 100%; }
.field-title { font-weight: 700; color: var(--text); }
.broadcast-media-box { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px; border: 1px dashed var(--border); border-radius: 12px; outline: none; }
.broadcast-media-box:focus-within, .broadcast-media-box:focus { border-color: var(--accent); }
.broadcast-media-box .attachment-preview { flex-basis: 100%; }
.button-builder { display: grid; gap: 8px; }
.broadcast-button-list { display: flex; flex-wrap: wrap; gap: 7px; }
.broadcast-button-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel-2); }
.broadcast-button-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.broadcast-button-chip button { border: 0; background: transparent; color: var(--danger); font-size: 16px; }
.broadcast-actions { display: flex; justify-content: flex-end; gap: 8px; }
.broadcast-jobs { display: grid; gap: 10px; margin-top: 12px; }
.broadcast-job { display: grid; gap: 7px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.progress { height: 7px; overflow: hidden; border-radius: 999px; background: var(--border); }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .25s ease; }
.job-error { color: var(--danger); font-size: 12px; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .broadcast-layout { grid-template-columns: 1fr; overflow: auto; }
  .broadcast-editor, .broadcast-history { overflow: visible; }
  .broadcast-history { border-left: 0; border-top: 1px solid var(--border); }
  .broadcast-card { height: calc(100vh - 16px); }
}
@media (max-width: 760px) {
  #broadcast-open { display: inline-flex; padding: 7px 9px; font-size: 12px; }
  .broadcast-modal { padding: 4px; }
  .broadcast-card { height: calc(100vh - 8px); border-radius: 12px; }
  .broadcast-editor, .broadcast-history { padding: 12px; }
  .form-grid.two, .form-grid.button-grid { grid-template-columns: 1fr; }
  .broadcast-actions { flex-direction: column; }
  .broadcast-actions .btn { width: 100%; }
  .message-image, .message-video { max-height: 360px; }
  .attachment-preview img, .attachment-preview video { width: 64px; height: 54px; }
}

/* x-ui server health */
.xui-server-cards { display: grid; gap: 10px; }
.server-health-card { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 13px; background: var(--panel-2); }
.server-health-card.loading { color: var(--muted); }
.server-health-card.online { border-color: color-mix(in srgb, var(--success) 52%, var(--border)); }
.server-health-card.warning { border-color: color-mix(in srgb, var(--warning) 58%, var(--border)); }
.server-health-card.offline { border-color: color-mix(in srgb, var(--danger) 58%, var(--border)); }
.server-health-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.server-health-head > div { min-width: 0; display: grid; gap: 2px; }
.server-health-head strong { overflow-wrap: anywhere; }
.server-health-head span { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.server-health-state { flex: 0 0 auto; padding: 4px 7px; border-radius: 999px; font-weight: 700; font-size: 10px !important; }
.server-health-card.online .server-health-state { color: var(--success); background: color-mix(in srgb, var(--success) 14%, var(--panel)); }
.server-health-card.warning .server-health-state { color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, var(--panel)); }
.server-health-card.offline .server-health-state { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, var(--panel)); }
.server-health-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.server-health-metrics > div { min-width: 0; padding: 8px; border-radius: 9px; background: color-mix(in srgb, var(--panel) 62%, transparent); display: grid; gap: 3px; }
.server-health-metrics span { color: var(--muted); font-size: 10px; }
.server-health-metrics strong { font-size: 15px; }
.server-health-metrics .metric-address { font-size: 12px; overflow-wrap: anywhere; }
.server-health-divider { display: flex; justify-content: space-between; gap: 8px; padding-top: 2px; border-top: 1px solid var(--border); color: var(--muted); font-size: 10px; }
.server-health-divider span:last-child { text-align: right; }
.server-health-panel-metrics strong { font-size: 13px; }
.server-health-foot { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.server-health-error { padding: 8px; border-radius: 8px; color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--panel)); font-size: 11px; overflow-wrap: anywhere; }

/* v1.5: stable chat scrolling and x-ui server management */
.chat-panel { position: relative; }
.new-messages-button {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 118px;
  transform: translateX(-50%);
  padding: 8px 13px;
  border: 1px solid color-mix(in srgb, var(--accent) 70%, var(--border));
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 700;
  font-size: 12px;
}
.new-messages-button:hover { background: var(--accent-2); }
.inline-actions { display: flex; align-items: center; gap: 6px; }
.audience-server-options { display: contents; }
.server-health-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.server-health-actions .btn { padding: 6px 9px; font-size: 11px; }
.server-source-badge { color: var(--muted); font-size: 10px; }
.server-modal-card { width: min(760px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
.server-modal-card .field-help { color: var(--muted); font-size: 10px; line-height: 1.35; }
.compact-checks { align-items: center; }
.server-modal-actions { align-items: center; }
.modal-spacer { flex: 1; }
.server-auth-summary { color: var(--muted); font-size: 11px; }
.server-health-card.disabled { opacity: .72; border-style: dashed; }
.server-health-card.disabled .server-health-state { color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, var(--panel)); }

@media (max-width: 760px) {
  .new-messages-button { bottom: 124px; }
  .server-modal-card { max-height: calc(100vh - 12px); }
  .compact-checks { grid-template-columns: 1fr; }
}

/* Administrative subscription gifts and compensation */
#key-result-modal { z-index: 90; }
.grant-modal-card { width: min(720px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
.grant-fieldset { min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 12px; display: grid; gap: 11px; }
.grant-fieldset legend { padding: 0 6px; color: var(--text); font-weight: 700; font-size: 13px; }
.grant-presets { display: flex; flex-wrap: wrap; gap: 7px; }
.grant-presets .btn { min-width: 48px; padding: 7px 10px; }
.grant-presets .btn.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--panel)); color: var(--accent); font-weight: 800; }
.grant-current, .grant-result { padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2); display: grid; gap: 7px; overflow-wrap: anywhere; }
.grant-current span { color: var(--muted); font-size: 12px; }
.grant-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.grant-summary-grid.bulk { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grant-summary-grid > div { min-width: 0; padding: 10px; border-radius: 10px; background: color-mix(in srgb, var(--panel) 70%, transparent); display: grid; gap: 4px; }
.grant-summary-grid span { color: var(--muted); font-size: 11px; }
.grant-summary-grid strong { overflow-wrap: anywhere; }
.grant-success { color: var(--success); font-size: 12px; }
.grant-url { padding: 9px; border-radius: 9px; background: color-mix(in srgb, var(--accent) 8%, var(--panel)); color: var(--accent); font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }
.grant-actions { align-items: center; }
.bulk-grant-modal { align-items: stretch; justify-items: stretch; padding: 12px; }
.bulk-grant-card { width: min(1120px, 100%); height: min(820px, calc(100vh - 24px)); margin: auto; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.bulk-grant-layout { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 390px; }
.bulk-grant-editor, .bulk-grant-history { min-height: 0; overflow-y: auto; padding: 18px; display: grid; align-content: start; gap: 14px; }
.bulk-grant-history { border-left: 1px solid var(--border); background: color-mix(in srgb, var(--panel-2) 55%, var(--panel)); }
.bulk-grant-jobs { display: grid; gap: 10px; }
.bulk-grant-job { display: grid; gap: 7px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); overflow-wrap: anywhere; }
.bulk-grant-failures { border-top: 1px solid var(--border); padding-top: 7px; color: var(--danger); }
.bulk-grant-failures summary { cursor: pointer; font-size: 12px; font-weight: 700; }
.bulk-grant-failure { display: grid; gap: 2px; margin-top: 7px; padding: 7px; border-radius: 8px; background: color-mix(in srgb, var(--danger) 8%, transparent); font-size: 12px; }
.bulk-grant-failure span { color: var(--muted); }

@media (max-width: 900px) {
  .bulk-grant-layout { grid-template-columns: 1fr; overflow-y: auto; }
  .bulk-grant-editor, .bulk-grant-history { overflow: visible; }
  .bulk-grant-history { border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 760px) {
  .grant-modal-card { max-height: calc(100vh - 12px); }
  .grant-summary-grid, .grant-summary-grid.bulk { grid-template-columns: 1fr; }
  .grant-actions { flex-direction: column; }
  .grant-actions .btn { width: 100%; }
  .bulk-grant-modal { padding: 4px; }
  .bulk-grant-card { height: calc(100vh - 8px); border-radius: 12px; }
  .bulk-grant-editor, .bulk-grant-history { padding: 12px; }
}
