:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #dde3ea;
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --danger: #dc2626;
  --ok: #0f9f6e;
  --warning: #b7791f;
  --shadow: 0 10px 30px rgb(15 23 42 / 0.07);
  --shadow-soft: 0 1px 2px rgb(15 23 42 / 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: inherit;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: #101828;
  color: #ffffff;
  box-shadow: var(--shadow);
}

.brand {
  font-size: 17px;
  font-weight: 700;
}

.nav-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-link,
.btn-logout {
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 6px;
  padding: 8px 10px;
  background: rgb(255 255 255 / 0.08);
  color: #ffffff;
  text-decoration: none;
}

.nav-link.active {
  background: var(--primary);
}

.app-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.loading,
.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  grid-column: span 12;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel.half {
  grid-column: span 6;
}

.account-panel {
  grid-column: span 8;
}

.video-panel {
  grid-column: span 4;
}

.search-panel {
  grid-column: span 5;
}

.utility-panel {
  grid-column: span 3;
}

.link-panel {
  grid-column: span 12;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 13px 16px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  font-weight: 700;
}

.panel-header small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.account-header {
  align-items: center;
}

.account-header > span {
  font-size: 18px;
}

.account-header-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  color: #98a2b3;
  font-size: 16px;
  font-weight: 500;
}

.account-header-stats strong {
  color: var(--ok);
  font-size: 17px;
}

.account-header-stats span:last-child strong {
  color: #e0a100;
}

.panel-body {
  padding: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  padding: 11px 12px;
  background: #fbfcfe;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.button-row,
.quick-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button,
.action-button {
  min-height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 12px;
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.primary-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.primary-actions button {
  min-height: 42px;
}

.account-choice {
  display: grid;
  gap: 42px;
  padding: 62px 18px 44px;
  text-align: center;
}

.account-choice .muted {
  margin: 0;
  font-size: 20px;
}

.account-choice-actions {
  display: grid;
  gap: 12px;
  width: min(100%, 760px);
  margin: 0 auto;
}

.account-choice-actions button {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  color: #ffffff;
  font-size: 18px;
  box-shadow: 0 4px 12px rgb(15 23 42 / 0.12);
}

.account-choice-actions .settings-icon,
.account-choice-actions .settings-icon svg {
  width: 22px;
  height: 22px;
  color: #ffffff;
}

.account-switch {
  display: grid;
  gap: 8px;
}

.account-switch .muted {
  margin: 0;
  font-weight: 700;
}

.account-switch-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.account-switch-actions button {
  border: 0;
  color: #ffffff;
}

button:hover,
.action-button:hover {
  border-color: var(--primary);
}

.btn-primary,
.btn-save {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover,
.btn-save:hover {
  background: var(--primary-dark);
}

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-small {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-group {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.form-group.full {
  grid-column: 1 / -1;
}

label {
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfd8e3;
  border-radius: 6px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
  outline: none;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.search-results,
.output-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #f8fafc;
  white-space: pre-wrap;
}

.issued-output {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.issued-output strong {
  display: block;
  margin-bottom: 4px;
}

.copy-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
}

.copy-field input {
  border-bottom-right-radius: 0;
  border-top-right-radius: 0;
}

.copy-icon-btn {
  min-width: 54px;
  min-height: 40px;
  border-left: 0;
  border-bottom-left-radius: 0;
  border-top-left-radius: 0;
  padding: 0 8px;
  background: #ffffff;
  color: #334155;
  font-size: 12px;
}

.copy-icon-btn.compact {
  min-width: 40px;
  width: 40px;
  font-size: 0;
}

.copy-icon-btn.compact::before,
.copy-icon-btn:not(.compact)::before {
  content: "⧉";
  color: #334155;
  font-size: 16px;
  line-height: 1;
}

.copy-icon-btn:not(.compact) {
  color: transparent;
}

.issued-output .copy-icon-btn {
  height: 40px;
  align-self: start;
  border-left: 1px solid #cbd5e1;
  border-radius: 6px;
}

.copy-icon-btn:hover {
  background: #eff6ff;
}

.issued-card {
  display: grid;
  gap: 12px;
}

.issued-card .form-group {
  margin-bottom: 0;
}

.issued-card label {
  font-size: 15px;
}

.issued-actions {
  display: grid;
  gap: 12px;
}

.issued-actions.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.btn-green,
.btn-teal,
.btn-refresh {
  border-color: transparent;
  color: #ffffff;
  font-size: 17px;
  font-weight: 700;
}

.btn-green {
  background: #29a94a;
}

.btn-green:hover {
  background: #208b3c;
}

.btn-teal {
  background: #21a6b8;
}

.btn-teal:hover {
  background: #168b9c;
}

.btn-refresh {
  background: #56a9e6;
  box-shadow: 0 4px 12px rgb(37 99 235 / 0.18);
}

.btn-refresh:hover {
  background: #3f96d4;
}

.wide {
  width: 100%;
  min-height: 44px;
}

.issued-divider {
  height: 2px;
  margin: 12px 0 2px;
  background: var(--primary);
}

.settings-page {
  width: min(920px, 100%);
  margin: 0 auto;
}

.settings-stack {
  display: grid;
  gap: 24px;
}

.settings-card {
  overflow: hidden;
  border: 1px solid #d9e1eb;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.settings-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  border-bottom: 1px solid #d9e1eb;
  padding: 0 18px;
  background: #f4f8fc;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
}

.settings-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.settings-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.settings-card-body {
  padding: 22px;
}

.settings-card-body form {
  display: grid;
  gap: 14px;
}

.settings-card-body .btn-save {
  width: 100%;
  min-height: 42px;
}

.settings-card-body h4 {
  margin: 2px 0 0;
  font-size: 14px;
}

.quick-settings-card {
  margin-bottom: 24px;
}

.settings-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  margin: 0;
  padding: 22px;
}

.settings-quick-grid button {
  display: grid;
  min-height: 96px;
  align-content: center;
  justify-items: center;
  gap: 8px;
  border-color: #d9e1eb;
  background: #ffffff;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 700;
  box-shadow: none;
}

.settings-quick-grid button .settings-icon,
.settings-quick-grid button .settings-icon svg {
  width: 26px;
  height: 26px;
  flex-basis: 26px;
}

.settings-quick-grid button:hover,
.settings-quick-grid button.active {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
}

.settings-back-link {
  display: block;
  margin: 28px auto 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.radio-stack {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.radio-stack .check-row {
  justify-content: flex-start;
  border: 0;
  padding: 0;
}

.radio-stack .check-row input {
  order: 0;
}

.check-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 11px 0;
  color: #334155;
  font-size: 13px;
}

.check-row input {
  width: auto;
  min-height: auto;
  order: 2;
  accent-color: var(--primary);
}

.check-row input[type="checkbox"] {
  position: relative;
  width: 38px;
  height: 20px;
  flex: 0 0 38px;
  border: 0;
  border-radius: 999px;
  appearance: none;
  background: #c7cbd1;
  cursor: pointer;
  transition: background 0.18s ease;
}

.check-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.22);
  transition: transform 0.18s ease;
}

.check-row input[type="checkbox"]:checked {
  background: var(--primary);
}

.check-row input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgb(15 23 42 / 0.54);
}

.modal {
  width: min(760px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 18px 45px rgb(15 23 42 / 0.28);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  font-weight: 700;
}

.modal-body {
  padding: 14px;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 70;
  max-width: 360px;
  border-radius: 4px;
  padding: 11px 13px;
  background: #111827;
  color: #ffffff;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
}

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

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

.page-head h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

.page-eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.head-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.head-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}

.video-panel .button-row {
  display: grid;
  grid-template-columns: 1fr;
}

.video-panel button {
  justify-content: flex-start;
  min-height: 44px;
  text-align: left;
}

.link-panel textarea {
  min-height: 150px;
}

.link-panel .form-actions {
  justify-content: flex-end;
}

.utility-panel input[readonly] {
  min-width: 0;
  background: #f8fafc;
}

.utility-panel .button-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.quick-actions {
  margin-bottom: 14px;
}

.quick-actions button {
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

@media (max-width: 760px) {
  .navbar,
  .nav-actions,
  .button-row,
  .quick-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .app-shell {
    padding: 10px;
  }

  .panel.half,
  .panel,
  .account-panel,
  .video-panel,
  .search-panel,
  .utility-panel,
  .link-panel {
    grid-column: span 12;
  }

  .stats,
  .primary-actions,
  .form-grid,
  .video-grid {
    grid-template-columns: 1fr;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .head-meta {
    justify-content: flex-start;
  }

  .utility-panel .button-row {
    grid-template-columns: 1fr;
  }

  .issued-output {
    grid-template-columns: 1fr;
  }

  .issued-output .copy-icon-btn {
    width: 100%;
  }

  .account-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-header-stats {
    gap: 8px 12px;
    font-size: 13px;
  }

  .issued-actions.two-col {
    grid-template-columns: 1fr;
  }

  .account-switch-actions {
    grid-template-columns: 1fr;
  }

  .copy-field input {
    border-bottom-right-radius: 0;
    border-top-right-radius: 0;
  }

  .copy-field .copy-icon-btn {
    width: auto;
    min-width: 42px;
    border-left: 0;
    border-bottom-left-radius: 0;
    border-top-left-radius: 0;
  }
}

@media (max-width: 430px) {
  body {
    font-size: 13px;
  }

  .navbar {
    gap: 8px;
    padding: 10px 12px;
  }

  .brand {
    font-size: 14px;
  }

  .nav-actions {
    gap: 6px;
  }

  .nav-link,
  .btn-logout {
    min-height: 34px;
    padding: 7px 9px;
  }

  .app-shell {
    padding: 8px;
  }

  .dashboard-grid {
    gap: 10px;
  }

  .page-head {
    gap: 10px;
    margin-bottom: 10px;
  }

  .page-head h1 {
    font-size: 22px;
  }

  .page-eyebrow {
    font-size: 11px;
  }

  .head-meta {
    gap: 6px;
  }

  .head-meta span {
    padding: 5px 8px;
    font-size: 11px;
  }

  .panel {
    border-radius: 7px;
    box-shadow: var(--shadow-soft);
  }

  .panel-header {
    gap: 8px;
    padding: 10px 12px;
  }

  .account-header > span {
    font-size: 16px;
  }

  .account-header-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, auto));
    gap: 4px 12px;
    font-size: 12px;
  }

  .account-header-stats strong {
    font-size: 13px;
  }

  .panel-body {
    padding: 12px;
  }

  .primary-actions {
    gap: 7px;
  }

  .settings-page {
    width: 100%;
  }

  .settings-stack {
    gap: 14px;
  }

  .settings-card-title {
    min-height: 46px;
    padding: 0 12px;
    font-size: 13px;
  }

  .settings-card-body {
    padding: 14px 12px;
  }

  .settings-quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
  }

  .settings-quick-grid button {
    min-height: 74px;
    padding: 8px;
    font-size: 12px;
  }

  .primary-actions button,
  button,
  .action-button {
    min-height: 38px;
    padding: 7px 10px;
    font-size: 13px;
  }

  .issued-card {
    gap: 10px;
  }

  .form-group {
    gap: 4px;
    margin-bottom: 10px;
  }

  .issued-card label,
  label {
    font-size: 13px;
  }

  input,
  textarea,
  select {
    min-height: 38px;
    padding: 8px 9px;
    font-size: 13px;
  }

  .copy-field {
    grid-template-columns: minmax(0, 1fr) 40px;
  }

  .copy-icon-btn {
    min-width: 38px;
    min-height: 38px;
    padding: 0 6px;
  }

  .copy-icon-btn.compact {
    min-width: 38px;
    width: 38px;
  }

  .copy-icon-btn.compact::before,
  .copy-icon-btn:not(.compact)::before {
    font-size: 14px;
  }

  .issued-actions {
    gap: 8px;
  }

  .btn-green,
  .btn-teal,
  .btn-refresh {
    font-size: 14px;
  }

  .wide {
    min-height: 40px;
  }

  .issued-divider {
    margin: 8px 0 0;
  }

  .video-panel button {
    min-height: 40px;
  }

  .link-panel textarea {
    min-height: 120px;
  }

  .link-panel .form-actions {
    justify-content: stretch;
  }

  .link-panel .form-actions button {
    flex: 1 1 0;
  }
}
