:root {
  --font-family: "M PLUS 1", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  --page-padding: 24px;
  --section-gap: 12px;
  --header-gap: 12px;
  --header-actions-gap: 8px;
  --header-margin-bottom: 12px;
  --tabs-margin-bottom: 12px;
  --bg-accent-1: #dcebd8;
  --bg-accent-2: #f5decf;
  --bg-start: #f5f1e8;
  --bg-end: #f3f8ef;
  --surface: #fffdf8;
  --ink: #1f2b24;
  --muted: #6a766f;
  --brand: #1f6f5f;
  --brand-2: #c95f2d;
  --danger: #b7421b;
  --danger-soft: #fee2e2;
  --success: #1d7d4f;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #ffedd5;
  --ring: rgba(31, 111, 95, 0.25);
  --border-color: #d8ddd5;
  --shadow: 0 14px 34px rgba(22, 35, 29, 0.1);
  --status-banner-shell-bg: rgba(247, 250, 252, 0.92);
  --status-banner-shell-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --status-banner-active-start: rgba(220, 252, 231, 0.92);
  --status-banner-active-end: rgba(240, 253, 244, 0.96);
  --status-banner-active-border: rgba(34, 197, 94, 0.28);
  --status-banner-pending-start: rgba(255, 237, 213, 0.96);
  --status-banner-pending-end: rgba(255, 247, 237, 0.98);
  --status-banner-pending-border: rgba(249, 115, 22, 0.28);
  --status-banner-danger-start: rgba(254, 226, 226, 0.96);
  --status-banner-danger-end: rgba(254, 242, 242, 0.98);
  --status-banner-danger-border: rgba(239, 68, 68, 0.28);
  --status-banner-meta-fg: rgba(31, 43, 51, 0.72);
  --status-banner-meta-active-fg: rgba(22, 101, 52, 0.78);
  --status-banner-meta-pending-fg: rgba(146, 64, 14, 0.8);
  --status-banner-meta-danger-fg: rgba(185, 28, 28, 0.78);
}

body {
  margin: 0;
  padding: var(--page-padding);
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-family);
  background: radial-gradient(1200px 480px at 12% -5%, var(--bg-accent-1) 0, transparent 60%),
    radial-gradient(900px 500px at 100% 10%, var(--bg-accent-2) 0, transparent 65%),
    linear-gradient(160deg, var(--bg-start) 0%, var(--bg-end) 100%);
}

.app-header,
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--header-gap);
  margin-bottom: var(--header-margin-bottom);
  flex-wrap: nowrap;
  overflow: visible;
}

.app-header > :first-child,
.header > :first-child {
  flex: 0 0 auto;
  min-width: max-content;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--header-actions-gap);
  min-width: 0;
  flex: 0 1 auto;
  overflow: visible;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.06em;
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 4px 0;
  font-size: var(--h1-size, clamp(28px, 4vw, 40px));
  line-height: 1.1;
}

h2 {
  margin: 0 0 12px;
  font-size: var(--h2-size, 20px);
}

h3 {
  margin: 16px 0 10px;
  font-size: var(--h3-size, 15px);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--panel-border, var(--border-color));
  border-radius: 16px;
  padding: var(--panel-padding, 14px);
  box-shadow: var(--shadow);
}

.subtitle,
.sub {
  margin: 0;
  color: var(--muted);
  white-space: nowrap;
}

.identity,
.env-card {
  background: var(--surface);
  border: 1px solid var(--panel-border, var(--border-color));
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.identity > div,
.env-card > div,
.lang-switch {
  white-space: nowrap;
}

.identity strong,
.env-card strong,
.header-right > * {
  white-space: nowrap;
  flex: 0 0 auto;
}

.identity p,
.env-card p {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--avatar-bg, #0ea5a4);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.auth-panel {
  margin-bottom: 14px;
}

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

.auth-message {
  margin-top: 12px;
}

* {
  box-sizing: border-box;
}

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

input,
select,
textarea,
button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: none;
}

select {
  cursor: pointer;
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgba(31, 43, 36, 0.04);
}

input[type="radio"],
input[type="checkbox"] {
  appearance: auto;
}

button:hover,
button:active,
button:focus,
button:focus-visible,
.lang-btn:hover,
.lang-btn:active,
.lang-btn:focus,
.lang-btn:focus-visible,
.tab-btn:hover,
.tab-btn:active,
.tab-btn:focus,
.tab-btn:focus-visible {
  transition: none;
  transform: none;
}

input,
select,
textarea {
  border: 1px solid var(--control-border, var(--border-color));
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--control-bg, #fff);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--ring, rgba(15, 118, 110, 0.18));
  border-color: var(--brand);
}

.lang-switch {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--control-border, var(--border-color));
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow);
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.lang-btn.active {
  background: var(--brand);
  color: #fff;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  transition: none;
}

.btn:hover,
.btn:active,
.btn:focus,
.btn:focus-visible {
  transition: none;
  transform: none;
}

.btn.primary {
  background: var(--brand);
  color: #fff;
}

.btn.secondary {
  background: var(--btn-secondary-bg, #e8edf2);
  color: var(--btn-secondary-fg, #1f2b33);
}

.btn.danger,
.btn.row-danger {
  background: var(--danger);
  color: #fff;
}

.btn.success {
  background: var(--success, #1d7d4f);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--control-border, var(--border-color));
  color: var(--muted);
  padding: 7px 10px;
}

.btn.row {
  padding: 6px 8px;
  font-size: 11px;
  border-radius: 8px;
}

.btn.compact {
  padding: 7px 10px;
  font-size: 12px;
  border-radius: 9px;
}

.scope-select {
  width: auto;
  min-width: 118px;
  padding: 7px 30px 7px 10px;
  font-size: 12px;
}

.one-time-code-value {
  margin: 8px 0 0;
  padding: 18px 16px;
  border-radius: 16px;
  border: 1px solid rgba(201, 95, 45, 0.3);
  background: linear-gradient(135deg, rgba(255, 247, 237, 0.98), rgba(255, 237, 213, 0.95));
  color: #9a3412;
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.1;
  text-align: center;
}

.one-time-code-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.control-cluster {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: var(--tabs-margin-bottom);
}

.tab-btn {
  border: 1px solid var(--tab-border, var(--border-color));
  background: var(--tab-bg, #f0f4f7);
  color: var(--tab-fg, #24303a);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.tab-pane-stack.active {
  display: grid;
  gap: 12px;
}

.message {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--table-border, var(--border-color));
  border-radius: var(--table-radius, 12px);
  overflow: hidden;
}

.addon-feature-table {
  table-layout: fixed;
}

.addon-feature-table th:first-child,
.addon-feature-table td:first-child {
  width: 42%;
}

.addon-feature-table th:nth-child(2),
.addon-feature-table td:nth-child(2) {
  width: 12%;
}

.addon-feature-table th:nth-child(3),
.addon-feature-table td:nth-child(3),
.addon-feature-table th:nth-child(4),
.addon-feature-table td:nth-child(4) {
  width: 12%;
}

.addon-feature-table th:last-child,
.addon-feature-table td:last-child {
  width: 14%;
}

.addon-feature-table td:first-child {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.addon-feature-table td:first-child > div:first-child {
  font-weight: 700;
}

.device-activation-table {
  table-layout: fixed;
  width: 100%;
}

.device-activation-table th:first-child,
.device-activation-table td:first-child {
  width: 26%;
}

.device-activation-table th:nth-child(2),
.device-activation-table td:nth-child(2) {
  width: 24%;
}

.device-activation-table th:nth-child(3),
.device-activation-table td:nth-child(3) {
  width: 12%;
}

.device-activation-table th:nth-child(4),
.device-activation-table td:nth-child(4) {
  width: 20%;
}

.device-activation-table th:last-child,
.device-activation-table td:last-child {
  width: 18%;
}

.device-activation-table td:first-child,
.device-activation-table td:nth-child(2),
.device-activation-table td:nth-child(4),
.device-activation-table td:last-child {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.device-activation-table td:empty::before {
  content: "-";
  color: var(--muted);
}

.device-activation-table td {
  vertical-align: middle;
}

.device-label-cell {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  width: auto;
  max-width: 100%;
  min-width: 0;
  line-height: 1.2;
  vertical-align: middle;
}

.device-label-text {
  flex: 0 1 auto;
  display: inline;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.device-label-edit {
  flex: 0 0 auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: auto;
  min-width: 0;
  height: auto;
  padding: 4px 6px;
  line-height: 1;
  vertical-align: middle;
}

.device-label-edit svg {
  display: block;
}

.plan-card--loading {
  justify-content: center;
}

th,
td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid var(--table-border, var(--border-color));
  font-size: 12px;
  vertical-align: top;
}

th {
  background: var(--table-head-bg, #eff4f7);
  color: var(--table-head-fg, #3d4a54);
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.feature-row-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.feature-row-actions .btn {
  min-width: 0;
  white-space: nowrap;
}

.section-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.section-header-row h2,
.section-header-row h3 {
  margin-bottom: 0;
}

.cell-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.code-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f4efe4;
  border: 1px dashed var(--border-color);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.status-pill,
.status-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.status-pill.active,
.status-tag.active {
  background: var(--status-active-bg, #d9f4e6);
  color: var(--status-active-fg, #15603b);
}

.status-pill.pending_disable,
.status-pill.pending_add_canceled,
.status-tag.pending_disable {
  background: var(--status-pending-bg, #ffe8cf);
  color: var(--status-pending-fg, #94520f);
}

.status-tag.pending_add_canceled {
  background: var(--status-pending-bg, #ffe8cf);
  color: var(--status-pending-fg, #94520f);
}

.status-pill.disabled,
.status-pill.revoked,
.status-pill.inactive,
.status-tag.disabled,
.status-tag.revoked,
.status-tag.inactive {
  background: var(--status-danger-bg, #ffd8d1);
  color: var(--status-danger-fg, #8b2f1d);
}

.status-pill.canceled,
.status-pill.expired,
.status-tag.canceled,
.status-tag.expired {
  background: var(--status-neutral-bg, #e8edf1);
  color: var(--status-neutral-fg, #5c6770);
}

.badge.current {
  background: var(--status-active-bg, #d9f4e6);
  color: var(--status-active-fg, #15603b);
  border-radius: 999px;
  padding: 4px 8px;
  font-weight: 700;
  font-size: 12px;
}

.current-row {
  border-left: 4px solid var(--brand);
  background: linear-gradient(90deg, rgba(31, 111, 95, 0.03), transparent 60%);
}

.current-row td {
  font-weight: 700;
}

.result,
.result-box {
  margin-top: 10px;
  border: 1px dashed var(--result-border, #b8c3cc);
  border-radius: 10px;
  padding: 10px;
  background: var(--result-bg, #f8fbfd);
  font-size: 13px;
  color: var(--result-fg, #374957);
}

.result-box {
  margin: 12px 0 14px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--modal-overlay-bg, rgba(15, 23, 42, 0.45));
  z-index: var(--modal-z, 1200);
}

.modal-overlay[hidden],
.modal[hidden],
[hidden] {
  display: none !important;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--control-border, var(--border-color));
  border-radius: 16px;
  padding: 18px;
  width: var(--modal-width, 420px);
  max-width: calc(100% - 32px);
  box-shadow: var(--modal-shadow, 0 20px 40px rgba(2, 6, 23, 0.24));
}

.modal--compact {
  --modal-width: 420px;
}

.modal--wide {
  --modal-width: 520px;
}

.modal h3 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.25;
}

.modal-body {
  margin: 14px 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.modal-lead {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.modal-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.modal label,
.modal-label {
  display: grid;
  gap: 8px;
}

.modal label > span,
.modal-label > span {
  font-weight: 400;
}

.modal input:not([type="radio"]):not([type="checkbox"]),
.modal select,
.modal textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  font-weight: 400;
}

.modal input:not([type="radio"]):not([type="checkbox"])::placeholder,
.modal textarea::placeholder {
  font-weight: 400;
}

.modal-form {
  display: grid;
  gap: 12px;
}

.modal-form textarea {
  resize: vertical;
  min-height: var(--modal-textarea-min-height, 96px);
}

.modal-form textarea:focus,
.modal-form select:focus,
.modal-form input:focus {
  outline: 2px solid var(--ring);
  border-color: var(--brand);
}

.confirm-choice input {
  margin: 0;
  align-self: center;
  width: 16px;
  min-height: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.card {
  border: 1px solid var(--card-border, var(--border-color));
  border-radius: 12px;
  padding: 10px;
  background: var(--card-bg, #fbfdff);
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.card strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

@media (max-width: 760px) {
  .app-header,
  .header {
    flex-direction: column;
    overflow: visible;
  }

  .header-right {
    width: 100%;
    max-width: 100%;
    align-items: flex-start;
    overflow: visible;
  }

  .app-header > :first-child,
  .header > :first-child {
    min-width: 0;
  }

  .subtitle,
  .sub {
    white-space: normal;
  }

  .identity,
  .env-card,
  .lang-switch {
    width: max-content;
    max-width: none;
  }
}

.row-actions .btn.row:not(.danger):not(.success) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--btn-row-bg, #e8edf2);
  color: var(--btn-row-fg, #2d3b33);
  border: 1px solid var(--control-border, var(--border-color));
}

.row-actions .btn.row:hover {
  background: var(--btn-row-hover-bg, #e0e6e2);
}

.row-actions .btn.row:focus {
  outline: 2px solid var(--ring, rgba(15, 118, 110, 0.18));
  outline-offset: 2px;
}

.row-actions .btn.row svg {
  display: block;
  width: 14px;
  height: 14px;
}
