:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #15171d;
  --muted: #687080;
  --line: #d9dde5;
  --line-strong: #c3c9d4;
  --accent: #181f8f;
  --accent-soft: #eef0ff;
  --green: #167a3a;
  --amber: #a95c00;
  --red: #c52222;
  --radius: 8px;
  --shadow: 0 12px 34px rgba(20, 28, 48, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; }

.topbar {
  min-height: 70px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand-lockup { display: flex; align-items: center; gap: 20px; white-space: nowrap; }
.brand-lockup strong { color: var(--accent); font-size: 21px; letter-spacing: -0.02em; }
.brand-lockup span { border-left: 1px solid var(--text); padding-left: 20px; font-size: 17px; }
.topbar-actions { display: flex; align-items: center; gap: 24px; }
.topbar-actions form { margin: 0; }
.health { color: var(--green); display: inline-flex; align-items: center; gap: 9px; }
.health > span { width: 9px; height: 9px; background: var(--green); border-radius: 50%; }

.workspace { padding: 20px 28px 40px; max-width: 1800px; margin: 0 auto; }
.button { min-height: 40px; padding: 0 17px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-weight: 650; transition: transform 140ms ease, background 140ms ease, border-color 140ms ease; }
.button:active { transform: translateY(1px); }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, tr:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid rgba(24, 31, 143, 0.22); outline-offset: 2px; }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover { background: #0f166f; }
.button-secondary { background: #fff; color: var(--text); border-color: var(--line-strong); }
.button-secondary:hover { border-color: #8991a0; }

.notice { margin: 0 0 16px; padding: 11px 14px; border: 1px solid #b9c0f0; background: var(--accent-soft); border-radius: var(--radius); }
.notice-error { border-color: #efb5b5; background: #fff3f3; color: #8f1e1e; }

.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)) auto; gap: 18px; align-items: stretch; margin-bottom: 20px; }
.summary-strip > div { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-height: 90px; display: flex; flex-direction: column; justify-content: space-between; }
.summary-strip span { color: var(--text); font-size: 15px; }
.summary-strip strong { font-family: Georgia, "Times New Roman", serif; font-size: 31px; line-height: 1; font-weight: 500; }
.summary-strip .positive { color: var(--green); }
.summary-strip .negative { color: var(--red); }
.summary-strip > button { align-self: center; min-width: 128px; }

.filters { display: grid; grid-template-columns: 190px 190px 190px minmax(280px, 1fr); gap: 20px; margin-bottom: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; min-height: 40px; padding: 8px 11px; color: var(--text); background: #fff; font-weight: 400; }
textarea { resize: vertical; }
.search-control { display: grid; grid-template-columns: 1fr auto; }
.search-control input { border-radius: 6px 0 0 6px; }
.search-control button { border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 6px 6px 0; background: #f8f9fb; padding: 0 14px; cursor: pointer; font-weight: 650; }

.operations-grid { display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(340px, 0.95fr); gap: 12px; align-items: start; }
.table-panel, .detail-panel, .test-panel, .apps-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td { padding: 13px 15px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; letter-spacing: 0.03em; color: #303541; background: #fbfbfc; white-space: nowrap; }
td { white-space: nowrap; }
td:last-child { width: 48%; white-space: normal; }
tbody tr { cursor: pointer; transition: background 120ms ease; }
tbody tr:hover { background: #fafaff; }
tbody tr.is-selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
tbody a { text-decoration: none; }
.table-panel footer { padding: 12px 15px; color: var(--muted); }
.empty-state { height: 230px; text-align: center; color: var(--muted); }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { color: var(--text); margin-bottom: 4px; }

.status { display: inline-flex; align-items: center; gap: 7px; }
.status > span { width: 13px; height: 13px; border: 1.5px solid currentColor; border-radius: 50%; }
.status-sent { color: var(--green); }
.status-failed, .status-expired { color: var(--red); }
.status-queued, .status-sending { color: var(--amber); }

.detail-panel { box-shadow: var(--shadow); position: sticky; top: 12px; }
.detail-heading, .panel-heading { min-height: 51px; padding: 0 17px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.detail-heading h2, .panel-heading h2 { margin: 0; font-size: 16px; }
.detail-heading a { text-decoration: none; font-size: 25px; line-height: 1; color: var(--muted); }
.detail-list { margin: 0; padding: 16px 18px; }
.detail-list > div { display: grid; grid-template-columns: 126px minmax(0, 1fr); gap: 12px; padding: 5px 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.detail-separated { border-top: 1px solid var(--line); }
.detail-section { border-top: 1px solid var(--line); padding: 14px 18px; }
.detail-section h3 { margin: 0 0 8px; font-size: 13px; font-weight: 700; }
.detail-section p { margin: 0; color: #3e4450; }
.detail-section pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; background: #f7f8fa; border-radius: 5px; padding: 9px; }
.error-copy { color: var(--red); }
.attempt-list { margin: 0; padding: 0; list-style: none; }
.attempt-list li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; color: var(--muted); }
.attempt-list span { color: var(--text); text-transform: capitalize; }
.detail-action { display: flex; justify-content: flex-end; padding: 14px 18px 18px; border-top: 1px solid var(--line); }
.empty-detail { min-height: 360px; display: flex; flex-direction: column; justify-content: center; text-align: center; padding: 30px; color: var(--muted); }
.empty-detail strong { color: var(--text); }

.test-panel { margin-top: 12px; }
.panel-heading p { margin: 2px 0 0; color: var(--muted); }
.test-form { padding: 16px 18px 18px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; align-items: end; }
.test-wide { grid-column: span 2; }
.test-url { grid-column: span 3; }
.test-submit { display: flex; justify-content: flex-end; }
label span { font-weight: 400; color: var(--muted); }

.apps-panel { margin-top: 12px; }
.apps-panel summary { padding: 14px 18px; font-weight: 700; cursor: pointer; }
.apps-list { border-top: 1px solid var(--line); }
.apps-list > div { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.apps-list > div:last-child { border-bottom: 0; }
.apps-list span { display: grid; grid-template-columns: 160px 120px 1fr; align-items: center; gap: 14px; }
.apps-list small { color: var(--muted); }

.login-body { min-height: 100vh; display: grid; place-items: center; background: #f7f8fb; padding: 20px; }
.login-panel { width: min(440px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 30px; box-shadow: var(--shadow); }
.login-panel .brand-lockup { margin-bottom: 42px; }
.login-panel h1 { margin: 0 0 8px; font-family: Georgia, "Times New Roman", serif; font-size: 34px; font-weight: 500; }
.login-panel > p { margin: 0 0 24px; color: var(--muted); }
.login-form { display: grid; gap: 14px; }

@media (max-width: 1080px) {
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .summary-strip > button { min-height: 56px; }
  .filters { grid-template-columns: repeat(3, 1fr); }
  .search-label { grid-column: 1 / -1; }
  .operations-grid { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
}

@media (max-width: 680px) {
  .topbar { padding: 13px 16px; align-items: flex-start; }
  .brand-lockup { display: grid; gap: 2px; }
  .brand-lockup span { border: 0; padding: 0; font-size: 13px; color: var(--muted); }
  .health { display: none; }
  .workspace { padding: 16px; }
  .summary-strip { gap: 10px; }
  .summary-strip > div { min-height: 78px; padding: 13px; }
  .summary-strip strong { font-size: 27px; }
  .summary-strip > button { grid-column: 1 / -1; width: 100%; }
  .filters { grid-template-columns: 1fr 1fr; gap: 12px; }
  .filters .search-label { grid-column: 1 / -1; }
  .test-form { grid-template-columns: 1fr; }
  .test-wide, .test-url { grid-column: auto; }
  .test-submit .button { width: 100%; }
  .apps-list > div { align-items: flex-start; }
  .apps-list span { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
  .detail-list > div { grid-template-columns: 105px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
