:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-strong: #eef4f8;
  --line: #dce4ec;
  --line-strong: #b7c5d1;
  --text: #111827;
  --muted: #64748b;
  --muted-strong: #475569;
  --nav: #111827;
  --nav-soft: #1f2937;
  --nav-muted: #a7b3c2;
  --blue: #2563eb;
  --blue-strong: #1d4ed8;
  --teal: #0f766e;
  --teal-strong: #0b5f59;
  --amber: #a05a10;
  --danger: #b42318;
  --success: #147a52;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.06);
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.16);
  --radius: 8px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: Inter, "Avenir Next", "Helvetica Neue", "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  font-family: var(--sans);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background:
    linear-gradient(rgba(148, 163, 184, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.1) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px, 32px 32px, auto;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 180ms ease;
}

.app-shell.is-sidebar-collapsed {
  grid-template-columns: 76px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 18px;
  overflow: hidden;
  padding: 20px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(31, 41, 55, 0.94), rgba(17, 24, 39, 0.98)),
    var(--nav);
  color: #ffffff;
}

.brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 20px;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 0;
  border: 0;
  background: transparent;
  appearance: none;
  color: #ffffff;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--blue), var(--teal));
  color: #ffffff;
  font-weight: 900;
  letter-spacing: 0;
}

.brand:hover .brand-mark {
  border-color: rgba(191, 219, 254, 0.5);
}

.brand-copy {
  min-width: 0;
}

.sidebar-toggle-indicator {
  display: grid;
  width: 20px;
  height: 28px;
  place-items: center;
  color: #dbeafe;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
}

.brand strong,
.brand small,
.tool-link-copy strong,
.tool-link-copy small {
  display: block;
}

.brand strong {
  overflow: hidden;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small {
  margin-top: 3px;
  color: var(--nav-muted);
  font-size: 0.78rem;
}

.nav-section-label {
  margin-top: 6px;
  color: #d5dce7;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-nav {
  display: grid;
  gap: 8px;
}

.tool-link {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 72px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  color: #ffffff;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease;
}

.tool-link:hover,
.tool-link.is-active {
  border-color: rgba(96, 165, 250, 0.42);
  background: rgba(37, 99, 235, 0.16);
}

.tool-link-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(96, 165, 250, 0.34);
  border-radius: var(--radius);
  background: rgba(37, 99, 235, 0.16);
  color: #bfdbfe;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 900;
}

.tool-link-copy strong {
  overflow: hidden;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-link-copy small {
  margin-top: 4px;
  overflow: hidden;
  color: var(--nav-muted);
  font-size: 0.78rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-panel {
  min-width: 0;
  width: 100%;
  padding: 22px clamp(20px, 3vw, 42px) 34px;
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 42px;
  margin-bottom: 18px;
}

.breadcrumb,
.bar-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.breadcrumb {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.breadcrumb strong {
  color: var(--text);
}

.bar-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted-strong);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.app-shell.is-sidebar-collapsed .sidebar {
  align-items: center;
  gap: 14px;
  padding: 16px;
}

.app-shell.is-sidebar-collapsed .brand {
  grid-template-columns: 44px;
  width: 44px;
  min-height: 44px;
}

.app-shell.is-sidebar-collapsed .brand-copy,
.app-shell.is-sidebar-collapsed .sidebar-toggle-indicator,
.app-shell.is-sidebar-collapsed .nav-section-label,
.app-shell.is-sidebar-collapsed .tool-link-copy {
  display: none;
}

.app-shell.is-sidebar-collapsed .tool-nav,
.app-shell.is-sidebar-collapsed .tool-link {
  width: 44px;
}

.app-shell.is-sidebar-collapsed .tool-link {
  grid-template-columns: 44px;
  min-height: 52px;
  padding: 4px 0;
  place-items: center;
}

.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.page-head.compact {
  margin-bottom: 16px;
}

.page-title {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.lead {
  max-width: 840px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.trust-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.trust-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.84);
  color: #334155;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: var(--shadow-soft);
}

.trust-strip strong {
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
}

.toolbar-label {
  margin: 0 0 7px 2px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  width: min(580px, 100%);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.segmented button {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-strong);
  cursor: pointer;
  font-weight: 800;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button[aria-pressed="true"] {
  background: var(--nav);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
}

.actions,
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 13px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.button:focus-visible,
.segmented button:focus-visible,
.tool-link:focus-visible,
.brand:focus-visible {
  outline: 0;
  box-shadow: var(--focus);
}

.button.primary {
  background: var(--teal);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.18);
}

.button.primary:hover {
  background: var(--teal-strong);
}

.button.session {
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.24);
}

.button.session:hover {
  background: var(--blue-strong);
}

.button.secondary,
.button.ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.button.secondary:hover,
.button.ghost:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  height: clamp(680px, calc(100vh - 214px), 900px);
}

.panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  min-height: 76px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.panel-head h2 {
  margin-bottom: 4px;
  font-size: 1rem;
  line-height: 1.25;
}

.panel-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.panel-body {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  padding: 14px 16px 16px;
}

.warning,
.notice,
.issues {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  line-height: 1.45;
}

.warning {
  display: grid;
  gap: 3px;
  margin-bottom: 12px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  background: #eef6ff;
  color: #26384f;
}

.warning strong {
  color: var(--blue-strong);
}

.notice {
  margin: 0 0 12px;
  border: 1px solid rgba(160, 90, 16, 0.24);
  background: #fff8eb;
  color: var(--amber);
}

.hidden {
  display: none !important;
}

textarea {
  display: block;
  width: 100%;
  min-height: 0;
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: #fbfdff;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.03);
}

textarea:focus {
  border-color: var(--blue);
  outline: 0;
  box-shadow: var(--focus);
}

textarea::placeholder {
  color: #94a3b8;
}

textarea[readonly] {
  border-color: #1e293b;
  background: #0f172a;
  color: #dbeafe;
}

textarea[readonly]::placeholder {
  color: #64748b;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stat {
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.stat-value {
  overflow: hidden;
  font-family: var(--mono);
  font-size: 1.12rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.accounts {
  overflow: auto;
  max-height: 168px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.86rem;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

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

.col-name {
  width: 23%;
}

.col-email {
  width: 31%;
}

.col-expiry {
  width: 24%;
}

.cell-clip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  color: var(--muted);
}

.status-line {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.status-line.is-ok {
  color: var(--success);
}

.status-line.is-error {
  color: var(--danger);
}

.issues {
  display: none;
  margin: 0 0 12px;
  border: 1px solid rgba(180, 35, 24, 0.24);
  background: #fff7f7;
  color: var(--danger);
}

.issues.is-visible {
  display: block;
}

@media (max-width: 1180px) {
  .app-shell,
  .app-shell.is-sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .app-shell.is-sidebar-collapsed .sidebar {
    align-items: flex-start;
    padding: 20px;
  }

  .tool-nav {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .page-head,
  .toolbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .workspace {
    height: auto;
  }

  .panel {
    min-height: 620px;
  }

  .trust-strip,
  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .main-panel,
  .sidebar {
    padding: 14px;
  }

  .app-bar {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 14px;
  }

  h1 {
    font-size: 1.72rem;
  }

  .lead {
    font-size: 0.94rem;
  }

  .toolbar,
  .panel-head {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions,
  .panel-actions,
  .summary {
    display: grid;
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  textarea {
    min-height: 300px;
    font-size: 0.8rem;
  }

  .col-expiry,
  .col-source,
  td:nth-child(3),
  td:nth-child(4),
  th:nth-child(3),
  th:nth-child(4) {
    display: none;
  }

  .col-name,
  .col-email {
    width: 50%;
  }
}
