:root {
  --bg: #081018;
  --panel: #101b26;
  --panel-2: #142332;
  --border: #223446;
  --text: #edf6ff;
  --muted: #8fa5b8;
  --accent: #32d5a4;
  --accent-2: #1fb887;
  --blue: #45a6ff;
  --danger: #ff627d;
  --warning: #ffbd55;
  --shadow: 0 20px 50px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 90% 0, rgba(50, 213, 164, .08), transparent 28%), var(--bg); }
a { color: var(--accent); text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px; background: rgba(11, 20, 29, .96); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 10px 28px; color: var(--text); }
.brand-mark, .login-logo { display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), #69e7c0); color: #04110d; font-weight: 900; letter-spacing: -.04em; box-shadow: 0 10px 28px rgba(50, 213, 164, .24); }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; }
.brand span:last-child { display: grid; gap: 2px; }
.brand small, .account-chip small { color: var(--muted); font-size: 11px; }
.nav { display: grid; gap: 6px; }
.nav a { display: flex; gap: 12px; align-items: center; padding: 12px 13px; border-radius: 11px; color: var(--muted); font-size: 14px; transition: .2s ease; }
.nav a span { width: 20px; color: #607b91; font-weight: 800; text-align: center; }
.nav a:hover, .nav a.active { color: var(--text); background: #162633; }
.nav a.active { box-shadow: inset 3px 0 var(--accent); }
.nav a.active span { color: var(--accent); }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; }
.service-pill { display: flex; gap: 9px; align-items: center; padding: 11px 12px; background: #0c151e; border: 1px solid var(--border); border-radius: 11px; color: var(--muted); font-size: 12px; }
.service-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 12px rgba(255, 98, 125, .65); flex: 0 0 auto; }
.service-pill.online i { background: var(--accent); box-shadow: 0 0 12px rgba(50, 213, 164, .65); }

.main { min-width: 0; }
.topbar { min-height: 91px; padding: 20px clamp(22px, 4vw, 48px); border-bottom: 1px solid var(--border); background: rgba(8, 16, 24, .76); backdrop-filter: blur(15px); display: flex; align-items: center; justify-content: space-between; gap: 20px; position: sticky; top: 0; z-index: 10; }
.topbar h1 { margin: 3px 0 0; font-size: 23px; letter-spacing: -.03em; }
.eyebrow { margin: 0; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.account-chip { display: flex; align-items: center; gap: 10px; }
.account-chip > span:last-child { display: grid; gap: 1px; text-align: right; font-size: 13px; }
.avatar, .large-avatar, .group-avatar { display: grid; place-items: center; background: linear-gradient(135deg, #20384a, #2f5368); color: #d9f7ed; font-weight: 800; }
.avatar { width: 36px; height: 36px; border-radius: 50%; order: 2; }
.menu-button { display: none; background: transparent; border: 0; color: var(--text); font-size: 22px; }
.content { padding: clamp(22px, 4vw, 48px); max-width: 1500px; margin: 0 auto; }

.alert { padding: 13px 16px; margin-bottom: 18px; background: rgba(50, 213, 164, .12); border: 1px solid rgba(50, 213, 164, .35); border-radius: 11px; color: #aef3de; font-size: 14px; transition: opacity .4s; }
.alert.error { background: rgba(255, 98, 125, .1); border-color: rgba(255, 98, 125, .35); color: #ffadbb; }
.alert.fade { opacity: .35; }
.hero-card { min-height: 205px; padding: clamp(24px, 4vw, 42px); border: 1px solid #244a48; border-radius: 20px; background: linear-gradient(120deg, rgba(25, 71, 66, .62), rgba(15, 29, 41, .95) 62%), var(--panel); display: flex; align-items: center; justify-content: space-between; gap: 30px; box-shadow: var(--shadow); overflow: hidden; position: relative; }
.hero-card::after { content: "#"; position: absolute; right: 11%; bottom: -76px; color: rgba(50, 213, 164, .06); font-size: 250px; font-weight: 900; }
.hero-card > * { position: relative; z-index: 1; }
.hero-card h2 { margin: 14px 0 7px; font-size: clamp(27px, 4vw, 42px); letter-spacing: -.045em; }
.hero-card p { max-width: 730px; margin: 0; color: #aac0ce; line-height: 1.7; }
.status-badge { display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.status-badge.success { color: #98f1d5; background: rgba(50, 213, 164, .14); border: 1px solid rgba(50, 213, 164, .28); }
.status-badge.warning { color: #ffd895; background: rgba(255, 189, 85, .12); border: 1px solid rgba(255, 189, 85, .28); }
.status-badge.neutral { color: #a7c4dc; background: rgba(116, 151, 178, .1); border: 1px solid rgba(116, 151, 178, .25); }

.primary-button, .secondary-button, .ghost-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; border-radius: 9px; font-size: 13px; font-weight: 800; border: 1px solid transparent; transition: transform .18s, border-color .18s, background .18s; }
.primary-button { background: var(--accent); color: #06130f; }
.primary-button:hover { background: #61e2bc; transform: translateY(-1px); }
.secondary-button { color: var(--text); background: #1b3040; border-color: #315067; }
.secondary-button:hover { border-color: var(--accent); }
.ghost-button { color: var(--muted); background: transparent; border-color: var(--border); }
.ghost-button:hover { color: var(--text); border-color: #42637d; }
.danger-button { color: #ff9bac; background: rgba(255, 98, 125, .08); border-color: rgba(255, 98, 125, .3); }
.danger-button:hover { background: rgba(255, 98, 125, .15); }
.full { width: 100%; }
.small { min-height: 32px; padding: 0 10px; font-size: 11px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin: 20px 0; }
.stat-card, .panel { border: 1px solid var(--border); background: rgba(16, 27, 38, .94); border-radius: 15px; }
.stat-card { padding: 19px 20px; display: grid; gap: 4px; }
.stat-card span, .stat-card small { color: var(--muted); font-size: 12px; }
.stat-card strong { font-size: 31px; letter-spacing: -.04em; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel { padding: 24px; box-shadow: 0 14px 40px rgba(0, 0, 0, .12); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.panel-heading h2 { margin: 5px 0 0; font-size: 18px; letter-spacing: -.025em; }
.panel-heading > a { font-size: 12px; font-weight: 700; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 13px; }
.steps li { display: flex; align-items: center; gap: 13px; padding: 11px; border-radius: 10px; background: #0d1821; border: 1px solid #1e3141; }
.steps li > span { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; background: #243847; color: var(--muted); font-size: 12px; font-weight: 800; }
.steps li.done > span { color: #092019; background: var(--accent); }
.steps li div { display: grid; gap: 3px; }
.steps small, .event-row small, .group-card small, td small { color: var(--muted); font-size: 11px; }
.event-list { display: grid; }
.event-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 12px 0; border-bottom: 1px solid #1c2c3a; }
.event-row:last-child { border: 0; }
.event-row div { display: grid; gap: 2px; min-width: 0; }
.event-row time { color: #71899d; font-size: 10px; }
.event-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; background: rgba(50, 213, 164, .1); color: var(--accent); font-weight: 900; }
.event-icon.partial, .event-icon.failed { color: var(--danger); background: rgba(255, 98, 125, .1); }
.empty-state { min-height: 180px; display: grid; place-content: center; justify-items: center; gap: 7px; color: var(--muted); text-align: center; }
.empty-state strong { color: #b8c8d4; }

.form-stack { display: grid; gap: 17px; }
label { display: grid; gap: 7px; color: #c9d7e1; font-size: 12px; font-weight: 700; }
label small { color: var(--muted); font-weight: 400; line-height: 1.5; }
input, textarea, select { width: 100%; border: 1px solid #2b4254; border-radius: 9px; outline: none; background: #0b151e; color: var(--text); padding: 11px 12px; transition: border .18s, box-shadow .18s; }
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(50, 213, 164, .1); }
input:disabled { opacity: .65; }
.section-separator { height: 1px; background: var(--border); margin: 3px 0; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 0; }
.switch-row span { display: grid; gap: 3px; }
.switch-row input, .check-line input { width: 18px; height: 18px; accent-color: var(--accent); }
.settings-layout { grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); align-items: start; }
.compact-panel { position: sticky; top: 114px; }
.muted { color: var(--muted); line-height: 1.65; }
.notice-box { padding: 16px; margin-top: 20px; border: 1px solid #315066; background: #0c1821; border-radius: 11px; }
.notice-box strong { color: #cce2ef; }
.notice-box p { color: var(--muted); font-size: 12px; line-height: 1.65; }
.notice-box .primary-button { margin-top: 5px; }

.account-hero { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; background: linear-gradient(125deg, rgba(34, 76, 72, .55), var(--panel)); }
.large-avatar { width: 72px; height: 72px; border-radius: 20px; font-size: 28px; }
.account-hero h2 { margin: 9px 0 3px; }
.account-hero p { margin: 0; color: var(--muted); font-size: 13px; }
.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.action-card { display: flex; flex-direction: column; align-items: flex-start; }
.action-card > strong { font-size: 17px; }
.action-card p { color: var(--muted); font-size: 12px; line-height: 1.65; min-height: 40px; }
.action-card button { margin-top: auto; }
.danger-zone { border-color: rgba(255, 98, 125, .23); }
.login-flow { max-width: 780px; margin: 0 auto; padding: clamp(25px, 5vw, 45px); }
.flow-heading { text-align: center; margin-bottom: 28px; }
.flow-heading h2 { margin: 14px 0 5px; font-size: 28px; }
.flow-heading p { color: var(--muted); line-height: 1.7; }
.narrow-form { max-width: 470px; margin: 0 auto; }
.cancel-form { text-align: center; margin-top: 17px; }
.wide-notice { max-width: 780px; margin: 18px auto 0; }

.rule-form { display: grid; grid-template-columns: 1.2fr 1fr .55fr .55fr; gap: 15px; align-items: end; }
.full-span { grid-column: 1 / -1; }
.check-line { display: flex; align-items: center; flex-direction: row; }
.rule-list { display: grid; gap: 9px; }
.rule-item { background: #0c1720; border: 1px solid #203343; border-radius: 11px; overflow: hidden; }
.rule-item summary { display: grid; grid-template-columns: 9px minmax(110px, .6fr) 90px minmax(180px, 1.2fr) auto; align-items: center; gap: 13px; padding: 15px; cursor: pointer; list-style: none; }
.rule-item summary::-webkit-details-marker { display: none; }
.summary-action { color: var(--accent); font-size: 11px; font-weight: 800; white-space: nowrap; }
.rule-status { width: 8px; height: 8px; border-radius: 50%; background: #516273; }
.rule-status.enabled { background: var(--accent); box-shadow: 0 0 10px rgba(50, 213, 164, .55); }
.keyword-label { font-weight: 800; }
.match-label, .priority-label, .count-pill { color: var(--muted); font-size: 11px; }
.reply-preview { color: #aebfcb; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edit-rule { padding: 18px; border-top: 1px solid var(--border); }
.inline-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rule-item > .inline-actions { padding: 0 18px 18px; }
.rule-editor[open] > summary { background: #122432; border-bottom: 1px solid var(--border); }

.groups-heading { align-items: flex-end; }
.search-form { display: flex; gap: 10px; margin-bottom: 18px; }
.search-form input { max-width: 470px; }
.group-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.group-card { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 13px; background: #0c1720; border: 1px solid #1d3141; border-radius: 11px; }
.group-avatar { width: 42px; height: 42px; border-radius: 12px; }
.group-card > div { display: grid; gap: 3px; min-width: 0; }
.group-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toggle { width: 42px; height: 24px; padding: 2px; border: 0; border-radius: 999px; background: #334757; transition: .2s; }
.toggle i { display: block; width: 20px; height: 20px; border-radius: 50%; background: #afbdc7; transition: .2s; }
.toggle.on { background: var(--accent-2); }
.toggle.on i { transform: translateX(18px); background: white; }

.blacklist-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.blacklist-card { display: grid; gap: 13px; padding: 17px; border: 1px solid #263b4c; border-radius: 13px; background: #0c1720; }
.blacklist-user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.blacklist-user > div { display: grid; gap: 4px; min-width: 0; }
.blacklist-user strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blacklist-user small, .blacklist-card > small { color: var(--muted); }
.blacklist-card p { min-height: 20px; margin: 0; color: #b7c7d3; font-size: 12px; }

.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th { padding: 11px 12px; border-bottom: 1px solid var(--border); color: #6f8799; font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
td { padding: 13px 12px; border-bottom: 1px solid #1a2a38; vertical-align: top; font-size: 12px; }
td strong, td small { display: block; margin-bottom: 3px; }
td time { color: #90a7b8; white-space: nowrap; font-size: 11px; }
.message-cell { display: block; max-width: 320px; color: #bccbd5; line-height: 1.5; }
.log-status { display: inline-block; margin: 3px 0; padding: 2px 7px; border-radius: 999px; color: var(--accent); background: rgba(50, 213, 164, .1); font-size: 9px; font-weight: 800; }
.log-status.partial, .log-status.failed { color: #ff8da1; background: rgba(255, 98, 125, .1); }
.error-text { max-width: 210px; color: #ff91a4; }
.table-link { font-weight: 700; white-space: nowrap; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 18px; padding-top: 22px; color: var(--muted); font-size: 12px; }
.pagination a { padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; }

.login-body { display: grid; place-items: center; padding: 25px; background: radial-gradient(circle at 50% 0, rgba(50, 213, 164, .13), transparent 38%), #081018; }
.login-card { width: min(440px, 100%); padding: clamp(28px, 7vw, 44px); border: 1px solid var(--border); border-radius: 20px; background: rgba(15, 27, 38, .96); box-shadow: 0 30px 80px rgba(0, 0, 0, .42); }
.login-logo { width: 58px; height: 58px; border-radius: 17px; margin-bottom: 25px; font-size: 20px; }
.login-card h1 { margin: 8px 0; font-size: 30px; letter-spacing: -.04em; }
.login-card > .muted { margin-bottom: 25px; font-size: 13px; }
.security-note { margin: 18px 0 0; color: #667e91; font-size: 10px; text-align: center; }
.nav-overlay { display: none; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-column { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .compact-panel { position: static; }
  .rule-form { grid-template-columns: 1fr 1fr; }
  .action-grid { grid-template-columns: 1fr; }
  .action-card p { min-height: 0; }
}

@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -275px; width: 260px; transition: left .22s ease; }
  .sidebar.open { left: 0; }
  .nav-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .58); z-index: 15; }
  .nav-overlay.show { display: block; }
  .menu-button { display: block; }
  .topbar { padding: 16px 19px; min-height: 76px; justify-content: flex-start; }
  .account-chip { margin-left: auto; }
  .account-chip > span:last-child { display: none; }
  .content { padding: 19px; }
  .hero-card { align-items: flex-start; flex-direction: column; }
  .hero-card .primary-button { width: 100%; }
  .stats-grid, .group-grid { grid-template-columns: 1fr; }
  .rule-form { grid-template-columns: 1fr; }
  .full-span { grid-column: auto; }
  .rule-item summary { grid-template-columns: 9px 1fr auto; }
  .reply-preview, .priority-label { display: none; }
  .groups-heading { align-items: flex-start; flex-direction: column; }
  .panel { padding: 18px; }
}

@media (max-width: 440px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { padding: 15px; }
  .stat-card strong { font-size: 25px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { margin: 0; font-size: 19px; }
  .search-form { align-items: stretch; flex-direction: column; }
}

.partition-switcher { display: flex; align-items: center; gap: 6px; }
.partition-switcher select { min-width: 150px; max-width: 220px; padding: 10px 34px 10px 12px; }
.account-partition-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.partition-card { padding: 18px; border: 1px solid var(--border); border-radius: 18px; background: #0c1720; }
.partition-card.selected { border-color: var(--accent-2); box-shadow: 0 0 0 1px rgba(50, 213, 164, .24); }
.partition-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.partition-head h3 { margin: 6px 0 3px; }
.partition-head p, .runtime-detail { color: var(--muted); }
.compact-form { gap: 12px; }
.partition-actions { margin-top: 14px; }
.blacklist-form { align-items: end; }
code { user-select: all; }

@media (max-width: 780px) {
  .partition-switcher { width: 100%; order: 3; }
  .partition-switcher select { width: 100%; max-width: none; }
  .account-partition-grid { grid-template-columns: 1fr; }
}
