:root {
  --bg: #f3f4f7;
  --panel: #ffffff;
  --text: #15171a;
  --muted: #6b7280;
  --line: #eaecf2;
  --shadow: 0 10px 30px rgba(12, 18, 28, 0.06);

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;

  --dark: #111214;

  --lav: #eeecff;
  --mint: #e9fbf3;
  --peach: #ffecef;
  --sky: #eaf2ff;

  --chip-hot: #1d1f23;
  --chip-active: #e9fbf3;
  --chip-active-t: #147a3d;
  --chip-pend: #fff7e6;
  --chip-pend-t: #9a6700;

  --purple: #7c6cf2;
  --pink: #ff7bb2;
  --blue: #4f88ff;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Page Layout */
.page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}

.page--authed {
  display: block;
  padding: 0;
}

.page-wrap {
  width: min(1100px, 100%);
}

/* App Shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  padding: 18px;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

/* Desktop: Collapse sidebar */
@media (min-width: 961px) {
  .app-shell.sidebar-collapsed {
    grid-template-columns: 0 1fr !important;
    gap: 0 !important;
  }
  
  .app-shell.sidebar-collapsed .app-shell__nav {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  .app-shell.sidebar-collapsed .app-shell__body {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    grid-column: 2 !important;
  }
}

/* Sidebar */
.app-shell__nav {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-xl);
  padding: 18px 14px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
  overflow: hidden;
  width: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 16px;
}

.brand__icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(17, 18, 20, 0.08);
  font-weight: 700;
}

.brand__title {
  font-weight: 700;
  letter-spacing: 0.4px;
  font-size: 14px;
}

.brand__subtitle {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-direction: column;
}

.nav__section {
  margin-top: 0;
}

.nav__section:not(:first-child) {
  margin-top: 12px;
}

.nav__label {
  font-size: 12px;
  color: var(--muted);
  margin: 10px 10px 8px;
  font-weight: 600;
  text-transform: none;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 4px 6px;
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
}

.nav__link:hover {
  background: rgba(255, 255, 255, 0.75);
}

.nav__link--active {
  background: var(--dark);
  color: #fff;
}

.nav__icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(17, 18, 20, 0.08);
  font-size: 14px;
}

.nav__link--active .nav__icon {
  background: rgba(255, 255, 255, 0.12);
}

.nav__footer {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(12, 18, 28, 0.05);
}

.user-pill__avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--dark);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 12px;
}

.user-pill__name {
  font-weight: 700;
  font-size: 13px;
}

.user-pill__email {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.link-muted {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 8px;
  transition: color 0.2s ease;
}

.link-muted:hover {
  color: var(--text);
}

/* Main Content */
.app-shell__body {
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 6px;
}

.sidebar-toggle {
  margin-right: auto;
  z-index: 1001;
  position: relative;
  cursor: pointer;
  pointer-events: auto;
}

.sidebar-toggle:hover {
  background: #fff;
  transform: scale(1.05);
}

.search {
  flex: 1;
  max-width: 540px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

.search__icon {
  color: var(--muted);
  font-weight: 700;
}

.search__input {
  border: 0;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: 14px;
  color: var(--text);
}

.search__input::placeholder {
  color: var(--muted);
}

.search__kbd {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
}

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

.iconbtn {
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(12, 18, 28, 0.05);
  transition: all 0.2s ease;
  font-size: 16px;
}

.iconbtn:hover {
  background: #fff;
}

.iconbtn--tiny {
  width: 34px;
  height: 34px;
  box-shadow: none;
}

.userpill {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  padding: 4px;
  box-shadow: 0 8px 18px rgba(12, 18, 28, 0.05);
  position: relative;
}

.userpill--dropdown {
  cursor: pointer;
}

.userpill__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(12, 18, 28, 0.15);
  min-width: 180px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 1000;
  overflow: hidden;
}

.userpill--dropdown.active .userpill__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.userpill__dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s ease;
  border-bottom: 1px solid var(--line);
}

.userpill__dropdown-item:last-child {
  border-bottom: none;
}

.userpill__dropdown-item:hover {
  background: var(--bg);
}

.userpill__dropdown-item span:first-child {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.avatar {
  border-radius: 999px;
  object-fit: cover;
}

.avatar--sm {
  width: 30px;
  height: 30px;
}

.avatar--xl {
  width: 94px;
  height: 94px;
  border-radius: 22px;
}

/* Page Content */
.page-content {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-xl);
  padding: 18px;
  box-shadow: var(--shadow);
}

.page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 6px 14px;
}

.title {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.4px;
  font-weight: 800;
}

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

.meta-pill {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
}

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: 0 12px 30px rgba(12, 18, 28, 0.06);
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.card__title {
  font-weight: 700;
  font-size: 15px;
}

.card__sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

/* Buttons */
.btn {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.9);
}

.btn--sm {
  padding: 8px 12px;
  font-size: 13px;
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.85);
}

.btn--dark {
  background: var(--dark);
  border-color: var(--dark);
  color: #fff;
  padding: 10px 16px;
}

.btn--dark:hover {
  background: #1a1c1f;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(90, 216, 255, 0.5);
  background: linear-gradient(135deg, #5ad8ff, #a78bfa);
  color: #050710;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(90, 216, 255, 0.25);
}

.btn-primary {
  position: relative;
  overflow: hidden;
}

.btn-primary .ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: ripple 500ms linear;
  background: rgba(255, 255, 255, 0.6);
  pointer-events: none;
}

@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Forms */
.form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 15px;
}

.field input:focus {
  outline: 1px solid var(--purple);
  box-shadow: 0 0 0 3px rgba(124, 108, 242, 0.15);
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.check input {
  accent-color: var(--purple);
}

.link {
  color: var(--purple);
  font-weight: 600;
}

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

/* Flash Messages */
.flash {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 109, 109, 0.08);
  color: #ff6d6d;
  margin-bottom: 8px;
}

.flash--error {
  border-color: rgba(255, 109, 109, 0.5);
}

.flash--success {
  background: rgba(20, 122, 61, 0.08);
  color: #147a3d;
  border-color: rgba(20, 122, 61, 0.5);
}

/* Note */
.note {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.note__title {
  font-weight: 700;
  font-size: 13px;
}

.note__text {
  color: var(--muted);
  margin-top: 4px;
  font-size: 12px;
}

/* Login Page Specific */
.page:not(.page--authed) .card {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.card__side {
  padding: 32px;
}

.card__side--visual {
  background: linear-gradient(135deg, rgba(124, 108, 242, 0.12), rgba(255, 123, 178, 0.08)), rgba(255, 255, 255, 0.9);
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
}

.logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  width: fit-content;
}

.logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.hero {
  display: grid;
  gap: 6px;
}

.hero__eyebrow {
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-size: 12px;
}

.hero__title {
  font-size: 24px;
  font-weight: 800;
}

.hero__subtitle {
  color: var(--muted);
  line-height: 1.5;
}

.hero__image img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #f9fafb;
}

.card__side--form {
  background: var(--panel);
  display: grid;
  gap: 18px;
}

.form-head .eyebrow {
  color: var(--muted);
  letter-spacing: 0.3px;
  font-size: 12px;
  margin: 0 0 4px;
}

.form-head .title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
}

.form-head .muted {
  margin-top: 6px;
  color: var(--muted);
}

.mt-16 {
  margin-top: 16px;
}

.btn-inline {
  width: auto;
  display: inline-flex;
}

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

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

table thead {
  background: rgba(0, 0, 0, 0.02);
}

table tbody tr:hover {
  background: rgba(0, 0, 0, 0.01);
}

table th,
table td {
  text-align: left;
  padding: 12px;
}

table th {
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

table td {
  font-size: 14px;
  border-bottom: 1px solid var(--line);
}

/* Responsive */
@media (max-width: 960px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
  
  table {
    font-size: 12px;
  }
  
  table th,
  table td {
    padding: 8px;
  }
  .card {
    grid-template-columns: 1fr;
  }

  .card__side--visual {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 0;
  }

  .app-shell__nav {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    width: 260px;
    height: 100vh;
    border-radius: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    display: grid !important;
    transform: translateX(-100%);
  }
  
  .app-shell:not(.sidebar-collapsed) .app-shell__nav {
    transform: translateX(0) !important;
  }

  .app-shell.sidebar-collapsed .app-shell__nav {
    transform: translateX(-100%) !important;
  }

  .app-shell__body {
    width: 100%;
  }
  
  /* Overlay for mobile when sidebar is open */
  .app-shell__body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
  }
  
  .app-shell:not(.sidebar-collapsed) .app-shell__body::before {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
  }
  
  .app-shell.sidebar-collapsed .app-shell__body::before {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

@media (max-width: 1200px) {
  .app-shell {
    gap: 12px;
    padding: 12px;
  }
}

/* Section Head */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.section-head__eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.section-head__title {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.3px;
}

/* Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stat__value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

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

/* Panel */
.panel {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-xl);
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel__title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 12px 0;
}

/* Table Wrapper */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table thead {
  background: rgba(0, 0, 0, 0.02);
}

.table tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background 0.2s ease;
}

.table tbody tr:hover {
  background: rgba(0, 0, 0, 0.01);
}

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

.table th {
  padding: 12px;
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.table td {
  padding: 12px;
  font-size: 13px;
  color: var(--text);
}

/* Muted text */
.muted {
  color: var(--muted);
  font-size: 12px;
}
