:root {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: #17202a;
  background: #edf2f6;
  --panel: rgba(255, 255, 255, 0.94);
  --solid: #ffffff;
  --line: rgba(126, 146, 166, 0.28);
  --muted: #667486;
  --primary: #0f6d7a;
  --primary-2: #163d4c;
  --green: #16865a;
  --amber: #a46805;
  --red: #c24132;
  --blue: #2563a8;
  --shadow: 0 18px 42px rgba(26, 41, 58, 0.1);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: linear-gradient(135deg, #f7fafc, #e5ebf1); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 800; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #17202a; padding: 10px 12px; outline: none; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 109, 122, .13); }
pre { margin: 0; max-height: 240px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 8px; background: #f9fbfc; padding: 11px; color: #263241; }

.brand-mark { display: flex; align-items: center; gap: 10px; color: var(--primary); font-weight: 900; }
.ghost-button, .icon-button, .primary-button, .pager button, .bulk-bar button, .notice, .rail button { border: 1px solid var(--line); border-radius: 8px; min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: #fff; color: #17202a; font-weight: 850; padding: 8px 12px; transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease; }
.ghost-button:hover, .icon-button:hover, .primary-button:hover, .pager button:hover, .bulk-bar button:hover, .rail button:hover { transform: translateY(-1px); border-color: rgba(15,109,122,.35); box-shadow: 0 10px 26px rgba(26,41,58,.08); }
.primary-button { background: var(--primary); color: #fff; border-color: var(--primary); }
.compact { min-height: 34px; padding: 7px 10px; }
.icon-button { width: 40px; padding: 0; }
.muted { color: var(--muted); }
.error-text { color: var(--red); font-weight: 850; }
.spin { animation: spin .8s linear infinite; }
.reveal { animation: rise .28s ease both; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }

.public-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.public-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px clamp(18px, 5vw, 64px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.78); backdrop-filter: blur(16px); }
.public-hero { width: min(1180px, calc(100% - 32px)); margin: 28px auto; display: grid; grid-template-columns: minmax(0, 1.06fr) minmax(320px, .94fr); gap: 18px; align-content: start; }
.public-copy, .status-lookup, .public-status { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); padding: clamp(18px, 3vw, 30px); }
.public-copy { min-height: 320px; display: grid; align-content: center; gap: 18px; }
.public-copy h1 { margin: 0; font-size: clamp(34px, 5vw, 58px); line-height: 1.04; letter-spacing: 0; color: #142535; }
.public-copy p { margin: 0; max-width: 620px; color: var(--muted); font-size: 17px; line-height: 1.7; }
.public-signals { display: flex; flex-wrap: wrap; gap: 10px; }
.public-signals span { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 999px; padding: 8px 11px; background: #fff; color: var(--primary-2); font-weight: 850; }
.status-lookup { display: grid; align-content: start; gap: 14px; }
.public-status { grid-column: 1 / -1; min-height: 220px; display: grid; gap: 14px; }
.public-status-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.status-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status-head strong { font-size: 20px; }
.error-state { place-items: center; text-align: center; color: var(--red); }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(460px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.login-panel h1 { margin: 18px 0 6px; font-size: 32px; letter-spacing: 0; }
.login-panel p { margin: 0; color: var(--muted); }
.login-form { display: grid; gap: 15px; margin-top: 24px; }
.captcha-row { display: grid; grid-template-columns: 1fr 152px; gap: 10px; }
.captcha-button { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 0; overflow: hidden; min-height: 48px; }
.captcha-button img { width: 100%; height: 100%; object-fit: cover; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.rail { position: sticky; top: 0; height: 100vh; display: grid; grid-template-rows: auto 1fr auto; gap: 24px; padding: 22px 16px; border-right: 1px solid var(--line); background: rgba(251, 253, 255, .82); backdrop-filter: blur(18px); }
.rail nav { display: grid; gap: 8px; align-content: start; }
.rail nav button { justify-content: flex-start; background: transparent; }
.rail nav button.active { border-color: rgba(15,109,122,.25); background: rgba(15,109,122,.1); color: var(--primary-2); }
.workbench { min-width: 0; display: grid; gap: 18px; align-content: start; padding: 22px; }
.hero-bar { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.hero-bar h1 { margin: 6px 0; font-size: 30px; letter-spacing: 0; }
.hero-bar p { margin: 0; color: var(--muted); }
.eyebrow, .refresh-stamp { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); font-weight: 850; font-size: 13px; }
.refresh-stamp.live { color: var(--amber); }
.hero-actions { display: flex; align-items: center; gap: 10px; }
.notice { justify-content: flex-start; background: rgba(15,109,122,.09); color: var(--primary-2); }

.dashboard-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 12px; }
.metric, .chart-panel, .activity-card, .filter-pane, .queue-pane, .detail-pane, .mail-workspace, .config-section, .health-strip, .board-column, .integration-card, .delivery-list, .ops-panel { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: 0 12px 34px rgba(26,41,58,.07); backdrop-filter: blur(16px); }
.metric { min-height: 92px; padding: 15px; display: flex; align-items: center; gap: 13px; }
.metric > span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; background: rgba(15,109,122,.1); color: var(--primary); }
.metric.green > span { background: rgba(22,134,90,.12); color: var(--green); }
.metric.amber > span { background: rgba(164,104,5,.14); color: var(--amber); }
.metric.red > span { background: rgba(194,65,50,.12); color: var(--red); }
.metric.blue > span { background: rgba(37,99,168,.12); color: var(--blue); }
.metric small { color: var(--muted); }
.metric strong { display: block; margin-top: 3px; font-size: 26px; }
.chart-panel, .activity-card, .health-strip { padding: 15px; min-height: 180px; }
.status-panel { grid-column: span 2; }
.activity-card { grid-column: span 2; display: grid; gap: 12px; align-content: start; }
.card-title, .pane-title { display: flex; align-items: center; justify-content: space-between; gap: 9px; font-weight: 900; margin-bottom: 12px; }
.card-title { justify-content: flex-start; }
.span-all { grid-column: 1 / -1; margin-bottom: 0; }

.donut-wrap { display: grid; grid-template-columns: 140px minmax(0,1fr); gap: 12px; align-items: center; }
.donut-wrap svg { width: 140px; height: 140px; transform: rotate(-90deg); }
.donut-bg, .donut-segment { fill: none; stroke-width: 13; }
.donut-bg { stroke: #e4ebf1; }
.donut-segment { transition: stroke-dasharray .55s ease, stroke-dashoffset .55s ease; }
.donut-wrap strong { display: block; font-size: 32px; }
.donut-wrap span { color: var(--muted); }
.donut-legend { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.donut-legend span { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 9px; background: #fff; font-size: 12px; font-weight: 850; color: #39485a; }
.donut-legend i { width: 8px; height: 8px; border-radius: 50%; }
.status-bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 72px 1fr 34px; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.bar-row div { height: 10px; border-radius: 999px; overflow: hidden; background: #e4ebf1; }
.bar-row i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #36a0ae); transition: width .45s ease; }
.mail-signal { display: grid; grid-template-columns: auto 1fr; gap: 4px 9px; align-items: center; }
.mail-signal small { grid-column: 2; color: var(--muted); overflow-wrap: anywhere; }
.config-line { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.health-strip { grid-column: 1 / -1; min-height: auto; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.health-chip { min-width: 0; display: grid; grid-template-columns: auto minmax(0,1fr); gap: 3px 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 10px; }
.health-chip small { grid-column: 2; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 5px rgba(194,65,50,.11); }
.health-dot.ok { background: var(--green); box-shadow: 0 0 0 5px rgba(22,134,90,.11); }
.health-dot.warning { background: var(--amber); box-shadow: 0 0 0 5px rgba(164,104,5,.12); }

.ticket-grid { display: grid; grid-template-columns: 270px minmax(340px, .82fr) minmax(460px, 1.18fr); gap: 14px; align-items: start; }
.filter-pane, .queue-pane, .detail-pane, .mail-workspace, .config-section, .delivery-list, .ops-panel { padding: 14px; }
.filter-pane { position: sticky; top: 18px; display: grid; gap: 14px; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; top: 12px; left: 11px; color: var(--muted); }
.input-icon input { padding-left: 35px; }
.two-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checkline { display: flex; align-items: center; grid-template-columns: none; gap: 8px; color: #39485a; }
.checkline input { width: auto; }
.segment-group { display: flex; gap: 7px; flex-wrap: wrap; }
.segment-group > span { flex-basis: 100%; color: var(--muted); font-size: 12px; font-weight: 900; }
.segment-group button, .quick-status button { border: 1px solid var(--line); border-radius: 999px; padding: 6px 9px; background: #fff; color: var(--muted); font-weight: 850; }
.segment-group button.active, .quick-status button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.bulk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px; margin-bottom: 10px; border: 1px solid rgba(15,109,122,.22); border-radius: 8px; background: rgba(15,109,122,.08); }
.bulk-bar span { font-weight: 900; color: var(--primary-2); }
.bulk-bar button { min-height: 30px; padding: 5px 8px; }
.ticket-list { display: grid; gap: 9px; }
.ticket-row { display: grid; grid-template-columns: 30px minmax(0,1fr) 18px; gap: 10px; align-items: center; min-height: 122px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 12px; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; animation: rise .22s ease both; }
.ticket-row:hover, .ticket-row.active { transform: translateY(-2px); border-color: rgba(15,109,122,.42); box-shadow: 0 14px 34px rgba(26,41,58,.09); }
.check-button { border: 0; background: transparent; color: var(--primary); padding: 0; }
.ticket-main { min-width: 0; display: grid; gap: 6px; }
.ticket-main strong, .ticket-main p, .ticket-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-main p, .ticket-main small { margin: 0; color: var(--muted); }
.ticket-top { display: flex; gap: 6px; flex-wrap: wrap; }
.status-pill, .priority-pill, .sla-pill, .category-tag { width: fit-content; border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 900; background: #e7edf3; color: #516174; white-space: nowrap; }
.status-pill.investigating, .priority-pill.major, .sla-pill.elevated, .status-pill.pending { background: #fff0ce; color: var(--amber); }
.status-pill.resolved, .status-pill.sent { background: #dff5e8; color: var(--green); }
.status-pill.failed, .priority-pill.blocking, .sla-pill.urgent { background: #ffe4df; color: var(--red); }
.status-pill.triaged { background: #dbeafe; color: var(--blue); }
.priority-pill.normal, .sla-pill.standard { background: #e9f7f4; color: var(--primary); }
.category-tag { background: #eef2f6; color: var(--muted); }

.detail-pane { display: grid; gap: 13px; max-height: calc(100vh - 42px); overflow: auto; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.detail-head h2 { margin: 8px 0 4px; font-size: 24px; letter-spacing: 0; overflow-wrap: anywhere; }
.detail-head p { margin: 0; color: var(--muted); }
.quick-status { display: flex; flex-wrap: wrap; gap: 7px; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.info-cell { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fff; display: grid; gap: 5px; }
.info-cell span { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; font-weight: 900; }
.info-cell strong { overflow-wrap: anywhere; }
.report-block h3, .timeline h3 { margin: 0 0 8px; font-size: 15px; }
.workflow-form { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.workflow-form .full { grid-column: 1 / -1; }
.comment-box, .package-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fff; }
.comment-input { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.comment-list { display: grid; gap: 8px; margin-top: 10px; }
.comment-list article { border: 1px solid rgba(126,146,166,.18); border-radius: 8px; padding: 9px; background: #f9fbfc; }
.comment-list small { display: block; color: var(--muted); margin-top: 2px; }
.comment-list p { margin: 7px 0 0; overflow-wrap: anywhere; }
.package-box code { display: block; margin-top: 8px; color: var(--muted); overflow-wrap: anywhere; }
.mini-timeline, .timeline { display: grid; gap: 10px; }
.event-line { position: relative; display: grid; grid-template-columns: 16px minmax(0,1fr); gap: 9px; }
.event-line .dot { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 5px rgba(15,109,122,.1); }
.event-line strong { display: block; }
.event-line small, .event-line em { display: block; color: var(--muted); font-size: 12px; font-style: normal; margin-top: 2px; }
.event-line.compact strong { font-size: 13px; }

.board-grid { display: grid; grid-template-columns: repeat(5, minmax(180px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 6px; }
.board-column { min-height: 460px; padding: 12px; display: grid; align-content: start; gap: 10px; }
.board-title { display: flex; align-items: center; justify-content: space-between; }
.board-title small { color: var(--muted); font-weight: 900; }
.board-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 12px; display: grid; gap: 8px; transition: transform .18s ease, box-shadow .18s ease; }
.board-card:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(26,41,58,.08); }
.board-card p { margin: 0; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.board-card div { display: flex; gap: 6px; flex-wrap: wrap; }
.board-card small { color: var(--muted); overflow-wrap: anywhere; }
.empty-mini { min-height: 86px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); }

.mail-workspace { display: grid; gap: 12px; }
.mail-grid { display: grid; gap: 10px; }
.mail-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 12px; }
.mail-card summary { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 6px 10px; align-items: center; cursor: pointer; }
.mail-card summary small { grid-column: 2; color: var(--muted); }
.mail-card code { display: block; margin-top: 8px; color: var(--muted); overflow-wrap: anywhere; }

.integration-grid, .ops-grid { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(360px, 1.2fr); gap: 14px; align-items: start; }
.integration-list, .delivery-list, .ops-panel { display: grid; gap: 10px; }
.integration-card, .delivery-row, .backup-row, .audit-row { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 12px; }
.integration-card { display: grid; gap: 8px; }
.integration-card > div:first-child, .backup-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.integration-card small, .delivery-row small, .backup-row small, .audit-row small { color: var(--muted); display: block; margin-top: 3px; overflow-wrap: anywhere; }
.integration-card p, .delivery-row p, .audit-row p { margin: 7px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.delivery-row { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 6px 10px; align-items: center; }
.delivery-row p { grid-column: 2; }

.config-page { display: grid; gap: 14px; }
.config-checks { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.config-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.config-section dl { margin: 0; display: grid; gap: 9px; }
.config-section dl div { display: grid; grid-template-columns: 128px minmax(0,1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid rgba(126,146,166,.18); }
.config-section dl div:last-child { border-bottom: 0; }
.config-section dt { color: var(--muted); font-weight: 850; }
.config-section dd { margin: 0; overflow-wrap: anywhere; font-weight: 760; }
.config-footer, .inline-actions { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-weight: 850; flex-wrap: wrap; }
.workflow-form.single { grid-template-columns: repeat(2, minmax(0,1fr)); }
.db-runtime { margin-top: 12px; border: 1px solid rgba(22,134,90,.22); border-radius: 8px; background: rgba(22,134,90,.08); padding: 11px; display: grid; gap: 4px; }
.db-runtime.warning { border-color: rgba(164,104,5,.28); background: rgba(164,104,5,.1); }
.db-runtime strong { color: var(--primary-2); }
.db-runtime span, .db-runtime small { color: var(--muted); overflow-wrap: anywhere; }
.webhook-editor { display: grid; gap: 10px; }
.webhook-editor .integration-card { background: #fbfdff; }
.webhook-editor .workflow-form { grid-template-columns: repeat(5, minmax(0,1fr)); }

.pager { margin-top: 12px; display: flex; justify-content: flex-end; align-items: center; gap: 8px; color: var(--muted); font-weight: 850; }
.pager button { min-height: 32px; padding: 5px 10px; }
.empty-state { min-height: 160px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); text-align: center; }
.skeleton { min-height: 92px; border-radius: 8px; background: linear-gradient(90deg, #edf2f6, #f8fafc, #edf2f6); background-size: 240% 100%; animation: shimmer 1.1s linear infinite; }
.skeleton.row { min-height: 118px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -240% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1420px) {
  .dashboard-grid, .config-checks { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ticket-grid { grid-template-columns: 250px minmax(330px, 1fr); }
  .detail-pane { grid-column: 1 / -1; max-height: none; }
  .activity-card, .status-panel { grid-column: span 2; }
  .health-strip { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 980px) {
  .admin-shell, .public-hero, .config-grid, .public-status-grid, .integration-grid, .ops-grid { grid-template-columns: 1fr; }
  .public-status { grid-column: auto; }
  .rail { position: sticky; z-index: 5; height: auto; grid-template-columns: 1fr auto; grid-template-rows: auto auto; }
  .rail nav { grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0,1fr)); }
  .rail nav button { justify-content: center; }
  .workbench { padding: 14px; }
  .hero-bar, .ticket-grid, .dashboard-grid, .info-grid, .workflow-form, .workflow-form.single, .webhook-editor .workflow-form, .captcha-row, .config-checks, .health-strip { grid-template-columns: 1fr; }
  .filter-pane { position: static; }
  .activity-card, .status-panel { grid-column: auto; }
  .board-grid { grid-template-columns: repeat(5, minmax(220px, 1fr)); }
}

@media (max-width: 600px) {
  .public-top, .hero-bar, .detail-head, .pane-title, .integration-card div, .backup-row { align-items: flex-start; flex-direction: column; }
  .rail nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .public-copy h1 { font-size: 34px; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .config-section dl div, .two-inputs, .comment-input { grid-template-columns: 1fr; gap: 4px; }
}
