* {
  box-sizing: border-box;
}

:root {
  --primary: #5b35b5;
  --primary-dark: #43248e;
  --primary-light: #f0ebff;

  --background: #f5f6fa;
  --surface: #ffffff;

  --text: #20222a;
  --muted: #6d7280;

  --border: #e2e5ec;

  --success: #16834b;
  --success-light: #eaf8f0;

  --danger: #b42318;
  --danger-light: #fff0ef;

  --warning: #8a5b00;
  --warning-light: #fff8df;

  --shadow: 0 8px 30px rgba(26, 30, 45, 0.08);
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  color: var(--text);
  background: var(--background);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}


/* ========================================================
   LOGIN
   ======================================================== */

.login-view {
  min-height: 100vh;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 24px;

  background:
    linear-gradient(
      135deg,
      #3d237f,
      #6f42c1
    );
}

.login-card {
  width: 100%;
  max-width: 430px;

  padding: 38px;

  background: var(--surface);

  border-radius: 18px;

  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.22);
}

.brand-mark {
  width: 64px;
  height: 64px;

  margin: 0 auto 18px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 18px;

  background: var(--primary);
  color: white;

  font-size: 32px;
  font-weight: 800;
}

.brand-mark.small {
  width: 42px;
  height: 42px;

  margin: 0;

  border-radius: 12px;

  font-size: 22px;
}

.login-card h1 {
  margin: 0;
  text-align: center;
}

.subtitle {
  margin: 6px 0 30px;

  text-align: center;
  color: var(--muted);
}

.security-note {
  margin: 22px 0 0;

  text-align: center;

  color: var(--muted);
  font-size: 13px;
}


/* ========================================================
   FORMS
   ======================================================== */

label {
  display: block;

  margin: 16px 0 7px;

  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;

  padding: 12px 13px;

  border: 1px solid #ccd1dc;
  border-radius: 9px;

  background: white;
  color: var(--text);

  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);

  box-shadow:
    0 0 0 3px rgba(91, 53, 181, 0.12);
}

textarea {
  resize: vertical;
}

small {
  display: block;

  margin-top: 6px;

  color: var(--muted);
  line-height: 1.4;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;

  gap: 8px 22px;
}

.field.full {
  grid-column: 1 / -1;
}


/* ========================================================
   BUTTONS
   ======================================================== */

.primary-button,
.secondary-button {
  border: 0;
  border-radius: 9px;

  padding: 11px 17px;

  font-weight: 700;
}

.primary-button {
  background: var(--primary);
  color: white;
}

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

.secondary-button {
  border: 1px solid var(--border);

  background: white;
  color: var(--text);
}

.secondary-button:hover {
  background: #f5f5f8;
}

.full-width {
  width: 100%;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.login-card .primary-button {
  margin-top: 22px;
}


/* ========================================================
   ADMIN LAYOUT
   ======================================================== */

.admin-layout {
  min-height: 100vh;

  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  min-height: 100vh;

  position: sticky;
  top: 0;

  display: flex;
  flex-direction: column;

  padding: 24px 18px;

  background: #241546;
  color: white;
}

.sidebar-brand {
  display: flex;
  align-items: center;

  gap: 12px;

  margin-bottom: 34px;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand span {
  margin-top: 3px;

  color: #c8bce6;
  font-size: 12px;
}

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

  gap: 7px;
}

.nav-button {
  width: 100%;

  padding: 12px 13px;

  border: 0;
  border-radius: 9px;

  text-align: left;

  background: transparent;
  color: #ded7ee;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.sidebar-footer {
  margin-top: auto;
}

.admin-identity {
  margin-bottom: 12px;

  color: #c8bce6;

  font-size: 13px;
  line-height: 1.5;
}

.main-content {
  min-width: 0;

  padding: 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 20px;

  margin-bottom: 25px;
}

.topbar h1 {
  margin: 0 0 4px;
}

.topbar p {
  margin: 0;

  color: var(--muted);
}

.status-badge {
  padding: 8px 12px;

  border-radius: 999px;

  background: var(--success-light);
  color: var(--success);

  font-size: 13px;
  font-weight: 700;
}


/* ========================================================
   PANELS
   ======================================================== */

.panel,
.welcome-card,
.stat-card {
  background: var(--surface);

  border: 1px solid var(--border);
  border-radius: 14px;

  box-shadow: var(--shadow);
}

.panel {
  margin-bottom: 22px;

  padding: 24px;
}

.welcome-card {
  margin-bottom: 22px;

  padding: 25px;
}

.welcome-card h2 {
  margin-top: 0;
}

.welcome-card p {
  margin-bottom: 0;

  color: var(--muted);
  line-height: 1.6;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 18px;

  margin-bottom: 20px;
}

.panel-heading h2 {
  margin: 0 0 5px;
}

.panel-heading p {
  margin: 0;

  color: var(--muted);
}


/* ========================================================
   DASHBOARD
   ======================================================== */

.stats-grid {
  display: grid;

  grid-template-columns:
    repeat(4, minmax(0, 1fr));

  gap: 16px;

  margin-bottom: 22px;
}

.stat-card {
  padding: 20px;
}

.stat-card span {
  display: block;

  margin-bottom: 8px;

  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  font-size: 28px;
}

.package-grid {
  display: grid;

  grid-template-columns:
    repeat(3, minmax(0, 1fr));

  gap: 13px;
}

.package-card {
  padding: 16px;

  border: 1px solid var(--border);
  border-radius: 10px;

  background: #fafaff;
}

.package-card strong,
.package-card span {
  display: block;
}

.package-card span {
  margin-top: 5px;

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


/* ========================================================
   MESSAGES
   ======================================================== */

.message {
  margin: 15px 0;

  padding: 12px 14px;

  border-radius: 8px;

  line-height: 1.45;
}

.message.error {
  background: var(--danger-light);
  color: var(--danger);
}

.warning-box {
  margin: 18px 0;

  padding: 14px;

  border: 1px solid #f1d27a;
  border-radius: 9px;

  background: var(--warning-light);
  color: var(--warning);

  line-height: 1.5;
}


/* ========================================================
   GENERATED PIN RESULT
   ======================================================== */

.success-heading {
  display: flex;
  align-items: flex-start;

  gap: 14px;
}

.success-icon {
  width: 42px;
  height: 42px;

  flex: 0 0 42px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: var(--success-light);
  color: var(--success);

  font-size: 24px;
  font-weight: 800;
}

.success-heading h2 {
  margin: 0 0 5px;
}

.success-heading p {
  margin: 0;

  color: var(--muted);
}

.batch-summary {
  margin-top: 20px;

  display: grid;

  grid-template-columns:
    repeat(3, minmax(0, 1fr));

  gap: 10px;
}

.summary-item {
  padding: 12px;

  border: 1px solid var(--border);
  border-radius: 8px;

  background: #fafafa;
}

.summary-item span,
.summary-item strong {
  display: block;
}

.summary-item span {
  margin-bottom: 5px;

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

.pin-list {
  max-height: 420px;

  overflow: auto;

  padding: 18px;

  border-radius: 10px;

  background: #17141e;
  color: #f4f0ff;

  font-family:
    "Courier New",
    monospace;

  font-size: 15px;
  line-height: 1.8;

  white-space: pre-wrap;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;

  gap: 10px;

  margin: 16px 0;
}


/* ========================================================
   TABLE
   ======================================================== */

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

table {
  width: 100%;

  border-collapse: collapse;
}

th,
td {
  padding: 12px;

  border-bottom: 1px solid var(--border);

  text-align: left;
  vertical-align: middle;
}

th {
  background: #f7f7fa;

  color: var(--muted);

  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

td {
  font-size: 14px;
}

.table-button {
  padding: 7px 10px;

  border: 1px solid var(--border);
  border-radius: 7px;

  background: white;
}

.table-button:hover {
  background: var(--primary-light);
}

.detail-grid {
  display: grid;

  grid-template-columns:
    repeat(3, minmax(0, 1fr));

  gap: 12px;
}

.detail-item {
  padding: 13px;

  border: 1px solid var(--border);
  border-radius: 9px;
}

.detail-item span,
.detail-item strong {
  display: block;
}

.detail-item span {
  margin-bottom: 5px;

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


/* ========================================================
   RESPONSIVE
   ======================================================== */

@media (max-width: 1000px) {

  .admin-layout {
    grid-template-columns: 210px 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .package-grid {
    grid-template-columns: 1fr 1fr;
  }

}

@media (max-width: 760px) {

  .admin-layout {
    display: block;
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

  .sidebar nav {
    margin-bottom: 20px;
  }

  .main-content {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
  }

  .form-grid,
  .package-grid,
  .batch-summary,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

}

@media (max-width: 480px) {

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 26px 20px;
  }

}

/* ========================================================
   OFFICIAL STUDYSPARK BRANDING
   ======================================================== */

.login-logo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;

  margin: 0 auto 14px;
}

.login-logo {
  display: block;

  width: 100%;
  max-width: 285px;
  height: auto;

  object-fit: contain;
}

.sidebar-logo {
  display: block;

  width: 58px;
  height: 58px;

  flex: 0 0 58px;

  object-fit: contain;

  border-radius: 10px;

  background: #ffffff;

  padding: 3px;
}

@media (max-width: 480px) {

  .login-logo {
    max-width: 235px;
  }

}

/* ========================================================
   FINAL APPROVED STUDYSPARK LOGO SIZE
   ======================================================== */

/* Login page */
.login-logo {
  display: block;
  width: 180px;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

/* Left Admin sidebar */
.sidebar-logo {
  display: block;
  width: 55px;
  height: 55px;
  flex: 0 0 55px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  padding: 2px;
}

/* Smaller phones */
@media (max-width: 480px) {
  .login-logo {
    width: 155px;
  }

  .sidebar-logo {
    width: 50px;
    height: 50px;
    flex-basis: 50px;
  }
}
