﻿:root,
:root[data-theme=light] {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --surface: #F5F7FA;
  --card: #FFFFFF;
  --border: #DCE3EA;
  --muted: #5B6B7B;
  --ink: #1B2733;
  --green: #2E7D5B;
  --red: #B4443C;
  --amber: #C98A2D;
  --hover: #F2F6FC;
  --chip-bg: #EAF0FB;
  --chip-ink: #2563EB;
  --sidebar-bg: #1B2733;
  --sidebar-ink: #FFFFFF;
  --sidebar-accent: #8FB4F5;
  --shadow: 0 14px 40px rgba(27, 39, 51, .12);
  --shadow-sm: 0 4px 14px rgba(27, 39, 51, .08);
}

:root[data-theme=dark] {
  --primary: #3B82F6;
  --primary-dark: #2563EB;
  --surface: #0F1620;
  --card: #18222E;
  --border: #2A3746;
  --muted: #8695A6;
  --ink: #E7ECF2;
  --green: #4FB488;
  --red: #E0776E;
  --amber: #E0A64A;
  --hover: #1E2A38;
  --chip-bg: #1E2E44;
  --chip-ink: #9DC1FB;
  --sidebar-bg: #0B121A;
  --sidebar-ink: #E7ECF2;
  --sidebar-accent: #8FB4F5;
  --shadow: 0 14px 40px rgba(0, 0, 0, .5);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, .35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  background: var(--surface);
  color: var(--ink);
  min-height: 100vh;
  transition: background 0.2s ease, color 0.2s ease;
}

.mono {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

a {
  color: var(--primary);
  text-decoration: none;
}

h1, h2, h3, .brand {
  font-family: "Sora", system-ui, sans-serif;
}

button {
  font-family: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: 0;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-primary:active {
  transform: scale(0.99);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 9px 15px;
  border-radius: 8px;
  font-size: 13px;
  transition: background 0.15s ease;
}
.btn-secondary:hover {
  background: var(--hover);
}

.btn-danger {
  background: var(--card);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 9px 15px;
  border-radius: 8px;
  font-size: 13px;
}
.btn-danger:hover {
  background: rgba(180, 68, 60, 0.08);
}

.btn-block {
  width: 100%;
  display: block;
}

input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--card);
  color: var(--ink);
  width: 100%;
  transition: border-color 0.15s ease;
}
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus, input[type=search]:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.field {
  margin-bottom: 12px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 12px;
  white-space: nowrap;
}
.badge.active {
  background: rgba(46, 125, 91, 0.14);
  color: var(--green);
}
.badge.invited {
  background: var(--chip-bg);
  color: var(--chip-ink);
}
.badge.locked {
  background: rgba(180, 68, 60, 0.14);
  color: var(--red);
}
.badge.deactivated {
  background: rgba(91, 107, 123, 0.16);
  color: var(--muted);
}

.pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  letter-spacing: 0.05em;
}

.pill-env {
  background: var(--amber);
  color: #fff;
}

.chip {
  display: inline-block;
  font-size: 11px;
  background: var(--chip-bg);
  color: var(--chip-ink);
  border-radius: 11px;
  padding: 2px 9px;
  margin: 1px 2px;
}
.chip.muted {
  background: rgba(91, 107, 123, 0.16);
  color: var(--muted);
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.panel-pad {
  padding: 16px 18px;
}

.panel h3, .panel-title {
  font-family: "Sora", sans-serif;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr.clickable {
  cursor: pointer;
}

tbody tr.clickable:hover {
  background: var(--hover);
}

.table-wrap {
  overflow-x: auto;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 14px 4px;
}

.switch {
  position: relative;
  width: 38px;
  height: 21px;
  flex-shrink: 0;
  display: inline-block;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #C7D1DB;
  border-radius: 11px;
  transition: 0.15s;
  cursor: pointer;
}
.slider:before {
  content: "";
  position: absolute;
  height: 15px;
  width: 15px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.15s;
}

.switch input:checked + .slider {
  background: var(--green);
}

.switch input:checked + .slider:before {
  transform: translateX(17px);
}

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  background: none;
  border: 0;
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color 0.12s ease;
}
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 15px;
}
.kpi b {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 24px;
  font-weight: 500;
}
.kpi span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .two-col {
    grid-template-columns: 1fr;
  }
}
.portal {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  padding: 18px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-size: 14.5px;
  font-weight: 700;
  padding: 0 18px 16px;
}
.brand span {
  color: var(--sidebar-accent);
  font-weight: 500;
}

.nav {
  display: flex;
  flex-direction: column;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  color: var(--sidebar-ink);
  opacity: 0.7;
  font-size: 13.5px;
  padding: 10px 18px;
  border-left: 3px solid transparent;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.nav-item:hover {
  opacity: 1;
}
.nav-item.active {
  opacity: 1;
  border-left-color: var(--sidebar-accent);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-foot a {
  color: var(--sidebar-accent);
}

.portal-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-search {
  max-width: 420px;
  flex: 1;
}

.topbar-user {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}

.lang {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 11.5px;
  color: var(--muted);
}
.lang a {
  color: var(--muted);
  padding: 2px 5px;
  border-radius: 4px;
}
.lang a.active {
  color: var(--primary);
  font-weight: 600;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--ink);
  width: 32px;
  height: 32px;
  font-size: 15px;
}

.content {
  padding: 22px 24px 60px;
  max-width: 1200px;
  width: 100%;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-title h1 {
  font-size: 19px;
  font-weight: 600;
}
.page-title .spacer {
  margin-left: auto;
}

.back-link {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 0;
  margin-bottom: 8px;
}
.back-link:hover {
  color: var(--ink);
}

@media (max-width: 780px) {
  .portal {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar-foot {
    margin: 0 0 0 auto;
    border: 0;
  }
}
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--card) 100%);
}

.login-card {
  width: 400px;
  max-width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 12px;
  padding: 30px 30px 22px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 20px;
}
.login-brand b {
  font-family: "Sora", sans-serif;
  font-size: 15px;
}
.login-brand span {
  font-family: "Sora", sans-serif;
  font-size: 15px;
  color: var(--primary);
  font-weight: 600;
}

.login-context {
  font-size: 14px;
  margin-bottom: 18px;
  line-height: 1.5;
}

.login-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
}

.alert-error {
  background: rgba(180, 68, 60, 0.12);
  color: var(--red);
  border: 1px solid rgba(180, 68, 60, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.alert-success {
  background: rgba(46, 125, 91, 0.12);
  color: var(--green);
  border: 1px solid rgba(46, 125, 91, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin: 4px 0 16px;
}
.checkbox-row label {
  margin: 0;
}
.checkbox-row input {
  width: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 39, 51, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal {
  background: var(--card);
  border-radius: 13px;
  max-width: 540px;
  width: 100%;
  box-shadow: var(--shadow);
}

.modal-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-head h2 {
  font-size: 15.5px;
  font-weight: 600;
}

.modal-body {
  padding: 18px 22px;
  font-size: 13.5px;
}

.modal-foot {
  padding: 13px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-close {
  background: none;
  border: 0;
  font-size: 20px;
  color: var(--muted);
  padding: 2px 8px;
}

.summary-box {
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 13px;
  line-height: 1.55;
  margin-top: 6px;
}

.secret-box {
  background: var(--hover);
  border: 1px dashed var(--primary);
  border-radius: 8px;
  padding: 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  word-break: break-all;
  margin: 10px 0;
}

.warn-box {
  background: rgba(201, 138, 45, 0.12);
  border: 1px solid rgba(201, 138, 45, 0.35);
  color: var(--amber);
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-top: 10px;
}

.access-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}

.access-card-head {
  background: var(--hover);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13.5px;
  display: flex;
  justify-content: space-between;
}

.access-row {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 10px;
  align-items: center;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--sidebar-bg);
  color: #fff;
  padding: 12px 20px;
  border-radius: 9px;
  font-size: 13.5px;
  display: none;
  box-shadow: var(--shadow);
  max-width: min(560px, 92vw);
  z-index: 200;
  text-align: center;
}
.toast.show {
  display: block;
}

.claims {
  background: var(--sidebar-bg);
  color: #D7E3F4;
  border-radius: 10px;
  padding: 16px 18px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
}

.page-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: no-preference) {
  .modal {
    animation: pop 0.22s ease;
  }
  .content > * {
    animation: fade-in 0.2s ease;
  }
  @keyframes pop {
    from {
      opacity: 0;
      transform: translateY(12px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
  @keyframes fade-in {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}
