:root {
  --gray-200: #f6f8fa; --gray-300: #e2e8f0; --gray-500: #94a3b8;
  --gray-600: #64748b; --gray-800: #334155; --gray-900: #0f172a; --gray-1000: #030407;
  --brand: #0d6efd; --brand-dark: #1e4ec4;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--gray-200);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--gray-900);
}
header.tursio-header {
  display: flex; align-items: center; gap: 8px;
  height: 64px; padding: 0 24px;
  background: #ffffff; border-bottom: 1px solid var(--gray-300);
}
header.app-header {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; padding: 0 32px;
  background: #ffffff; border-bottom: 1px solid var(--gray-300);
}
.app-header-brand { display: flex; align-items: center; gap: 12px; }
.app-header-mark svg { display: block; height: 26px; width: auto; }
.app-header-title { font-size: 18px; font-weight: 500; color: var(--gray-600); }
.app-header-logout { width: auto; margin: 0; padding: 8px 16px; }

main.page {
  max-width: 480px; margin: 64px auto; padding: 0 24px;
}
main.page.wide {
  max-width: 1080px; margin: 40px auto 64px; display: flex; flex-direction: column; gap: 24px;
}
.page-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
h1.page-title { font-size: 22px; font-weight: 600; margin: 0; color: var(--gray-1000); }
.page-subtitle { font-size: 14px; color: var(--gray-600); margin: 0; }
h2.section-title { font-size: 16px; font-weight: 600; margin: 40px 0 12px; color: var(--gray-1000); }
.card {
  background: #ffffff; border: 1px solid var(--gray-300); border-radius: 12px;
  padding: 32px; box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.card-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.card-title { font-size: 16px; font-weight: 600; color: var(--gray-1000); margin: 0; white-space: nowrap; }
.card-title-optional { font-size: 13px; font-weight: 400; color: var(--gray-600); white-space: nowrap; }
.step-badge {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.card-head .count-badge, .card-head button.card-action-btn { margin-left: auto; flex-shrink: 0; }
.count-badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 999px; background: var(--gray-200); color: var(--gray-800);
  font-size: 12px; font-weight: 600;
}
label { display: block; font-size: 14px; font-weight: 500; color: var(--gray-1000); margin-bottom: 8px; }
.hint-icon {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 4px; vertical-align: middle;
  cursor: pointer; user-select: none;
}
.hint-icon img { display: block; }
.hint-icon::after {
  content: attr(data-hint);
  position: absolute; bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 260px; padding: 8px 10px;
  background: #fff; color: var(--gray-800); font-size: 12px; font-weight: 400;
  line-height: 1.45; border-radius: 6px; text-align: left; white-space: normal;
  border: 1px solid var(--gray-300); box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
  opacity: 0; visibility: hidden; transition: opacity 120ms ease;
  pointer-events: none; z-index: 10;
}
.hint-icon::before {
  content: ""; position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 5px solid var(--gray-300);
  opacity: 0; visibility: hidden; transition: opacity 120ms ease; z-index: 11;
}
.hint-icon:hover::after, .hint-icon:focus::after,
.hint-icon:hover::before, .hint-icon:focus::before { opacity: 1; visibility: visible; }
input[type="text"], input[type="password"], input[type="number"], input[type="email"], select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--gray-300); border-radius: 8px; font-size: 14px;
  color: var(--gray-900); background: #fff;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1.5 2l4.5 4 4.5-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 10px 7px;
  padding-right: 32px; cursor: pointer;
}
input:focus, select:focus { outline: none; border-color: var(--brand); }

.field-group { display: flex; flex-direction: column; }
.field-group label { margin-bottom: 8px; }

.field-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); column-gap: 20px; row-gap: 20px;
}
.field-grid.field-grid-3 { grid-template-columns: repeat(3, 1fr); }
.field-grid .field-group.span-2 { grid-column: 1 / -1; }
@media (max-width: 760px) {
  .field-grid.field-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .field-grid { grid-template-columns: 1fr; }
}

.form-block { display: flex; flex-direction: column; gap: 20px; margin-bottom: 24px; }

.subsection-hint { font-size: 13px; color: var(--gray-600); margin: 0 0 20px; }

button[type="submit"] {
  width: 100%; padding: 11px; border: none; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background 150ms ease;
}
button[type="submit"]:hover { background: var(--brand-dark); }
button.card-action-btn {
  width: auto; flex: 0 0 auto; padding: 8px 16px;
  font-size: 13px; white-space: nowrap;
}
.secondary-btn {
  width: 100%; padding: 10px; margin-top: 12px; border: 1px solid var(--gray-300);
  border-radius: 8px; background: none; color: var(--gray-800); font-size: 13px;
  font-weight: 600; cursor: pointer;
}
.secondary-btn:hover { background: var(--gray-200); }
textarea {
  width: 100%; margin-top: 8px; padding: 10px 12px; border: 1px solid var(--gray-300);
  border-radius: 8px; font-size: 12px; color: var(--gray-900); font-family: monospace;
  resize: vertical;
}
.result-label { font-size: 13px; font-weight: 600; color: var(--gray-800); margin: 24px 0 0; }
.result-error { color: #b91c1c; }
.result-success { color: #15803d; }

.toast-viewport {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 1000; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 18px; border-radius: 10px;
  background: #ffffff; color: var(--gray-900);
  font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  animation: toast-in 0.2s ease-out;
}
.toast-icon { flex-shrink: 0; width: 18px; height: 18px; }
.toast-success .toast-icon { color: #15803d; }
.toast-error .toast-icon { color: #b91c1c; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-action-btn:disabled { cursor: not-allowed; opacity: 0.65; }

.toggle-row { display: flex; align-items: center; gap: 8px; }
.toggle-label { font-size: 13px; font-weight: 600; color: var(--gray-800); white-space: nowrap; }
.toggle-switch {
  position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; background: var(--gray-300); border-radius: 999px;
  cursor: pointer; transition: background 150ms ease;
}
.toggle-track::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: transform 150ms ease;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
}
.toggle-switch input:checked + .toggle-track { background: var(--brand); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(16px); }

.sync-banner {
  display: none; align-items: center; gap: 10px; padding: 12px 14px;
  border-radius: 8px; font-size: 13px; margin-bottom: 20px;
  background: var(--gray-200); color: var(--gray-800); border: 1px solid var(--gray-300);
}
.sync-banner.visible { display: flex; }
.sync-banner.banner-match { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.sync-banner.banner-nomatch { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.sync-banner-icon { flex-shrink: 0; width: 16px; height: 16px; }
.btn-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid transparent; border-top: 2px solid currentColor;
  border-radius: 50%; animation: btn-spin 1s linear infinite;
  vertical-align: middle;
}
@keyframes btn-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.license-list {
  display: flex; flex-direction: column; gap: 1px;
  background: var(--gray-300); border: 1px solid var(--gray-300);
  border-radius: 12px; overflow: hidden; overflow-x: auto;
}
.license-row {
  display: flex; gap: 24px; padding: 14px 20px; background: #fff;
  align-items: flex-start;
}
.license-cell { min-width: 110px; }
.license-cell.license-customer { min-width: 160px; }
.license-cell.license-notes { min-width: 140px; flex: 1; }
.license-cell.license-key { min-width: 200px; max-width: 260px; }
.license-cell-label {
  font-size: 11px; font-weight: 600; color: var(--gray-600);
  text-transform: uppercase; letter-spacing: 0.03em; margin: 0 0 4px;
}
.license-cell-value { font-size: 13px; color: var(--gray-900); margin: 0; }
.license-empty { color: var(--gray-600); font-size: 13px; justify-content: center; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.badge.active { background: #dcfce7; color: #166534; }
.badge.expired { background: #fee2e2; color: #991b1b; }
.badge.used { background: var(--gray-200); color: var(--gray-600); }
.license-key-cell {
  font-family: monospace; font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
