:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e2e4ea;
  --line-soft: #eef1f6;
  --text: #1a1d23;
  --text-soft: #6b7280;
  --text-faint: #b0b7c3;
  --brand: #2563eb;
  --brand-soft: #eff6ff;
  --brand-deep: #1e40af;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #b45309;
  --warning-soft: #fff7ed;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow: 0 18px 38px rgba(15, 23, 42, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "SF Pro Display", "Avenir Next", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

.app-body {
  min-height: 100vh;
  display: flex;
  overflow: auto;
}

.sidebar {
  width: 224px;
  min-width: 224px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--line);
}

.logo-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #60a5fa);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-caption {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 11px;
}

.nav {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
}

.nav-group-label {
  padding: 12px 18px 4px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-item {
  display: flex;
  align-items: center;
  margin: 2px 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 13.5px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: var(--surface-soft);
  color: #374151;
}

.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar.small {
  width: 32px;
  height: 32px;
}

.sidebar-user {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--text-faint);
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  overflow-y: auto;
  padding: 24px 28px 32px;
}

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

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-faint);
  font-size: 13px;
}

.breadcrumb .current {
  color: #374151;
  font-weight: 600;
}

.crumb-sep {
  color: #d1d5db;
}

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

.topbar-date {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--text-soft);
  font-size: 12px;
}

.content-shell {
  display: grid;
  gap: 18px;
}

.page-header,
.section-head,
.product-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-header {
  margin-bottom: 2px;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-header h1 {
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.page-subtitle {
  margin-top: 10px;
  max-width: 720px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.6;
}

.card-grid {
  display: grid;
  gap: 16px;
}

.metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.halves {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.metric-card {
  border-top: 3px solid transparent;
}

.metric-card span {
  display: block;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.06em;
  font-weight: 600;
}

.metric-card small {
  display: inline-block;
  margin-top: 10px;
  color: var(--text-soft);
  font-size: 12px;
}

.accent-blue {
  border-top-color: var(--brand);
}

.accent-green {
  border-top-color: #10b981;
}

.accent-violet {
  border-top-color: #7c3aed;
}

.accent-amber {
  border-top-color: #f59e0b;
}

.chip,
.success-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 11px;
  font-weight: 600;
}

.chip {
  background: var(--surface-soft);
  color: var(--text-soft);
}

.success-pill {
  background: var(--success-soft);
  color: var(--success);
}

.trend-list,
.stack {
  display: grid;
  gap: 14px;
}

.trend-row,
.status-line {
  display: grid;
  grid-template-columns: 56px 1fr 62px;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}

.trend-row span,
.status-line span {
  color: var(--text-soft);
}

.bars {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar,
.status-bar div {
  height: 10px;
  border-radius: 999px;
}

.bar.first {
  background: #60a5fa;
}

.bar.renew {
  background: var(--brand-deep);
}

.status-bar {
  height: 8px;
  background: #f3f4f6;
  border-radius: 999px;
  overflow: hidden;
}

.status-bar div {
  background: linear-gradient(90deg, var(--brand), #60a5fa);
}

.data-table,
table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
table th {
  padding: 0 0 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td,
table td {
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  color: #374151;
}

.data-table tr:last-child td,
table tr:last-child td {
  border-bottom: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 110px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: white;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.btn.ghost {
  min-width: auto;
  height: 34px;
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--line);
  padding: 0 12px;
}

.filters,
.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.full-row {
  grid-column: 1 / -1;
}

.hidden-panel {
  display: none !important;
}

.nested-form {
  margin-top: 16px;
}

.compact-head h2 {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.action-row {
  display: flex;
  justify-content: flex-end;
}

.channel-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  padding: 18px;
}

label {
  display: block;
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 6px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  box-sizing: border-box;
}

textarea {
  font: inherit;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input:disabled,
select:disabled {
  background: #f8fafc;
  color: #94a3b8;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge.issued {
  background: var(--success-soft);
  color: var(--success);
}

.badge.underwriting,
.badge.init {
  background: #eff6ff;
  color: var(--brand);
}

.badge.failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.detail-list {
  display: grid;
  gap: 12px;
}

.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.detail-list dt {
  color: var(--text-soft);
}

.detail-list dd {
  margin: 0;
  text-align: right;
  color: var(--text);
  font-weight: 500;
  max-width: 65%;
  word-break: break-word;
}

.simple-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-soft);
}

.flash-stack {
  display: grid;
  gap: 10px;
}

.flash {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  border: 1px solid transparent;
}

.flash.error {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: var(--danger);
}

.flash.success {
  background: var(--success-soft);
  border-color: #a7f3d0;
  color: var(--success);
}

.product-form {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  margin: 24px auto;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.22);
  padding: 22px;
}

.inset-card {
  background: var(--surface-soft);
  box-shadow: none;
}

.log-box {
  margin: 14px 0 0;
  padding: 16px;
  min-height: 360px;
  border-radius: 12px;
  background: #0f172a;
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.6;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.login-body {
  min-height: 100vh;
  display: flex;
  background: #eef2f7;
}

.login-shell {
  width: 100%;
  min-height: 100vh;
  display: flex;
  background: var(--surface);
}

.login-panel {
  padding: 48px 52px;
}

.form-panel {
  background: #fcfdff;
}

.form-panel .muted {
  color: var(--text-soft);
  margin-top: 10px;
  margin-bottom: 18px;
  font-size: 13px;
}

.login-visual {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 52px 56px;
  overflow: hidden;
}

.login-visual-photo,
.login-visual-overlay,
.login-visual-tint {
  position: absolute;
  inset: 0;
}

.login-visual-photo {
  background-image: url("/static/login-hero.svg");
  background-size: cover;
  background-position: center;
}

.login-visual-overlay {
  background: linear-gradient(
    to bottom,
    rgba(10, 20, 45, 0.2) 0%,
    rgba(10, 20, 45, 0.38) 42%,
    rgba(10, 20, 45, 0.82) 78%,
    rgba(10, 20, 45, 0.94) 100%
  );
}

.login-visual-tint {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12) 0%, transparent 60%);
}

.login-visual-content {
  position: relative;
  z-index: 1;
  max-width: 440px;
}

.login-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 5px 14px 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  font-weight: 500;
  backdrop-filter: blur(6px);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #60a5fa;
}

.login-visual h1 {
  color: white;
  font-size: 38px;
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.04em;
  margin: 0 0 16px;
}

.login-visual p {
  color: rgba(255, 255, 255, 0.62);
  font-size: 14.5px;
  line-height: 1.72;
}

.login-form-panel {
  width: 460px;
  min-width: 460px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
}

.login-form-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #2563eb 0%, #60a5fa 100%);
}

.logo-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 42px;
}

.logo-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-name {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  letter-spacing: -0.02em;
}

.logo-sub {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 1px;
}

.form-title {
  font-size: 22px;
  font-weight: 600;
  color: #111827;
  letter-spacing: -0.03em;
  margin: 0 0 4px;
}

.form-subtitle {
  font-size: 13.5px;
  color: #9ca3af;
  margin-bottom: 12px;
}

.login-form {
  gap: 0;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: #374151;
  font-size: 12.5px;
  font-weight: 500;
}

.input-wrap {
  position: relative;
}

.input-wrap input {
  height: 44px;
  padding: 0 14px 0 40px;
  margin-top: 0;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  color: #111827;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.input-wrap input::placeholder {
  color: #c4c9d4;
}

.input-wrap input:hover {
  border-color: #d1d5db;
  background: white;
}

.input-wrap input:focus {
  border-color: #2563eb;
  background: white;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #c4c9d4;
  pointer-events: none;
  display: flex;
}

.input-wrap.has-eye input {
  padding-right: 42px;
}

.eye-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  padding: 2px;
  border: 0;
  background: none;
  color: #c4c9d4;
  cursor: pointer;
  transition: color 0.15s ease;
}

.eye-btn:hover {
  color: #6b7280;
}

.form-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.cb-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6b7280;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.cb-label input[type="checkbox"] {
  display: none;
}

.custom-cb {
  width: 16px;
  height: 16px;
  border: 1.5px solid #d1d5db;
  border-radius: 4px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.12s ease;
}

.custom-cb svg {
  display: none;
}

.cb-label input:checked + .custom-cb {
  background: #2563eb;
  border-color: #2563eb;
}

.cb-label input:checked + .custom-cb svg {
  display: block;
}

.forgot {
  color: #2563eb;
  font-size: 13px;
  font-weight: 500;
}

.forgot:hover {
  color: #1d4ed8;
}

.btn.btn-primary {
  width: 100%;
  height: 44px;
  margin-bottom: 20px;
  border-radius: 8px;
  gap: 8px;
}

.register-row {
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
}

.register-row a {
  color: #2563eb;
  font-weight: 500;
}

.register-row a:hover {
  color: #1d4ed8;
}

.terms {
  margin-top: 32px;
  padding-top: 22px;
  border-top: 1px solid #f3f4f6;
  color: #c4c9d4;
  font-size: 11.5px;
  line-height: 1.65;
  text-align: center;
}

.terms a {
  color: #9ca3af;
}

.terms a:hover {
  color: #6b7280;
}

@media (max-width: 980px) {
  .metrics,
  .halves,
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-shell {
    min-height: auto;
    flex-direction: column;
  }

  .login-form-panel {
    width: 100%;
    min-width: 0;
  }

  .login-visual {
    min-height: 380px;
  }
}

@media (max-width: 900px) {
  .app-body {
    display: block;
  }

  .sidebar {
    position: static;
    width: auto;
    min-width: 0;
  }

  .main {
    padding: 18px 16px 24px;
  }

  .topbar,
  .page-header,
  .section-head,
  .product-head,
  .sidebar-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .trend-row,
  .status-line {
    grid-template-columns: 1fr;
  }
}
