:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --brand: #0d9488;
  --brand-strong: #0f766e;
  --brand-soft: #ccfbf1;
  --accent: #4f46e5;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #059669;
  --ring: 0 0 0 3px rgba(13, 148, 136, 0.18);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, 0.28);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #111a2b;
    --surface-2: #16223a;
    --border: #24334d;
    --text: #e8eef8;
    --text-muted: #94a3b8;
    --brand: #2dd4bf;
    --brand-strong: #14b8a6;
    --brand-soft: #123b39;
    --accent: #818cf8;
    --danger: #f87171;
    --danger-soft: #3b1a1a;
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

#root { min-height: 100vh; }

/* ---------------------------------------------------------------- layout */

.auth-shell {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
}

.brand-panel {
  position: relative;
  overflow: hidden;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #ecfeff;
  background:
    radial-gradient(1100px 620px at 12% -8%, #2dd4bf22, transparent 60%),
    radial-gradient(900px 700px at 110% 110%, #4f46e544, transparent 55%),
    linear-gradient(155deg, #062a2b 0%, #0b3c4a 46%, #10243f 100%);
}

.brand-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(70% 60% at 40% 30%, #000 30%, transparent 100%);
  pointer-events: none;
}

.brand-panel > * { position: relative; z-index: 1; }

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-size: 18px;
}

.brand-mark .glyph {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(140deg, #2dd4bf, #0e7490);
  box-shadow: 0 8px 24px -8px #2dd4bf;
}

.brand-copy h1 {
  margin: 0 0 16px;
  font-size: clamp(30px, 3.1vw, 46px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 680;
}

.brand-copy p {
  margin: 0;
  max-width: 46ch;
  color: #b6d7dc;
  font-size: 17px;
}

.feature-list {
  list-style: none;
  margin: 34px 0 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.feature-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  color: #d6ecef;
  font-size: 15px;
}

.feature-list .tick {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(45, 212, 191, 0.16);
  color: #5eead4;
  font-size: 12px;
}

.brand-footnote {
  font-size: 13px;
  color: #8fb6bd;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ------------------------------------------------------------ auth panel */

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 460px;
}

.auth-card.wide { max-width: 660px; }

.auth-head h2 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -0.02em;
  font-weight: 640;
}

.auth-head p {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 15px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 26px;
}

.tabs button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 9px;
  font: inherit;
  font-weight: 560;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tabs button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 560;
  margin-bottom: 6px;
  color: var(--text);
}

.field .hint {
  font-weight: 400;
  color: var(--text-muted);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="tel"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field textarea { resize: vertical; min-height: 82px; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.field input[aria-invalid="true"],
.field select[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-error {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--danger);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

.password-wrap { position: relative; }

.password-wrap input { padding-right: 66px; }

.password-wrap button {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 560;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
}

.password-wrap button:hover { color: var(--brand-strong); }

.meter { display: flex; gap: 5px; margin-top: 8px; }

.meter span {
  height: 4px;
  flex: 1;
  border-radius: 3px;
  background: var(--border);
  transition: background 0.2s;
}

.meter span.on-1 { background: #f59e0b; }
.meter span.on-2 { background: #eab308; }
.meter span.on-3 { background: var(--ok); }

.chip-set {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 7px 13px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover { border-color: var(--brand); color: var(--text); }

.chip[aria-pressed="true"] {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-strong);
  font-weight: 560;
}

@media (prefers-color-scheme: dark) {
  .chip[aria-pressed="true"] { color: var(--brand); }
}

.btn {
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 22px -12px var(--brand);
  transition: transform 0.12s, filter 0.15s;
}

.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.62; cursor: not-allowed; }

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
  width: auto;
  padding: 9px 15px;
  font-size: 14px;
}

.btn.ghost:hover { border-color: var(--brand); color: var(--brand-strong); }

.alert {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
  font-size: 14px;
  margin-bottom: 18px;
}

.form-foot {
  margin-top: 18px;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}

.form-foot button {
  border: 0;
  background: none;
  color: var(--brand-strong);
  font: inherit;
  font-weight: 560;
  cursor: pointer;
  padding: 0;
}

@media (prefers-color-scheme: dark) {
  .form-foot button { color: var(--brand); }
}

.section-label {
  margin: 26px 0 14px;
  font-size: 11.5px;
  font-weight: 640;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.steps {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 22px;
  font-size: 13px;
  color: var(--text-muted);
}

.steps .dot {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
}

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

.steps .bar { flex: 1; height: 1px; background: var(--border); }

.row-actions { display: flex; gap: 10px; margin-top: 22px; }
.row-actions .btn { flex: 1; }

/* -------------------------------------------------------------- dashboard */

.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.app-bar .brand-mark { color: var(--text); font-size: 16px; }

.app-bar .glyph { width: 34px; height: 34px; }

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

.who .avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 640;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(140deg, var(--brand), var(--accent));
}

.who .meta { line-height: 1.25; }
.who .meta strong { font-size: 14px; font-weight: 600; }
.who .meta span { display: block; font-size: 12.5px; color: var(--text-muted); }

.page {
  max-width: 1160px;
  margin: 0 auto;
  padding: 34px 28px 70px;
}

.page-head { margin-bottom: 26px; }
.page-head h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.02em;
  font-weight: 660;
}
.page-head p { margin: 0; color: var(--text-muted); }

.tenant-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
  font-size: 12.5px;
  font-weight: 560;
  margin-bottom: 12px;
}

@media (prefers-color-scheme: dark) {
  .tenant-pill { color: var(--brand); }
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.stat .label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 560;
  letter-spacing: 0.02em;
}

.stat .value {
  font-size: 32px;
  font-weight: 680;
  letter-spacing: -0.02em;
  margin: 8px 0 2px;
}

.stat .sub { font-size: 12.5px; color: var(--text-muted); }

.split {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
  align-items: start;
}

.card h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.card .card-sub {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.detail-list { display: grid; gap: 0; }

.detail-list .row {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}

.detail-list .row:last-child { border-bottom: 0; }
.detail-list .row .k { color: var(--text-muted); }
.detail-list .row .v { font-weight: 520; overflow-wrap: anywhere; }
.detail-list .row .v.empty { color: var(--text-muted); font-weight: 400; font-style: italic; }

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

.tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 14px 0 8px;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width 0.5s ease;
}

.empty-state {
  text-align: center;
  padding: 26px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-state .icon { font-size: 26px; display: block; margin-bottom: 8px; }

.skeleton {
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    color-mix(in srgb, var(--surface-2) 60%, var(--border)) 50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  display: inline-block;
  vertical-align: -3px;
  margin-right: 8px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; }
  .brand-panel { padding: 40px 28px; gap: 28px; }
  .brand-panel .feature-list { display: none; }
  .auth-panel { padding: 34px 22px 60px; }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .grid-2 { grid-template-columns: 1fr; }
  .detail-list .row { grid-template-columns: 1fr; gap: 2px; }
  .app-bar { padding: 12px 16px; }
  .who .meta { display: none; }
  .page { padding: 24px 16px 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
