.panel {
  min-width: 0;
  border: 1px solid rgba(220, 221, 227, .88);
  border-radius: var(--radius-lg);
  padding: 22px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-sm);
}

.panel-header { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.panel-header h2 { margin: 0; }
.panel-header p:not(.eyebrow) { max-width: 650px; margin: 7px 0 0; color: var(--muted); font-size: .85rem; }
.panel-footer { display: flex; justify-content: flex-end; padding-top: 18px; border-top: 1px solid var(--line); margin-top: 22px; }

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 16px;
  font-size: .79rem;
  font-weight: 740;
  line-height: 1;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}

.button svg { width: 17px; height: 17px; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:disabled { opacity: .52; }
.button.primary { color: #fff; background: linear-gradient(135deg, #7967e3, var(--primary-strong)); box-shadow: 0 8px 20px rgba(88, 69, 194, .2); }
.button.primary:hover:not(:disabled) { box-shadow: 0 12px 26px rgba(88, 69, 194, .28); }
.button.secondary { border-color: var(--line-strong); color: var(--ink-soft); background: #fff; }
.button.secondary:hover:not(:disabled), .button.quiet:hover:not(:disabled) { border-color: #c7c3e8; color: var(--primary-strong); background: var(--primary-soft); }
.button.quiet { border-color: var(--line); color: var(--ink-soft); background: var(--surface-soft); }
.button.danger { color: #fff; background: var(--danger); }
.button.light { color: var(--sidebar); background: #fff; }
.button.small { min-height: 34px; border-radius: 10px; padding: 0 12px; font-size: .72rem; }
.large-button { width: 100%; min-height: 50px; font-size: .86rem; }
.button.is-busy::before { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; content: ""; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 0;
  border-radius: 11px;
  padding: 0;
  color: var(--ink-soft);
  background: transparent;
  transition: color .16s ease, background .16s ease;
}
.icon-button:hover { color: var(--primary); background: var(--primary-soft); }
.icon-button svg { width: 19px; height: 19px; }

.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.button-row.end { justify-content: flex-end; }
.text-link, .text-button { border: 0; padding: 0; color: var(--primary-strong); background: transparent; font-size: .76rem; font-weight: 750; }
.text-link:hover, .text-button:hover { text-decoration: underline; }
.danger-link { color: var(--danger); }

.field { display: grid; min-width: 0; align-content: start; align-self: start; gap: 7px; }
.field > span, .field legend { color: var(--ink-soft); font-size: .74rem; font-weight: 690; }
.field > small { color: var(--muted); font-size: .7rem; line-height: 1.45; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input, select { min-height: 43px; padding: 0 12px; }
input[type="checkbox"], input[type="radio"] { min-height: 0; padding: 0; }
textarea { min-height: 88px; resize: vertical; padding: 11px 12px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #aaacb5; }
input:hover, select:hover, textarea:hover { border-color: #c3c5ce; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 0; box-shadow: 0 0 0 3px rgba(115, 87, 232, .12); }
input[readonly] { color: var(--muted); background: var(--surface-soft); }
input[type="color"] { min-height: 43px; padding: 5px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 15px; }
.form-grid .span-2 { grid-column: span 2; }
.form-stack { display: grid; align-content: start; gap: 15px; }

.status-pill, .soft-pill {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: .66rem;
  font-weight: 760;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-align: center;
}
.soft-pill { color: var(--muted); background: var(--surface-soft); }
.status-pill.ready { color: #157a61; background: var(--mint-soft); }
.status-pill.attention { color: #8b6215; background: var(--amber-soft); }
.status-pill.blocked { color: #a32e3c; background: var(--danger-soft); }
.status-pill.unknown { color: #6f7180; background: #eceef2; }

.live-badge { display: inline-flex; min-height: 28px; align-items: center; gap: 8px; border-radius: 999px; padding: 0 11px; color: #217b65; background: var(--mint-soft); font-size: .69rem; font-weight: 760; }
.live-badge i { width: 7px; height: 7px; border-radius: 50%; background: #2cac89; box-shadow: 0 0 0 4px rgba(44, 172, 137, .11); }

.metric-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.metric-card { position: relative; display: grid; min-width: 0; min-height: 132px; flex: 1 1 170px; align-content: space-between; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); padding: 17px; background: var(--surface); box-shadow: var(--shadow-sm); }
.metric-card > * { min-width: 0; max-width: 100%; }
.metric-card::after { position: absolute; right: -22px; bottom: -28px; width: 92px; height: 92px; border-radius: 50%; opacity: .7; content: ""; }
.metric-card span { position: relative; z-index: 1; color: var(--muted); font-size: .72rem; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.metric-card strong { position: relative; z-index: 1; margin-top: 9px; font-size: clamp(1.45rem, 2.2vw, 2.2rem); line-height: 1.05; overflow-wrap: anywhere; text-wrap: balance; }
.metric-card small { position: relative; z-index: 1; color: var(--muted); font-size: .68rem; line-height: 1.4; overflow-wrap: anywhere; }
.metric-card.violet::after { background: var(--primary-soft); }
.metric-card.mint::after { background: var(--mint-soft); }
.metric-card.blue::after { background: var(--blue-soft); }
.metric-card.coral::after { background: var(--coral-soft); }
.metric-card.amber::after { background: var(--amber-soft); }

.toast-region { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: grid; gap: 8px; width: min(360px, calc(100vw - 28px)); pointer-events: none; }
.toast { transform: translateY(10px); border: 1px solid rgba(255, 255, 255, .1); border-radius: 13px; padding: 13px 15px; opacity: 0; color: #fff; background: #1b1d27; box-shadow: var(--shadow); font-size: .78rem; font-weight: 650; transition: opacity .2s ease, transform .2s ease; }
.toast.visible { transform: translateY(0); opacity: 1; }
.toast.error { background: #8f2633; }

.app-dialog { position: fixed; inset: 0; width: min(1120px, calc(100vw - 28px)); max-width: calc(100vw - 28px); max-height: calc(100vh - 28px); max-height: calc(100dvh - 28px); overflow: visible; border: 0; border-radius: var(--radius-lg); padding: 0; margin: auto; color: var(--ink); background: transparent; box-shadow: none; }
.app-dialog::backdrop { background: rgba(13, 14, 20, .62); backdrop-filter: blur(6px); }
.dialog-shell { display: grid; width: 100%; max-height: calc(100vh - 28px); max-height: calc(100dvh - 28px); grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; border-radius: inherit; margin: 0 auto; background: var(--surface); box-shadow: var(--shadow); }
.dialog-shell.narrow { width: min(520px, 100%); }
.app-dialog:has(.dialog-shell.narrow) { width: min(520px, calc(100vw - 28px)); }
.app-dialog:has(.csv-import-dialog) { width: min(760px, calc(100vw - 28px)); }
.app-dialog:has(.photo-import-dialog) { width: min(920px, calc(100vw - 28px)); }
.app-dialog:has(.source-connect-dialog) { width: min(640px, calc(100vw - 28px)); }
.app-dialog:has(.batch-review-dialog) { width: min(1180px, calc(100vw - 40px)); }
.dialog-header { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 1.22rem; }
.dialog-close { font-size: 1.4rem; }
.dialog-body { min-height: 0; overflow-y: auto; padding: 22px; }
.dialog-body > p { color: var(--muted); font-size: .85rem; }
.dialog-footer { display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 16px 22px; border-top: 1px solid var(--line); background: #fbfbfc; }
.confirm-dialog { width: min(460px, calc(100vw - 28px)); }
.compact-dialog { display: grid; justify-items: center; max-width: 460px; margin: auto; padding: 34px; text-align: center; }
.compact-dialog h2 { margin: 5px 0 0; font-size: 1.25rem; }
.compact-dialog p { margin: 0 0 12px; }
.danger-mark { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 15px; color: var(--danger); background: var(--danger-soft); font-size: 1.2rem; font-weight: 850; }

.auth-panel { position: fixed; z-index: 300; inset: 0; display: grid; grid-template-columns: minmax(420px, .92fr) minmax(440px, 1.08fr); min-height: 100dvh; color: var(--ink); background: var(--surface); pointer-events: auto; user-select: auto; }
.auth-panel[hidden] { display: none; }
.auth-visual { position: relative; display: grid; overflow: hidden; align-items: end; padding: clamp(40px, 6vw, 86px); color: #fff; background: linear-gradient(145deg, #161720 0%, #27233c 55%, #40348b 100%); }
.auth-visual::before { position: absolute; inset: 0; opacity: .08; background-image: linear-gradient(rgba(255,255,255,.6) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.6) 1px, transparent 1px); background-size: 46px 46px; content: ""; mask-image: linear-gradient(to bottom, transparent, #000); }
.auth-orb { position: absolute; border-radius: 50%; filter: blur(2px); }
.auth-orb-one { top: 13%; left: 12%; width: 220px; height: 220px; background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.3), rgba(123,102,230,.1)); box-shadow: 0 0 100px rgba(119, 96, 230, .4); }
.auth-orb-two { right: -80px; bottom: 18%; width: 300px; height: 300px; background: radial-gradient(circle at 30% 30%, rgba(61,202,164,.22), transparent 66%); }
.auth-visual-copy { position: relative; z-index: 1; max-width: 500px; }
.auth-visual-copy p { margin: 28px 0 8px; color: #a99bf5; font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.auth-visual-copy h2 { max-width: 450px; margin: 0 0 18px; font-size: clamp(2.3rem, 4.5vw, 4.8rem); line-height: .98; letter-spacing: -.055em; }
.auth-visual-copy > span:last-child { display: block; max-width: 440px; color: rgba(255,255,255,.62); font-size: .95rem; line-height: 1.65; }
.auth-content { display: grid; overflow-y: auto; place-items: center; padding: 34px; }
.auth-card { width: min(430px, 100%); }
.auth-panel[data-auth-mode="register"] .auth-card { width: min(620px, 100%); padding-block: 28px; }
.auth-heading { margin-bottom: 28px; }
.auth-heading h1 { margin: 0 0 8px; font-size: 2rem; }
.auth-heading > p:not(.eyebrow) { color: var(--muted); }
.auth-form { display: grid; gap: 16px; }
.auth-switch { margin: 20px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.55; text-align: center; }
.auth-switch a { color: var(--blue); font-weight: 750; text-decoration: underline; text-decoration-color: rgba(57, 126, 209, .38); text-decoration-thickness: 1px; text-underline-offset: 3px; transition: color 350ms ease, text-decoration-color 350ms ease; }
.auth-switch a:hover, .auth-switch a:focus-visible { color: #245fa7; text-decoration-color: currentColor; }
.auth-inline-link { justify-self: end; margin-top: -6px; color: var(--blue); font-size: .76rem; font-weight: 750; text-decoration: none; }
.auth-inline-link:hover, .auth-inline-link:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
.account-recovery-fallback { display: grid; gap: 14px; }
.account-recovery-fallback[hidden] { display: none; }
.account-recovery-fallback p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.6; }
.consent-check { display: grid; width: fit-content; max-width: 100%; grid-template-columns: 17px minmax(0, 1fr); gap: 10px; align-items: start; color: var(--muted); font-size: .75rem; line-height: 1.45; cursor: pointer; }
.consent-check input { width: 17px; height: 17px; min-height: 17px; margin: 2px 0 0; padding: 0; align-self: start; accent-color: var(--primary); }
.consent-check > span { min-width: 0; }
.consent-check a { color: var(--blue); font-weight: 750; }
.registration-trial-note { margin: 0; border-left: 3px solid var(--primary); padding: 10px 13px; color: var(--ink-soft); background: var(--primary-soft); font-size: .74rem; line-height: 1.5; }
.registration-support { margin: -2px 0 0; color: var(--muted); font-size: .74rem; line-height: 1.45; }
.registration-support a { color: var(--primary-strong); font-weight: 800; text-decoration: none; }
.registration-support a:hover { text-decoration: underline; }
.auth-note { margin: 20px 0 0; color: var(--muted); font-size: .71rem; text-align: center; }
.mobile-auth-brand { display: none; margin-bottom: 24px; }

@media (min-width: 980px) {
  .auth-panel[data-auth-mode="register"] .consent-check > span { white-space: nowrap; }
}

.switch-field { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 14px 0; }
.switch-field > span { display: grid; }
.switch-field small { color: var(--muted); font-size: .72rem; }
.switch-field input, .availability-control input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-field i { position: relative; width: 42px; height: 24px; flex: 0 0 42px; border-radius: 999px; background: #d9dbe2; transition: background .18s ease; }
.switch-field i::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.14); transition: transform .18s ease; content: ""; }
.switch-field input:checked + i { background: var(--mint); }
.switch-field input:checked + i::after { transform: translateX(18px); }

.key-value-list, .integration-list { display: grid; gap: 0; }
.key-value-row, .integration-row { display: flex; min-width: 0; justify-content: space-between; gap: 18px; align-items: center; min-height: 54px; border-bottom: 1px solid var(--line); }
.key-value-row:last-child, .integration-row:last-child { border-bottom: 0; }
.key-value-row span { min-width: 0; color: var(--muted); font-size: .76rem; overflow-wrap: anywhere; }
.key-value-row strong { min-width: 0; font-size: .78rem; overflow-wrap: anywhere; text-align: right; }
.integration-row > span { display: grid; min-width: 0; }
.integration-row small { color: var(--muted); font-size: .69rem; }

@media (max-width: 720px) {
  .panel { border-radius: 18px; padding: 17px; }
  .panel-header { margin-bottom: 14px; }
  .metric-grid { gap: 10px; }
  .metric-card { flex-basis: 160px; }
  .metric-card { min-height: 116px; padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .app-dialog { width: min(520px, calc(100vw - 20px)); max-width: calc(100vw - 20px); max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); margin: auto; border-radius: 20px; }
  .app-dialog.item-dialog,
  .app-dialog:has(.photo-import-dialog),
  .app-dialog:has(.batch-review-dialog) { width: calc(100vw - 20px); }
  .dialog-shell { max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); min-height: 0; border-radius: inherit; }
  .confirm-dialog { width: min(420px, calc(100vw - 24px)); margin: auto; border-radius: 20px; }
  .confirm-dialog .dialog-shell { min-height: 0; border-radius: 20px; }
  .dialog-header { padding: 16px; }
  .dialog-body { padding: 16px; }
  .dialog-footer { position: sticky; bottom: 0; padding: 13px 16px max(13px, env(safe-area-inset-bottom)); }
  .auth-panel { display: block; overflow-y: auto; background: linear-gradient(180deg, #f2f0ff, #fff 36%); }
  .auth-visual { display: none; }
  .auth-content { min-height: 100dvh; padding: 30px 20px; }
  .auth-card { padding: 26px 20px; border: 1px solid rgba(255,255,255,.9); border-radius: 24px; background: rgba(255,255,255,.88); box-shadow: var(--shadow); }
  .mobile-auth-brand { display: inline-grid; }
  .toast-region { right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); }
}

@media (max-width: 430px) {
  .metric-card { flex-basis: 100%; }
  .metric-card strong { font-size: 1.55rem; }
  .dialog-footer { align-items: stretch; }
  .dialog-footer > .button-row { display: grid; grid-template-columns: 1fr 1.2fr; flex: 1; }
}
