:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #6a7684;
  --line: #d8e0e8;
  --accent: #156f7a;
  --accent-dark: #0e5962;
  --accent-soft: #dff3f5;
  --danger: #b23a48;
  --danger-soft: #fbe8eb;
  --warning: #8a5a00;
  --shadow: 0 18px 50px rgba(27, 44, 58, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(21, 111, 122, 0.14), rgba(238, 242, 246, 0) 38%),
    linear-gradient(315deg, rgba(178, 58, 72, 0.09), rgba(238, 242, 246, 0) 42%),
    var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
  min-height: 44px;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

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

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

textarea {
  min-height: 96px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(21, 111, 122, 0.14);
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
}

.login-panel,
.app-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(216, 224, 232, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  max-width: 680px;
  margin: 12vh auto 0;
  padding: 34px;
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 34px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
}

.brand p,
.meta-line,
.status-text {
  color: var(--muted);
}

.status-text.error-state {
  color: var(--danger);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.text-link {
  display: block;
  width: max-content;
  min-height: 0;
  margin: 4px auto 0;
  padding: 4px 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.text-link:hover:not(:disabled) {
  background: transparent;
  color: var(--accent-dark);
  transform: none;
}

.error {
  min-height: 24px;
  margin-top: 12px;
  color: var(--danger);
  font-weight: 700;
}

.hidden {
  display: none;
}

.app-panel {
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.customer-topbar {
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(220px, 1fr) auto;
}

.topbar-card {
  min-width: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 22px;
  overflow-wrap: anywhere;
}

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

.balance {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.balance span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.balance strong {
  font-size: 14px;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 0;
}

.control-surface,
.number-surface,
.sms-surface {
  padding: 24px;
}

.control-surface {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.number-surface {
  border-bottom: 1px solid var(--line);
}

.sms-surface {
  grid-column: 1 / -1;
  min-height: 220px;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.secondary-btn {
  background: #37556b;
}

.secondary-btn:hover:not(:disabled) {
  background: #2b4254;
}

.danger-btn {
  background: var(--danger);
}

.danger-btn:hover:not(:disabled) {
  background: #942f3b;
}

.ghost-btn,
.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.icon-btn {
  min-width: 74px;
}

.ghost-btn:hover:not(:disabled),
.icon-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.small {
  min-height: 36px;
  padding: 0 12px;
}

.status-text {
  min-height: 24px;
  margin-top: 18px;
}

.feedback-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

.dialog-feedback-form {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.feedback-dialog {
  width: min(520px, calc(100% - 32px));
}

.generate-dialog {
  width: min(620px, calc(100% - 32px));
}

.generate-form {
  margin-top: 16px;
}

.generated-cards-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  overflow: auto;
}

.generated-cards-list code {
  display: block;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.sms-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

#copySmsBtn {
  min-width: 74px;
}

.sms-heading-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.number-tip,
.topbar-tip {
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 14px;
  line-height: 1.5;
}

.number-tip {
  margin-bottom: 16px;
}

.topbar-tip {
  width: min(100%, 360px);
  margin: 0 auto;
}

.phone-number {
  min-height: 70px;
  margin-top: 14px;
  font-size: 40px;
  font-weight: 900;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.meta-line {
  min-height: 24px;
  margin-top: 8px;
}

.sms-box {
  min-height: 140px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #f8fafc;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sms-box.success {
  border-color: rgba(21, 111, 122, 0.38);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 38px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  letter-spacing: 0;
}

.otp-label {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

.otp-code {
  margin-top: 6px;
  color: var(--ink);
  font-size: 34px;
  font-weight: 900;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.sms-message {
  margin-top: 14px;
  color: var(--ink);
  line-height: 1.6;
}

.sms-box.timeout {
  border-color: rgba(138, 90, 0, 0.32);
  background: #fff4d8;
  color: var(--warning);
}

.admin-surface {
  padding: 24px;
}

.admin-card-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-card-tools h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.admin-card-tools p {
  color: var(--muted);
  line-height: 1.5;
}

.admin-card-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.confirm-dialog.cards-dialog {
  width: min(960px, calc(100vw - 64px));
  max-width: none;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  padding: 24px;
  overflow: hidden;
}

.cards-dialog-head,
.cards-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.cards-dialog-head p {
  margin: 0;
  line-height: 1.3;
}

.cards-dialog-head h3 {
  margin-bottom: 4px;
}

.cards-dialog-head-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.dialog-close-btn {
  min-height: 38px;
}

.cards-search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
}

.cards-search-form input,
.cards-search-form button {
  min-height: 40px;
}

.cards-table-wrap {
  min-height: 0;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.cards-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

.cards-table th,
.cards-table td {
  height: 40px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
  line-height: 1.2;
  text-align: left;
}

.cards-table tbody tr:last-child td {
  border-bottom: 0;
}

.cards-table th:first-child,
.cards-table td:first-child {
  width: 40%;
}

.cards-table th:nth-child(2),
.cards-table td:nth-child(2) {
  width: 20%;
}

.cards-table th:nth-child(3),
.cards-table td:nth-child(3) {
  width: 28%;
}

.cards-table th:last-child,
.cards-table td:last-child {
  width: 12%;
}

.cards-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

.cards-table code {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.card-expiry {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.copy-card-btn {
  width: 52px;
  min-height: 28px;
  padding: 0 6px;
  font-size: 12px;
}

.card-status {
  display: inline-block;
  min-width: 76px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.card-status.unused {
  background: #e6f4ea;
  color: #276738;
}

.card-status.in-use {
  background: #fff4d8;
  color: var(--warning);
}

.card-status.used {
  background: #edf0f3;
  color: #5f6974;
}

.timeout-mark {
  display: inline-grid;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  border-radius: 50%;
  background: #f4c84a;
  color: #5f4300;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  vertical-align: middle;
  place-items: center;
}

.cards-empty {
  padding: 72px 20px;
  color: var(--muted);
  text-align: center;
}

.cards-pagination {
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.cards-pagination button {
  min-height: 38px;
}

.feedback-admin {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.feedback-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
}

.feedback-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

.feedback-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 14px;
}

.feedback-item-head span {
  color: var(--muted);
  white-space: nowrap;
}

.feedback-item p {
  margin-top: 10px;
  color: var(--ink);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.admin-balance {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-balance span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.admin-balance strong {
  grid-column: 1;
  font-size: 24px;
}

.admin-balance button {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.setting-row h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.setting-row p {
  color: var(--muted);
}

.switch {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 62px;
  height: 34px;
  margin: 0;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #9aa7b3;
  cursor: pointer;
  transition: background 0.18s ease;
}

.switch span::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(23, 32, 42, 0.22);
  transition: transform 0.18s ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::before {
  transform: translateX(28px);
}

.switch input:focus + span {
  box-shadow: 0 0 0 3px rgba(21, 111, 122, 0.14);
}

.confirm-dialog {
  width: min(420px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.confirm-dialog::backdrop {
  background: rgba(23, 32, 42, 0.48);
}

.confirm-dialog h3 {
  margin: 0 0 10px;
  font-size: 20px;
}

.confirm-dialog p {
  color: var(--muted);
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1080px);
    padding: 18px 0;
  }

  .login-panel {
    margin-top: 8vh;
    padding: 22px;
  }

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

  .input-row,
  .workspace,
  .button-grid,
  .admin-balance {
    grid-template-columns: 1fr;
  }

  .admin-balance button {
    grid-column: auto;
    grid-row: auto;
  }

  .phone-number {
    font-size: 30px;
  }

  .topbar,
  .top-actions,
  .setting-row,
  .admin-card-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .customer-topbar {
    grid-template-columns: 1fr;
  }

  .topbar-tip {
    width: 100%;
  }

  .admin-card-actions {
    flex-direction: column;
  }

  .cards-search-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .confirm-dialog.cards-dialog {
    width: calc(100vw - 20px);
    padding: 14px;
  }

  .cards-dialog-head {
    align-items: flex-start;
  }

  .cards-table-wrap {
    min-height: 0;
  }

  .section-heading,
  .sms-heading-actions,
  .sms-heading-title {
    align-items: stretch;
    flex-direction: column;
  }

  .control-surface {
    border-right: 0;
  }

  .sms-surface {
    grid-column: auto;
  }

  .feedback-item-head {
    flex-direction: column;
  }

  .feedback-item-head span {
    white-space: normal;
  }
}
