/* AuthLocker — gateway UI */

:root {
  --bg: #0b0f17;
  --bg-soft: #111725;
  --panel: #141b2b;
  --panel-2: #182033;
  --line: #243049;
  --line-soft: #1c2740;
  --text: #e7ecf7;
  --muted: #8b98b3;
  --accent: #6c8cff;
  --accent-2: #46d3c4;
  --danger: #ff6b6b;
  --ok: #3ddc97;
  --warn: #ffcc66;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 15% -10%, rgba(108, 140, 255, .16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(70, 211, 196, .10), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }

p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.pad { padding: 20px 22px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 26px;
  height: 62px;
  background: rgba(11, 15, 23, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #08101d;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .02em;
}
.brand-mark.lg {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  font-size: 20px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}

.topnav > a {
  color: var(--muted);
  padding: 7px 11px;
  border-radius: 8px;
  font-weight: 550;
  font-size: 14px;
}
.topnav > a:hover {
  color: var(--text);
  background: var(--panel);
  text-decoration: none;
}
.topnav > a.active {
  color: var(--text);
  background: var(--panel-2);
  box-shadow: inset 0 0 0 1px var(--line);
}

.who {
  margin-left: 10px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linkbtn {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
}
.linkbtn:hover { color: var(--danger); background: rgba(255, 107, 107, .08); }

/* ---------- layout ---------- */

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 30px 26px 70px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head .muted { margin-top: 4px; }

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- panels ---------- */

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .015);
}

.danger-zone .panel-head { border-bottom-color: rgba(255, 107, 107, .25); }
.danger-zone p { padding: 16px 22px 0; }

/* ---------- stats ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 6px;
}
.stat-value { font-size: 28px; font-weight: 700; }

/* ---------- tables ---------- */

.table-scroll { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th {
  text-align: left;
  padding: 11px 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .012);
}
.table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(108, 140, 255, .045); }
.table.matrix th, .table.matrix td { padding: 12px 14px; }
.table input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.reset-form { display: inline-flex; gap: 6px; align-items: center; }
.reset-form input[type="password"] {
  width: 130px;
  padding: 6px 9px;
  font-size: 13px;
}

/* ---------- tags & dots ---------- */

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.tag-accent {
  background: rgba(108, 140, 255, .14);
  border-color: rgba(108, 140, 255, .4);
  color: #aebfff;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: 1px;
}
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(61, 220, 151, .15); }
.dot.off { background: #5a657d; box-shadow: 0 0 0 3px rgba(90, 101, 125, .15); }

/* ---------- forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.field.grow { flex: 1 1 200px; }

input[type="text"],
input[type="email"],
input[type="password"],
select {
  width: 100%;
  padding: 10px 12px;
  background: #0d1320;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, .18);
}
input::placeholder { color: #56617a; }

.hint { color: var(--muted); font-size: 12px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.checks { display: flex; gap: 22px; flex-wrap: wrap; }

.stack { display: flex; flex-direction: column; gap: 16px; padding: 22px; }
.stack > .actions { margin-top: 4px; }

.row-form {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 18px 22px;
  flex-wrap: wrap;
}
.row-form .field { flex: 0 0 150px; }
.row-form .field.grow { flex: 1 1 220px; }

.inline { display: inline; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: #1e2740; border-color: #31406a; text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: linear-gradient(140deg, var(--accent), #5a76e8);
  border-color: transparent;
  color: #0a1020;
}
.btn.primary:hover { filter: brightness(1.08); background: linear-gradient(140deg, var(--accent), #5a76e8); }

.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }

.btn.danger {
  background: rgba(255, 107, 107, .1);
  border-color: rgba(255, 107, 107, .35);
  color: #ff9a9a;
}
.btn.danger:hover { background: rgba(255, 107, 107, .18); }

.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }

/* ---------- alerts ---------- */

.alert {
  padding: 12px 15px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert.ok {
  background: rgba(61, 220, 151, .1);
  border-color: rgba(61, 220, 151, .3);
  color: #8ff0c2;
}
.alert.err {
  background: rgba(255, 107, 107, .1);
  border-color: rgba(255, 107, 107, .32);
  color: #ffadad;
}
.alert.info {
  background: rgba(108, 140, 255, .1);
  border-color: rgba(108, 140, 255, .32);
  color: #b6c4ff;
}

/* ---------- auth screens ---------- */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  padding: 34px 32px 28px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}
.auth-card.center { text-align: center; }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card > .muted { margin-bottom: 22px; }

.auth-logo { margin-bottom: 18px; }
.auth-card.center .auth-logo { display: flex; justify-content: center; }

.auth-card form.stack { padding: 0; }

.foot-note {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
  font-size: 12px;
}

.auth-card .actions { justify-content: center; margin-top: 22px; }

/* ---------- portal ---------- */

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.app-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .12s;
}
.app-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}

.app-avatar {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(140deg, rgba(108, 140, 255, .25), rgba(70, 211, 196, .18));
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 14px;
  color: #c3cdff;
}

.app-body { min-width: 0; flex: 1; }
.app-body h2 { font-size: 15px; margin-bottom: 2px; }
.app-body p { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-arrow { color: var(--muted); font-size: 16px; }

/* ---------- empty ---------- */

.empty {
  text-align: center;
  padding: 54px 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .012);
}
.empty h2 { margin-bottom: 6px; }
.empty .actions { justify-content: center; margin-top: 18px; }

/* ---------- responsive ---------- */

@media (max-width: 820px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { padding: 0 16px; height: auto; min-height: 62px; flex-wrap: wrap; }
  .topnav { width: 100%; margin-left: 0; padding-bottom: 10px; }
  .who { margin-left: 0; padding-left: 0; border-left: 0; width: 100%; }
  .wrap { padding: 22px 16px 60px; }
}

@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 22px 24px; }
  .row-form .field { flex: 1 1 100%; }
  .table th, .table td { padding: 10px 12px; }
}
