:root {
  --bg: #f7f8fc;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #64748b;
  --line: #d9e1ec;
  --blue: #2563eb;
  --teal: #0f766e;
  --orange: #ea580c;
  --red: #dc2626;
  --soft-blue: #eaf1ff;
  --soft-teal: #e6f7f4;
  --soft-orange: #fff4e7;
  --shadow: 0 12px 28px rgba(30, 41, 59, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 34%),
    linear-gradient(225deg, rgba(234, 88, 12, 0.08), transparent 32%),
    var(--bg);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.page-shell {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.page-shell.wide {
  width: min(1360px, calc(100% - 28px));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.topbar h1,
.login-card h1 {
  margin: 3px 0 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.1;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.panel,
.code-card,
.login-card {
  border: 1px solid rgba(217, 225, 236, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel h2,
.section-title h2 {
  margin: 0;
  font-size: 19px;
}

.panel p,
.muted {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

textarea,
input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 11px 12px;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.13);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

label span {
  color: var(--muted);
}

.primary-btn,
.plain-btn,
.ghost-link,
.small-btn {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.primary-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--teal), var(--blue));
}

.plain-btn {
  color: var(--teal);
  background: var(--soft-teal);
}

.ghost-link {
  color: var(--blue);
  background: var(--soft-blue);
}

.small-btn {
  min-height: 34px;
  padding: 0 10px;
  color: var(--ink);
  background: #eef2f7;
}

.small-btn.danger {
  color: #991b1b;
  background: #fee2e2;
}

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

.actions {
  margin-top: 12px;
}

.status-text {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-text.danger,
.danger {
  color: var(--red);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px;
  margin: 22px 0 10px;
}

.section-title span {
  color: var(--muted);
  font-weight: 900;
}

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

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.checkline input,
.card-select input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.card-select {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
}

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

.secret-panel {
  border-top: 4px solid var(--orange);
}

.cdk-panel {
  border-top: 4px solid var(--teal);
}

#publicStatus {
  margin: -2px 0 10px;
}

.single-secret-form {
  display: grid;
  gap: 11px;
}

.single-secret-form .plain-btn,
.single-secret-form .primary-btn {
  width: 100%;
}

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

.code-card {
  min-width: 0;
  padding: 14px;
  overflow: hidden;
}

.code-card:nth-child(3n + 1) {
  background: linear-gradient(180deg, #ffffff, var(--soft-teal));
}

.code-card:nth-child(3n + 2) {
  background: linear-gradient(180deg, #ffffff, var(--soft-blue));
}

.code-card:nth-child(3n) {
  background: linear-gradient(180deg, #ffffff, var(--soft-orange));
}

.card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.account-name {
  min-width: 0;
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 950;
  word-break: break-word;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--teal);
  background: rgba(15, 118, 110, 0.12);
  font-size: 12px;
  font-weight: 900;
}

.badge.off {
  color: var(--red);
  background: rgba(220, 38, 38, 0.12);
}

.code-value {
  margin: 16px 0 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(34px, 7vw, 52px);
  line-height: 1;
  font-weight: 950;
  color: #0f172a;
  letter-spacing: 0;
}

.remaining {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(100, 116, 139, 0.16);
}

.remaining > span {
  display: block;
  height: 100%;
  width: 50%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--orange), var(--teal));
  transition: width 0.25s linear;
}

.meta {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  word-break: break-all;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(320px, 1.18fr);
  gap: 12px;
}

.form-panel {
  display: grid;
  gap: 11px;
  align-content: start;
}

.admin-fields {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.admin-fields textarea {
  min-height: 68px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-card {
  padding: 22px;
}

.login-card label {
  margin: 18px 0 12px;
}

@media (max-width: 940px) {
  .code-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (max-width: 620px) {
  .page-shell,
  .page-shell.wide {
    width: min(100% - 18px, 560px);
    padding-top: 12px;
  }

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

  .top-actions {
    justify-content: stretch;
  }

  .top-actions > *,
  .actions > *,
  .toolbar-actions > *,
  .primary-btn,
  .plain-btn,
  .ghost-link {
    width: 100%;
  }

  .admin-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

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

  .panel,
  .code-card {
    padding: 12px;
  }

  .code-value {
    font-size: 44px;
  }
}
