/* ==========================================================================
   SMS Relay · design system
   Light: warm paper. Dark: near black. Iris accent. Hairlines, quiet motion.
   Self-contained: no external fonts, no CDN.
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  color-scheme: light;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas,
    "Liberation Mono", monospace;

  --bg: #f7f6f3;
  --bg-glow: radial-gradient(1200px 600px at 50% -10%, #edebff 0%, rgba(237, 235, 255, 0) 60%);
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --surface-3: #f3f1ed;
  --ink: #15171c;
  --ink-2: #4b5058;
  --muted: #8a8f98;
  --line: rgba(21, 23, 28, 0.08);
  --line-strong: rgba(21, 23, 28, 0.14);

  --brand: #5b5bd6;
  --brand-ink: #3f3fae;
  --brand-soft: #eeeefe;
  --brand-glow: rgba(91, 91, 214, 0.45);

  --ok: #0e9f6e;
  --ok-soft: rgba(14, 159, 110, 0.1);
  --warn: #c27803;
  --warn-soft: rgba(194, 120, 3, 0.1);
  --danger: #d14343;
  --danger-soft: rgba(209, 67, 67, 0.09);

  --shadow-card: 0 1px 2px rgba(16, 18, 24, 0.04), 0 12px 32px -18px rgba(16, 18, 24, 0.18);
  --shadow-pop: 0 18px 44px -20px rgba(16, 18, 24, 0.32), 0 2px 8px rgba(16, 18, 24, 0.05);
  --shadow-btn: 0 6px 16px -6px rgba(91, 91, 214, 0.5);

  --glass: rgba(247, 246, 243, 0.78);
  --toast-bg: #15171c;
  --toast-ink: #ffffff;
  --shimmer: rgba(255, 255, 255, 0.65);
  --selection: #e2e2ff;

  --radius-card: 18px;
  --radius-input: 12px;
  --radius-btn: 12px;
  --radius-pill: 999px;

  --dur-1: 120ms;
  --dur-2: 160ms;
  --dur-3: 200ms;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --page-max: 1120px;
  --topbar-h: 64px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b0c0f;
  --bg-glow: radial-gradient(1200px 600px at 50% -10%, rgba(91, 91, 214, 0.16) 0%, rgba(11, 12, 15, 0) 60%);
  --surface: #14161a;
  --surface-2: #1a1d22;
  --surface-3: #21252b;
  --ink: #ecedef;
  --ink-2: #b4b9c1;
  --muted: #7c838d;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);

  --brand: #8c8cf5;
  --brand-ink: #c7c7ff;
  --brand-soft: rgba(140, 140, 245, 0.14);
  --brand-glow: rgba(140, 140, 245, 0.35);

  --ok: #3ddc97;
  --ok-soft: rgba(61, 220, 151, 0.12);
  --warn: #e5b45b;
  --warn-soft: rgba(229, 180, 91, 0.12);
  --danger: #f07171;
  --danger-soft: rgba(240, 113, 113, 0.12);

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), 0 16px 40px -24px rgba(0, 0, 0, 0.7);
  --shadow-pop: 0 18px 44px -20px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-btn: 0 6px 16px -6px rgba(140, 140, 245, 0.45);

  --glass: rgba(11, 12, 15, 0.72);
  --toast-bg: #ecedef;
  --toast-ink: #15171c;
  --shimmer: rgba(255, 255, 255, 0.06);
  --selection: rgba(140, 140, 245, 0.3);
}

/* 2. Base ----------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--bg-glow);
  background-repeat: no-repeat;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

svg {
  display: block;
}

a {
  color: var(--brand-ink);
  text-decoration: none;
}

::selection {
  background: var(--selection);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.input:focus-visible,
.select__input:focus-visible {
  outline: none;
}

[hidden] {
  display: none !important;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
  border: 3px solid transparent;
  background-clip: content-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -72px;
  z-index: 200;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  font-size: 13px;
  font-weight: 500;
  transition: top var(--dur-2) var(--ease);
}

.skip-link:focus {
  top: 12px;
}

.noscript {
  position: relative;
  z-index: 10;
  margin: 16px;
  padding: 14px 18px;
  border-left: 3px solid var(--danger);
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--ink);
  font-size: 13px;
}

/* 3. Buttons -------------------------------------------------------------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  background: var(--brand);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  transition: background-color var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease),
    filter var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease);
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: var(--shadow-btn);
}

.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.995);
  box-shadow: none;
  filter: brightness(0.99);
  transition-duration: 80ms;
}

.btn:disabled {
  opacity: 0.55;
  transform: none;
  box-shadow: none;
  filter: none;
}

.btn--secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--line-strong);
  filter: none;
  box-shadow: 0 6px 16px -12px rgba(16, 18, 24, 0.35);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-2);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink);
  filter: none;
  box-shadow: none;
  transform: none;
}

.btn--sm {
  height: 40px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: 10px;
}

.btn--block {
  width: 100%;
}

.btn__label {
  line-height: 1;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  transition: background-color var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

.icon-btn:active {
  transform: scale(0.95);
}

.text-btn {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--brand-ink);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease);
}

.text-btn:hover {
  background: var(--brand-soft);
}

/* 4. Form controls -------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field__label {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink-2);
}

.field__control {
  position: relative;
  display: flex;
  align-items: center;
}

.field__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  z-index: 1;
  width: 17px;
  height: 17px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
  transition: border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}

.input::placeholder {
  color: var(--muted);
  opacity: 0.9;
}

.input:hover {
  border-color: var(--line-strong);
}

.input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 4px var(--danger-soft);
}

.input--icon {
  padding-left: 44px;
}

.input--password {
  padding-right: 52px;
}

.input[type="search"]::-webkit-search-cancel-button,
.input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  box-shadow: 0 0 0 1000px var(--surface-2) inset;
  transition: background-color 9999s ease-out 0s;
}

.field__toggle {
  position: absolute;
  right: 3px;
  top: 3px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  color: var(--muted);
  transition: background-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease);
}

.field__toggle:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.field__toggle svg {
  width: 17px;
  height: 17px;
}

.field__toggle .icon-eye-off {
  display: none;
}

.field__toggle[aria-pressed="true"] .icon-eye {
  display: none;
}

.field__toggle[aria-pressed="true"] .icon-eye-off {
  display: block;
}

.field__error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--danger);
}

.field__error svg {
  width: 13px;
  height: 13px;
  flex: none;
  margin-top: 2px;
}

.field__hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--warn);
}

.field__hint svg {
  width: 13px;
  height: 13px;
  flex: none;
}

.select {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
}

.select__input {
  -webkit-appearance: none;
  appearance: none;
  height: 46px;
  min-width: 150px;
  padding: 0 38px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}

.select__input:hover {
  border-color: var(--line-strong);
}

.select__input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.select__chevron {
  position: absolute;
  right: 13px;
  top: 50%;
  width: 15px;
  height: 15px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.select--compact .select__input {
  height: 40px;
  min-width: 0;
  padding: 0 32px 0 12px;
  border-radius: 10px;
  font-size: 13px;
}

.select--compact .select__chevron {
  right: 11px;
  width: 14px;
  height: 14px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  box-shadow: 0 1px 0 var(--line);
}

/* 5. Card ----------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

/* 6. Top bar -------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) saturate(160%);
  border-bottom: 1px solid var(--line);
}

@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .topbar {
    background: var(--bg);
  }
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--page-max);
  height: var(--topbar-h);
  margin: 0 auto;
  padding: 0 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-left: -4px;
  padding: 4px;
  border-radius: 10px;
  color: var(--ink);
  transition: background-color var(--dur-1) var(--ease);
}

.brand:hover {
  background: var(--surface-2);
}

.brand__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.brand__name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand__sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 9px;
  background: linear-gradient(140deg, #6e6ee6 0%, #5b5bd6 55%, #4a4ac2 100%);
  color: #ffffff;
  box-shadow: 0 6px 14px -8px var(--brand-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.logo-mark svg {
  width: 18px;
  height: 18px;
}

.logo-mark--lg {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  box-shadow: 0 12px 26px -12px var(--brand-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.logo-mark--lg svg {
  width: 28px;
  height: 28px;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar__divider {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: var(--line);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(16, 18, 24, 0.03);
}

.status-dot {
  position: relative;
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--muted);
}

.status-chip[data-state="loading"] .status-dot {
  animation: pulse-soft 1.8s ease-in-out infinite;
}

.status-chip[data-state="ok"] .status-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}

.status-chip[data-state="ok"] .status-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse 2.6s var(--ease) infinite;
}

.status-chip[data-state="warn"] .status-dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-soft);
}

.status-chip[data-state="error"] .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.theme-toggle {
  border-color: transparent;
}

.theme-toggle .icon-sun {
  display: block;
}

.theme-toggle .icon-moon {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 4px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.user-chip__name {
  max-width: 120px;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 7. Page ----------------------------------------------------------------- */
.page {
  position: relative;
  z-index: 1;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 30px 24px 72px;
}

.page__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  animation: rise var(--dur-3) var(--ease) both;
}

.page__title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: -0.02em;
}

.page__subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13.5px;
}

.page__hint {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.page__hint span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot-sep {
  color: var(--line-strong);
}

/* 8. Stats ---------------------------------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
  animation: rise var(--dur-3) var(--ease) both;
  animation-delay: 40ms;
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 18px 20px 16px;
}

.stat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat__label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
}

.stat__icon {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--muted);
  opacity: 0.8;
}

.stat__value {
  margin-top: 10px;
  color: var(--ink);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat__value--sm {
  font-size: 21px;
  letter-spacing: -0.02em;
}

.stat__hint {
  margin-top: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 9. Inbox card & toolbar ------------------------------------------------- */
.inbox {
  overflow: hidden;
  animation: rise var(--dur-3) var(--ease) both;
  animation-delay: 90ms;
  scroll-margin-top: 88px;
}

.inbox__body {
  position: relative;
  min-height: 160px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.search {
  position: relative;
  flex: 1 1 260px;
  max-width: 360px;
  min-width: 180px;
}

.search__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.input--search {
  height: 46px;
  padding-left: 42px;
  padding-right: 48px;
  background: var(--surface-2);
}

.search__kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  transition: opacity var(--dur-1) var(--ease);
}

.search:focus-within .search__kbd,
.search.has-value .search__kbd {
  opacity: 0;
}

.search__clear {
  position: absolute;
  right: 3px;
  top: 3px;
  display: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  color: var(--muted);
  transition: background-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease);
}

.search__clear:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.search__clear svg {
  width: 15px;
  height: 15px;
}

.search.has-value .search__clear {
  display: grid;
}

.toolbar__spacer {
  flex: 1 1 auto;
}

.toolbar__meta {
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.refresh-btn {
  gap: 7px;
}

.refresh-icon {
  width: 15px;
  height: 15px;
  transition: transform var(--dur-2) var(--ease);
}

.refresh-btn.is-spinning .refresh-icon {
  animation: spin 0.9s linear infinite;
}

/* 10. Table --------------------------------------------------------------- */
.table-wrap {
  display: block;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.table col.col-sender {
  width: 21%;
}

.table col.col-time {
  width: 15.5%;
}

.table col.col-device {
  width: 15%;
}

.table col.col-action {
  width: 58px;
}

.table thead th {
  height: 40px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-align: left;
  text-transform: uppercase;
}

.table thead th:first-child {
  padding-left: 20px;
}

.table thead th.col-action {
  padding: 0;
}

/* Dark: lift the header off the card a touch and keep the small caps legible. */
html[data-theme="dark"] .table thead th {
  background: rgba(255, 255, 255, 0.045);
  border-bottom-color: var(--line-strong);
  color: #9aa1ac;
}

.table tbody tr {
  cursor: copy;
  transition: background-color var(--dur-1) var(--ease);
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.table tbody td {
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody td:first-child {
  padding-left: 20px;
}

.table tbody td.col-action {
  padding: 0 10px;
  text-align: center;
}

.cell-sender {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.sender-addr {
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-body {
  overflow: hidden;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--dur-1) var(--ease);
}

.table tbody tr:hover .cell-body {
  color: var(--ink);
}

.time {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-device {
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  color: var(--muted);
  opacity: 0.55;
}

.copy-btn svg {
  width: 16px;
  height: 16px;
}

.table tbody tr:hover .copy-btn {
  color: var(--brand);
  opacity: 1;
}

.copy-btn:hover {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand);
}

.copy-btn.is-copied,
.sms-card__copy.is-copied {
  color: var(--ok);
  opacity: 1;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  flex: none;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
}

.tag--brand {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

/* 11. Mobile card stream -------------------------------------------------- */
.sms-list {
  display: none;
}

.sms-card {
  position: relative;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  transition: background-color var(--dur-1) var(--ease);
}

.sms-card:last-child {
  border-bottom: 0;
}

.sms-card:active {
  background: var(--surface-2);
}

.sms-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sms-card__sender {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.sms-card__time {
  flex: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sms-card__body {
  display: -webkit-box;
  margin-top: 7px;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.sms-card.is-open .sms-card__body {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

.sms-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.sms-card__device {
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sms-card__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.sms-card__actions .icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  color: var(--muted);
}

.sms-card__actions .icon-btn svg {
  width: 16px;
  height: 16px;
}

.sms-card__actions .icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.sms-card__expand svg {
  transition: transform var(--dur-2) var(--ease);
}

.sms-card.is-open .sms-card__expand svg {
  transform: rotate(180deg);
}

/* 12. Skeleton ------------------------------------------------------------ */
.skel {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-3);
}

.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent 0, var(--shimmer) 50%, transparent 100%);
  animation: shimmer 1.4s ease-in-out infinite;
}

.skel--value {
  width: 64px;
  height: 26px;
  border-radius: 7px;
}

.skel--sm-value {
  width: 72px;
  height: 22px;
  border-radius: 7px;
}

.skel--sender {
  width: 104px;
  height: 13px;
}

.skel--body {
  width: min(520px, 82%);
  height: 13px;
}

.skel--time {
  width: 86px;
  height: 12px;
}

.skel--device {
  width: 88px;
  height: 11px;
}

.skel--action {
  width: 20px;
  height: 20px;
  margin: 0 auto;
  border-radius: 6px;
}

.skeleton-row {
  cursor: default;
}

.skeleton-row:hover {
  background: transparent;
}

.sms-card--skel:active {
  background: transparent;
}

.sms-card--skel .skel {
  height: 12px;
}

/* 13. Pagination ---------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px 20px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.pagination__meta {
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pagination__controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pagination__sep {
  width: 1px;
  height: 22px;
  background: var(--line);
}

.pagination__size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.pager {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* When everything fits on one page the pager is hidden; the separator must
   disappear with it or it reads as an orphaned vertical rule. */
.pagination.is-single-page .pagination__sep {
  display: none;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}

.page-btn svg {
  width: 15px;
  height: 15px;
}

.page-btn:hover:not(:disabled):not(.is-current) {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink);
}

.page-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.page-btn:disabled {
  opacity: 0.4;
}

.page-btn.is-current {
  border-color: transparent;
  background: var(--brand);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px -6px var(--brand-glow);
  cursor: default;
}

.page-btn--nav {
  font-weight: 500;
}

.page-ellipsis {
  min-width: 24px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: center;
  user-select: none;
}

/* 14. Empty / error states ------------------------------------------------ */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 56px 24px 64px;
  text-align: center;
  animation: fade-in var(--dur-3) var(--ease) both;
}

.state__art {
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
  color: var(--muted);
  opacity: 0.95;
}

.state__art .art-brand {
  stroke: var(--brand);
}

.state__art .art-brand-fill {
  fill: var(--brand-soft);
  stroke: var(--brand);
}

.state__title {
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.state__desc {
  max-width: 320px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.state__action {
  margin-top: 18px;
}

.state--error {
  display: block;
  padding: 24px;
  text-align: left;
}

.state--error .alert {
  text-align: left;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-left: 3px solid var(--danger);
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.alert__icon {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 1px;
  color: var(--danger);
}

.alert__body {
  flex: 1;
  min-width: 0;
}

.alert__title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.alert__desc {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.5;
  word-break: break-word;
}

.alert__action {
  flex: none;
  margin-left: auto;
}

/* 15. Toast --------------------------------------------------------------- */
.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: calc(100vw - 40px);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  animation: toast-in 180ms var(--ease) both;
}

.toast.is-out {
  animation: toast-out 160ms var(--ease) both;
}

.toast__dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--brand);
}

.toast--success .toast__dot {
  background: #3ddc97;
}

.toast--error .toast__dot {
  background: #f07171;
}

.toast__text {
  min-width: 0;
}

/* 16. Spinner ------------------------------------------------------------- */
.spinner {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid rgba(255, 255, 255, 0.38);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* 17. Login page ---------------------------------------------------------- */
.login-page {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 40px 20px;
  overflow: hidden;
}

.login-page::after {
  content: "";
  position: fixed;
  inset: auto 0 -10% 0;
  z-index: 0;
  height: 60vh;
  background: radial-gradient(700px 380px at 50% 100%, rgba(91, 91, 214, 0.07), transparent 70%);
  pointer-events: none;
}

html[data-theme="dark"] .login-page::after {
  background: radial-gradient(700px 380px at 50% 100%, rgba(140, 140, 245, 0.08), transparent 70%);
}

.login-theme {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 30;
  border-color: var(--line);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 18, 24, 0.04);
}

.login-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 400px;
}

.login-card {
  width: 100%;
  padding: 34px 32px 26px;
  box-shadow: 0 1px 2px rgba(16, 18, 24, 0.04),
    0 24px 60px -36px rgba(16, 18, 24, 0.3);
  animation: rise 0.4s var(--ease) both;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 26px;
  text-align: center;
}

.login-title {
  margin-top: 18px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.login-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form .alert {
  margin-top: 2px;
  animation: rise 0.18s var(--ease) both;
}

.login-submit {
  margin-top: 6px;
}

.login-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.login-note svg {
  width: 13px;
  height: 13px;
  flex: none;
}

.login-footer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  text-align: center;
}

/* 18. Keyframes ----------------------------------------------------------- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  70%,
  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

@keyframes pulse-soft {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

/* 19. Responsive ---------------------------------------------------------- */
@media (max-width: 900px) {
  .page {
    padding: 24px 20px 56px;
  }

  .topbar__inner {
    padding: 0 20px;
  }

  .user-chip {
    display: none;
  }

  .table col.col-device,
  .table .col-device {
    display: none;
  }
}

@media (max-width: 760px) {
  :root {
    --topbar-h: 58px;
  }

  .brand__sub {
    display: none;
  }

  .topbar__inner {
    padding: 0 14px;
  }

  .page {
    padding: 20px 16px 48px;
  }

  .page__head {
    align-items: flex-start;
    margin-bottom: 18px;
  }

  .page__title {
    font-size: 24px;
  }

  .page__hint {
    display: none;
  }

  .stats {
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat {
    padding: 13px 14px 12px;
  }

  .stat__value {
    font-size: 22px;
  }

  .stat__value--sm {
    font-size: 17px;
  }

  .stat__hint {
    font-size: 11px;
  }

  .stat__label {
    font-size: 10px;
    letter-spacing: 0.06em;
  }

  .stat__icon {
    display: none;
  }

  .inbox {
    scroll-margin-top: 74px;
  }

  .toolbar {
    gap: 10px;
    padding: 12px 14px;
  }

  .search {
    flex: 1 1 100%;
    max-width: none;
  }

  .select {
    flex: 1 1 auto;
  }

  .select__input {
    width: 100%;
  }

  .toolbar__spacer,
  .toolbar__meta {
    display: none;
  }

  .refresh-btn {
    width: 44px;
    padding: 0;
  }

  .refresh-btn .btn__label {
    display: none;
  }

  .table {
    display: none;
  }

  .sms-list {
    display: block;
  }

  .pagination {
    gap: 10px;
    padding: 12px 14px;
  }

  .pagination__controls {
    justify-content: space-between;
    width: 100%;
    gap: 8px;
  }

  .pagination__sep {
    display: none;
  }

  .pagination__size {
    gap: 6px;
  }

  .page-btn--nav {
    padding: 0 10px;
  }

  .page-btn--nav .page-btn__label {
    display: none;
  }

  .page-num:not(.is-current),
  .page-ellipsis {
    display: none;
  }

  .login-page {
    padding: 24px 20px;
  }

  .login-card {
    padding: 28px 24px 22px;
  }

  .login-theme {
    top: 12px;
    right: 12px;
  }

  .login-title {
    font-size: 23px;
  }

  .login-brand {
    margin-bottom: 22px;
  }

  .logo-mark--lg {
    width: 48px;
    height: 48px;
    border-radius: 13px;
  }

  .logo-mark--lg svg {
    width: 25px;
    height: 25px;
  }

  .login-footer {
    display: none;
  }

  .toast-region {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 560px) {
  .status-chip {
    height: 30px;
    padding: 0 9px;
    font-size: 11px;
  }

  .topbar__divider {
    display: none;
  }

  .topbar__actions {
    gap: 2px;
  }

  .logout {
    width: 40px;
    padding: 0;
  }

  .logout .btn__label {
    display: none;
  }

  .page__title {
    font-size: 22px;
  }

  .page__subtitle {
    font-size: 12.5px;
  }

  .login-card {
    padding: 26px 22px 20px;
  }

  .login-title {
    font-size: 22px;
  }

  .toast-region {
    right: 16px;
    left: 16px;
    align-items: stretch;
  }

  .toast {
    max-width: none;
    justify-content: center;
  }
}

@media (max-width: 400px) {
  .stat__hint {
    display: none;
  }

  .stat__value {
    font-size: 20px;
  }

  .stat__value--sm {
    font-size: 15px;
  }

  .pagination__meta {
    font-size: 11.5px;
  }
}

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

  .skel::after {
    display: none;
  }
}
