:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #dbe3ef;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #eaf2ff;
  --success: #16803c;
  --success-soft: #eaf8ef;
  --warning: #a15c00;
  --warning-soft: #fff7df;
  --danger: #b42318;
  --danger-soft: #fff0ef;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 32%),
    var(--bg);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 18px 16px calc(28px + var(--safe-bottom));
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(23px, 6vw, 32px); line-height: 1.08; }
h2 { margin-bottom: 5px; font-size: 21px; }
h3 { margin-bottom: 6px; font-size: 18px; }

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}

.icon-button:disabled { cursor: wait; opacity: 0.55; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  margin-bottom: 22px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: 11px;
  color: var(--text-muted);
  background: transparent;
  font-weight: 750;
  cursor: pointer;
}

.tab.is-active {
  color: var(--primary);
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.08);
}

.panel { display: none; }
.panel.is-active { display: block; }

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-heading p { margin-bottom: 0; color: var(--text-muted); font-size: 14px; }
.section-heading-with-action { align-items: center; }

.card-list { display: grid; gap: 14px; }

.card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-body { padding: 17px; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { margin-bottom: 3px; font-size: 19px; word-break: break-word; }
.card-subtitle { margin: 0; color: var(--text-muted); font-size: 13px; word-break: break-all; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-success { color: var(--success); background: var(--success-soft); }
.status-warning { color: var(--warning); background: var(--warning-soft); }
.status-danger { color: var(--danger); background: var(--danger-soft); }
.status-neutral { color: var(--text-muted); background: #eef2f7; }

.info-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.info-item {
  min-width: 0;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--surface-muted);
}
.info-item-full { grid-column: 1 / -1; }
.info-label { display: block; margin-bottom: 4px; color: var(--text-muted); font-size: 12px; }
.info-value { display: block; font-size: 14px; font-weight: 750; word-break: break-word; }

.quota-block { margin-top: 17px; padding-top: 16px; border-top: 1px solid var(--border); }
.quota-row + .quota-row { margin-top: 14px; }
.quota-topline { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; font-size: 13px; }
.quota-name { color: var(--text-muted); }
.quota-value { font-weight: 800; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: #e8edf5; }
.progress-bar { height: 100%; border-radius: inherit; background: var(--primary); transition: width 220ms ease; }
.quota-reset { margin: 6px 0 0; color: var(--text-muted); font-size: 12px; }

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  padding: 13px 17px 17px;
}

.button {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
}
.button-primary { color: #fff; border-color: var(--primary); background: var(--primary); }
.button-primary:hover { background: var(--primary-strong); }
.button-secondary { color: var(--primary); border-color: #bdd2f9; background: var(--primary-soft); }
.button-compact { min-height: 38px; padding: 8px 12px; font-size: 13px; }
.button-link { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.button:disabled { color: #8b98aa; border-color: #d7dee8; background: #eef2f6; cursor: not-allowed; }

.notice { padding: 12px 14px; margin-bottom: 14px; border-radius: 12px; color: var(--text); background: var(--warning-soft); font-size: 14px; }
.notice-error { color: var(--danger); background: var(--danger-soft); }
.is-hidden { display: none !important; }

.empty-state { padding: 30px 18px; border: 1px dashed var(--border); border-radius: var(--radius); text-align: center; background: rgba(255,255,255,0.55); }
.empty-state p { margin-bottom: 0; color: var(--text-muted); }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 15px; color: var(--primary); background: var(--primary-soft); font-weight: 900; }

.skeleton { overflow: hidden; position: relative; min-height: 170px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,0.82), transparent); animation: shimmer 1.2s infinite; }
.skeleton-line { height: 14px; margin: 15px 17px 0; border-radius: 8px; background: #e9eef5; }
.skeleton-line.short { width: 42%; }
.skeleton-line.medium { width: 67%; }
@keyframes shimmer { to { transform: translateX(100%); } }

.dialog-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px 14px calc(18px + var(--safe-bottom));
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(4px);
}

.dialog-card {
  width: min(100%, 520px);
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 25px 80px rgba(15,23,42,0.28);
}
.dialog-copy { color: var(--text-muted); line-height: 1.45; }
.dialog-actions { display: grid; gap: 9px; margin-top: 18px; }

.field { display: block; margin-top: 15px; }
.field > span { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 800; }
.field input, .field select { width: 100%; height: 46px; padding: 0 13px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: var(--surface); outline: none; }
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.field small { display: block; margin-top: 6px; color: var(--text-muted); }

.auth-code-card { padding: 16px; margin: 18px 0 12px; border: 1px solid var(--border); border-radius: 15px; text-align: center; background: var(--surface-muted); }
.auth-code-card span { display: block; color: var(--text-muted); font-size: 12px; }
.auth-code-card strong { display: block; margin: 8px 0 12px; font-size: 28px; letter-spacing: 0.12em; }

.progress-row { display: flex; align-items: center; gap: 10px; margin-top: 16px; color: var(--text-muted); font-size: 14px; }
.spinner { width: 18px; height: 18px; border: 2px solid #d4deec; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 420px) {
  .info-grid { grid-template-columns: 1fr; }
  .info-item-full { grid-column: auto; }
  .card-actions { grid-template-columns: 1fr; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #111b2d;
    --surface-muted: #162236;
    --text: #edf4ff;
    --text-muted: #98a8bd;
    --border: #263650;
    --primary: #69a2ff;
    --primary-strong: #4d8df6;
    --primary-soft: #162d50;
    --success: #64d889;
    --success-soft: #163724;
    --warning: #ffc768;
    --warning-soft: #3b2b13;
    --danger: #ff8b83;
    --danger-soft: #431e1c;
    --shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
  }
  .tabs { background: rgba(17,27,45,0.78); }
  .progress-track { background: #27354b; }
  .button:disabled { color: #75849a; border-color: #304058; background: #1a273a; }
  .skeleton-line { background: #223149; }
  .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent); }
}

.confirmation-copy { margin-top: 16px; color: var(--text); line-height: 1.5; }
.confirmation-copy p:last-child { margin-bottom: 0; }
