@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --brand: #4338ca;
  --brand-dark: #362f9e;
  --brand-light: #eef2ff;
  --accent: #06b6d4;
  --danger: #dc2626;
  --muted: #71717a;
  --border: #e4e4e7;
  --shadow-soft: 0 1px 2px rgba(24, 24, 27, 0.04), 0 10px 28px rgba(67, 56, 202, 0.08);
  --shadow-hover: 0 4px 10px rgba(24, 24, 27, 0.05), 0 18px 40px rgba(67, 56, 202, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: radial-gradient(circle at 15% 10%, #eef2ff 0%, #f6f6f8 45%, #ececf1 100%);
  color: #18181b;
  -webkit-font-smoothing: antialiased;
}

nav {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(24, 24, 27, 0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  margin-right: 8px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-toggle {
  display: none;
  width: 44px;
  min-width: 44px;
  height: 44px;
  margin: 0 0 0 auto;
  padding: 8px;
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--border);
  box-shadow: none;
}

.nav-toggle span {
  display: block;
  height: 2px;
  margin: 4px 0;
  border-radius: 2px;
  background: currentColor;
}

nav a {
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color .15s;
}

nav a:hover {
  color: #111;
}

nav a.active {
  color: var(--brand);
  font-weight: 600;
  border-bottom-color: var(--brand);
}

.nav-logout {
  color: #b91c1c !important;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 9px;
  padding: 8px 12px !important;
  font-weight: 600;
}

.nav-logout:hover {
  color: #991b1b !important;
  background: #fee2e2;
}

.site-credit {
  flex: 0 0 auto;
  width: 100%;
  padding: 10px 20px 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
  letter-spacing: .01em;
}

.site-credit a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.site-credit a:hover {
  color: var(--brand);
  text-decoration: underline;
}

.page {
  width: 100%;
  flex: 1 0 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.page.top {
  align-items: flex-start;
  padding-top: 24px;
}

.card {
  background: white;
  border-radius: 20px;
  padding: 38px;
  box-shadow: var(--shadow-soft);
  border: 1px solid #f0f0f3;
  width: 100%;
  max-width: 400px;
  animation: fadeInUp .3s ease;
}

.card.wide {
  max-width: 760px;
}

.card.full {
  max-width: none;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h1 {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
  line-height: 1.5;
}

label {
  display: block;
  font-size: 13px;
  margin-top: 14px;
  color: #444;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}

button {
  margin-top: 18px;
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(180deg, #4f46e5, var(--brand));
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: filter .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 1px 2px rgba(67, 56, 202, 0.2);
}

button:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 12px rgba(67, 56, 202, 0.28);
}

button:active {
  transform: scale(.98);
}

button.secondary {
  background: var(--brand-light);
  color: var(--brand);
  border: 1px solid #e0e7ff;
  box-shadow: none;
}

button.secondary:hover {
  background: #e0e7ff;
  filter: none;
  box-shadow: none;
}

button.danger {
  background: linear-gradient(180deg, #ef4444, var(--danger));
  box-shadow: 0 1px 2px rgba(220, 38, 38, 0.25);
}

button.danger:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.row-btns {
  display: flex;
  gap: 10px;
}

.row-btns button {
  margin-top: 18px;
}

.msg {
  font-size: 13px;
  margin-top: 10px;
}

.ok {
  color: #16a34a;
}

.err {
  color: var(--danger);
}

.avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 700;
  color: white;
  margin: 0 auto 18px;
  box-shadow: 0 0 0 5px var(--brand-light), 0 8px 20px rgba(67, 56, 202, 0.18);
}

.center {
  text-align: center;
}

.idtext {
  color: #16a34a;
  font-size: 15px;
  font-weight: 600;
}

.namefield {
  font-size: 21px;
  font-weight: 700;
  margin: 6px 0 4px;
  letter-spacing: -0.01em;
}

.field {
  font-size: 14px;
  color: #444;
  margin: 3px 0;
}

.detail-grid {
  margin-top: 22px;
  border-top: 1px solid #eee;
  padding-top: 6px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 2px;
  font-size: 13px;
  border-bottom: 1px solid #f4f4f5;
}

.detail-label {
  color: #8b8b93;
}

.detail-value {
  color: #18181b;
  font-weight: 600;
}

.apps-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.app-card,
.admin-menu-item {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 16px 16px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  transition: transform .18s, box-shadow .18s;
}

.app-card::before,
.admin-menu-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.app-card:hover,
.admin-menu-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.app-card b,
.admin-menu-item b {
  display: block;
  font-size: 14px;
  margin-top: 6px;
}

.app-card span,
.admin-menu-item span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  display: block;
  margin-top: 4px;
}

.admin-menu-item svg {
  display: block;
}

.apps-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.app-tile {
  position: relative;
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 14px 18px;
  text-align: center;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s;
}

.app-tile:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.app-tile-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
  font-weight: 700;
  margin: 0 auto 14px;
  box-shadow: 0 6px 16px rgba(67, 56, 202, 0.2);
}

.app-tile-name {
  font-size: 14px;
  font-weight: 700;
}

.app-tile-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.app-tile-more {
  margin-top: 14px;
  width: auto;
  padding: 6px 16px;
  font-size: 12px;
  background: var(--brand-light);
  color: var(--brand);
  box-shadow: none;
}

.app-tile-more:hover {
  background: #e0e7ff;
  filter: none;
  box-shadow: none;
}

.hidden {
  display: none !important;
}

.admin-menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.admin-subsection {
  background: #fafafb;
  border: 1px solid #f0f0f2;
  border-radius: 14px;
  padding: 20px;
  margin-top: 16px;
}

.admin-subsection table {
  margin-top: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 700;
  padding-bottom: 10px;
}

tbody tr:nth-child(even) {
  background: #f8f8fa;
}

tbody td {
  padding: 9px 6px;
}

.logo-strip {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.pw-wrap {
  position: relative;
  width: 100%;
  margin-top: 4px;
}

.pw-wrap input {
  display: block;
  width: 100%;
  margin-top: 0;
  padding-right: 52px;
}

.pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  box-shadow: none;
  line-height: 0;
}

.pw-toggle svg {
  display: block;
}

.pw-toggle:hover {
  background: transparent;
  color: var(--brand);
  filter: none;
  box-shadow: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
}

.stat-tile {
  position: relative;
  overflow: hidden;
  background: #fafafb;
  border: 1px solid #f0f0f2;
  border-radius: 14px;
  padding: 18px 14px;
  text-align: center;
}

.stat-tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.stat-num {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

.activity-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid #f4f4f6;
  font-size: 13px;
}

.activity-row:last-child {
  border-bottom: none;
}

.activity-action {
  font-weight: 600;
  text-transform: capitalize;
}

.activity-target {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.activity-time {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 27, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-box {
  position: relative;
  background: white;
  border-radius: 18px;
  padding: 30px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  animation: fadeInUp .2s ease;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  width: auto;
  margin: 0;
  padding: 6px;
  color: var(--muted);
  cursor: pointer;
  box-shadow: none;
  font-size: 18px;
  line-height: 1;
}

.modal-close:hover {
  background: none;
  color: var(--brand);
  filter: none;
  box-shadow: none;
}

.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--brand);
  font-weight: 700;
  margin-bottom: 6px;
}

.back-link {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
}

.back-link:hover {
  color: var(--brand);
}

.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
  width: 100%;
}

@media (max-width: 820px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  min-width: 480px;
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  nav {
    padding: 10px 14px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .nav-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-top: 8px;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    font-size: 13px;
    padding: 11px 12px !important;
    border: 0;
    border-radius: 9px;
  }

  .nav-links a.active {
    background: var(--brand-light);
  }

  .nav-links .nav-logout {
    text-align: center;
    margin-top: 4px;
  }

  .page {
    padding: 24px 14px;
  }

  .card {
    padding: 24px 20px;
    border-radius: 16px;
  }

  .site-credit {
    padding: 0 14px 18px;
    font-size: 10.5px;
  }

  .card.wide,
  .card.full {
    max-width: 100%;
  }

  h1 {
    font-size: 17px;
  }

  .apps-grid,
  .apps-tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
  }

  .admin-menu-grid,
  .action-grid-3 {
    grid-template-columns: 1fr;
  }

  .stats-row,
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-row {
    font-size: 12.5px;
  }

  .modal-box {
    padding: 22px;
  }

  .row-btns {
    flex-direction: column;
  }
}


/* ---------- Accessibility and mobile polish ---------- */
button,
input,
select {
  min-height: 44px;
}

button,
input,
select {
  font: inherit;
}

.msg {
  overflow-wrap: anywhere;
  line-height: 1.5;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(67, 56, 202, 0.35);
  outline-offset: 2px;
}

.pw-toggle {
  min-width: 44px;
  min-height: 44px;
}

.app-tile {
  text-decoration: none;
  color: inherit;
}

.app-tile-more {
  min-height: 40px;
}

@media (max-width: 600px) {
  nav {
    justify-content: space-between;
  }

  thead th {
    font-size: 12px;
  }

  .app-tile-meta,
  .activity-time {
    font-size: 12px;
  }

  .table-wrap {
    position: relative;
  }

  .table-wrap::after {
    content: 'Swipe horizontally to see more';
    display: block;
    color: var(--muted);
    font-size: 12px;
    padding-top: 8px;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 10px;
  }

  .modal-box {
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 18px 18px 10px 10px;
  }
}

@media (min-width: 601px) {
  .table-wrap::after {
    display: none;
  }
}