:root {
  --bg: #f3f7fc;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --text: #102033;
  --muted: #66758b;
  --line: #dfe8f3;
  --blue: #005bff;
  --blue-2: #004bd6;
  --cyan: #17b6d9;
  --green: #10b981;
  --orange: #f59e0b;
  --red: #ef4444;
  --purple: #7c3aed;
  --shadow: 0 16px 38px rgba(20, 44, 83, .08);
  --shadow-soft: 0 8px 22px rgba(20, 44, 83, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(0, 91, 255, .11), transparent 30%),
    radial-gradient(circle at 92% 2%, rgba(23, 182, 217, .10), transparent 24%),
    linear-gradient(180deg, #f9fbff 0%, var(--bg) 100%);
}
.hidden { display: none !important; }
.muted, .hint, small { color: var(--muted); }
.hint, small { font-size: 12px; }

button, input, select, textarea {
  font: inherit;
  letter-spacing: 0;
}
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  color: var(--text);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.65; }
input:focus, select:focus, textarea:focus {
  border-color: rgba(0, 91, 255, .55);
  box-shadow: 0 0 0 4px rgba(0, 91, 255, .10);
}
button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid #d7e2f0;
  border-radius: 12px;
  background: #fff;
  color: #21405f;
  cursor: pointer;
  font-weight: 760;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
button:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); border-color: #bdd1ea; }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #2878ff);
  box-shadow: 0 12px 24px rgba(0, 91, 255, .22);
}
.primary:hover { background: linear-gradient(135deg, var(--blue-2), #1f70ff); }
.danger-btn { color: #be123c !important; background: #fff1f2 !important; border-color: #fecdd3 !important; }
.full { width: 100%; }

.toast {
  position: fixed;
  left: 50%;
  top: 22px;
  z-index: 100;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 24px));
  padding: 12px 16px;
  border: 1px solid #cfe0ff;
  border-radius: 14px;
  background: rgba(255, 255, 255, .96);
  color: #173352;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .16);
  backdrop-filter: blur(14px);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}
.auth-shell {
  width: min(1180px, 94vw);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 430px);
  gap: 22px;
}
.auth-hero, .auth-card {
  border: 1px solid rgba(214, 226, 240, .85);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.auth-hero {
  min-height: 600px;
  position: relative;
  overflow: hidden;
  padding: 30px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(4, 25, 70, .98), rgba(0, 91, 255, .86)),
    #0f2c62;
}
.auth-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, #000, transparent 85%);
}
.hero-nav, .hero-copy, .hero-metrics, .feature-strip { position: relative; z-index: 1; }
.hero-nav { display: flex; align-items: center; gap: 12px; }
.brand-icon,
.auth-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0, 24, 80, .18);
}
.auth-logo {
  width: 54px;
  height: 54px;
  margin-bottom: 12px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #fff;
  color: var(--blue);
  font-weight: 950;
  box-shadow: 0 12px 24px rgba(0, 34, 92, .16);
}
.hero-nav em {
  margin-left: auto;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  font-style: normal;
  font-size: 12px;
  color: rgba(255,255,255,.76);
}
.hero-copy { max-width: 650px; margin-top: 82px; }
.eyebrow { display: inline-flex; color: #aee8ff; font-weight: 900; font-size: 12px; text-transform: uppercase; }
.hero-copy h1 { margin: 14px 0; font-size: clamp(34px, 4vw, 58px); line-height: 1.05; letter-spacing: 0; }
.hero-copy p { max-width: 560px; margin: 0; color: rgba(255,255,255,.78); line-height: 1.85; }
.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 44px;
  max-width: 610px;
}
.hero-metrics div, .feature-strip {
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.10);
  backdrop-filter: blur(12px);
  border-radius: 16px;
}
.hero-metrics div { padding: 18px; }
.hero-metrics span, .hero-metrics b { display: block; }
.hero-metrics span { color: rgba(255,255,255,.70); font-size: 12px; }
.hero-metrics b { margin-top: 8px; font-size: 19px; }
.feature-strip {
  position: absolute;
  left: 30px;
  right: 30px;
  bottom: 30px;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px;
}
.feature-strip span { padding: 8px 10px; border-radius: 999px; background: rgba(255,255,255,.12); color: rgba(255,255,255,.82); font-size: 12px; }
.auth-card {
  align-self: center;
  padding: 30px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(18px);
}
.auth-card-head h2 { margin: 10px 0 6px; font-size: 28px; }
.auth-card-head p { margin: 0; color: var(--muted); line-height: 1.6; }
.auth-badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eaf2ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}
.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 22px 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f1f6fc;
}
.auth-tabs button { min-height: 38px; border: 0; background: transparent; box-shadow: none; }
.auth-tabs button.active { color: var(--blue); background: #fff; box-shadow: 0 8px 18px rgba(20, 44, 83, .08); }
.form-stack { display: grid; gap: 14px; }
.form-stack label, .form-card label { display: grid; gap: 7px; color: #314964; font-size: 13px; font-weight: 760; }
.inline-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.check-line { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 8px; color: var(--muted); }
.check-line input { width: auto; min-height: 0; }
.auth-helper-row, .auth-safe-note { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth-helper-row button { padding: 0; min-height: 32px; border: 0; color: var(--blue); background: transparent; box-shadow: none; }
.auth-safe-note { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

.app { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 22px 16px;
  border-right: 1px solid #dce7f4;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; }
.brand b, .brand small { display: block; }
.brand b { font-size: 18px; }
.brand small { color: var(--muted); margin-top: 2px; }
.user { margin: 6px 8px 16px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); color: #35506c; }
nav { display: grid; gap: 5px; }
.nav {
  justify-content: flex-start;
  width: 100%;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: #49637d;
  box-shadow: none;
}
.nav:hover { background: #eef5ff; box-shadow: none; }
.nav.active {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #2878ff);
  box-shadow: 0 12px 22px rgba(0, 91, 255, .18);
}
.nav-child { margin-left: 18px; width: calc(100% - 18px); min-height: 36px; font-size: 13px; color: #607790; }
.logout-nav { margin-top: 10px; color: #be123c; }

.main { min-width: 0; padding: 18px 22px 34px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 18px;
  background: linear-gradient(180deg, rgba(243,247,252,.96), rgba(243,247,252,.82));
  backdrop-filter: blur(12px);
}
.topbar h1 { margin: 0; font-size: 25px; }
.topbar p { margin: 4px 0 0; }
.topbar-title-row { display: flex; align-items: center; gap: 10px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn, .mobile-menu-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 14px;
}
.mobile-menu-btn { display: none; }
.notif-count {
  position: absolute;
  transform: translate(12px, -12px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
}
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 176px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.avatar-dot { width: 30px; height: 30px; border-radius: 999px; background: linear-gradient(135deg, var(--blue), var(--cyan)); }
.user-chip b, .user-chip small { display: block; }

.page { display: none; }
.page.active { display: block; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-hero, .card, .stat, .setting-tile, .ai-tool-card {
  border: 1px solid rgba(217, 229, 243, .92);
  border-radius: var(--radius);
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow-soft);
}
.page-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  min-height: 176px;
  padding: 28px;
  margin-bottom: 18px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(0,91,255,.09), rgba(23,182,217,.04)),
    rgba(255,255,255,.94);
}
.page-hero h2 { margin: 8px 0; font-size: clamp(28px, 3vw, 42px); letter-spacing: 0; }
.page-hero p { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.7; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.secondary-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat {
  min-height: 126px;
  position: relative;
  padding: 18px;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 18px;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(0,91,255,.16), rgba(23,182,217,.16));
}
.stat span, .stat b, .stat em { position: relative; z-index: 1; display: block; }
.stat span { color: var(--muted); font-size: 13px; font-weight: 760; }
.stat b { margin-top: 16px; font-size: 30px; line-height: 1; }
.stat em { margin-top: 10px; color: #7a8da3; font-style: normal; font-size: 12px; }
.stat.mini { min-height: 94px; }
.stat.mini b { font-size: 24px; }
.card { padding: 20px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 18px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h3, .section-head p { margin: 0; }
.dashboard-layout, .ai-workbench { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, .9fr); gap: 16px; }
.form-grid, .grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.search-filter-bar { display: grid; grid-template-columns: minmax(220px, 1fr) repeat(4, auto); gap: 10px; align-items: center; margin-bottom: 14px; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th { text-align: left; padding: 13px 14px; background: #f5f8fd; color: #607790; font-size: 12px; }
td { padding: 14px; border-top: 1px solid #edf2f7; color: #253b53; vertical-align: middle; }
tbody tr:hover { background: #f9fcff; }
.table-thumb, .thumb-placeholder { width: 46px; height: 46px; border-radius: 12px; object-fit: cover; display: inline-grid; place-items: center; background: #eef5ff; color: var(--blue); border: 1px solid #dbe8fb; }

.badge, .ok, .danger, .status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid #cfe0ff;
  background: #eef5ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
}
.ok, .status-pill.green { background: #ecfdf5; color: #047857; border-color: #bbf7d0; }
.danger { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.status-pill.blue { color: var(--blue); background: #eef5ff; }
.status-pill.purple { color: var(--purple); background: #f5f0ff; border-color: #ddd6fe; }

.trend-chart, .donut-wrap { min-height: 280px; }
.chart-grid { position: relative; height: 260px; border-radius: 14px; background: linear-gradient(180deg, #f9fbff, #f4f8fd); overflow: hidden; }
.chart-grid svg { width: 100%; height: 100%; }
.chart-grid polyline { fill: none; stroke: var(--blue); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.chart-point { position: absolute; width: 11px; height: 11px; border-radius: 999px; background: var(--blue); box-shadow: 0 0 0 5px rgba(0,91,255,.12); }
.chart-labels { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 12px; }
.donut-card { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: center; min-height: 250px; }
.donut-ring { width: 176px; height: 176px; border-radius: 999px; background: radial-gradient(circle at center, #fff 0 43%, transparent 44%), conic-gradient(var(--blue) 0 38%, var(--green) 38% 62%, var(--orange) 62% 78%, var(--purple) 78% 92%, var(--red) 92% 100%); border: 1px solid var(--line); }
.donut-list, .status-grid, .reminder-list, .quick-entry-grid, .audit-log-list, .history-list { display: grid; gap: 10px; }
.donut-list span, .rank-row, .audit-log-item, .reminder-item, .quick-entry, .status-grid div {
  padding: 12px;
  border: 1px solid #e6eef8;
  border-radius: 14px;
  background: #f8fbff;
}
.quick-entry-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.quick-entry { min-height: 104px; align-content: start; justify-content: start; text-align: left; }
.quick-entry span { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; background: #eaf2ff; color: var(--blue); font-weight: 900; }
.quick-entry b, .quick-entry small { display: block; margin-top: 8px; }
.reminder-item { width: 100%; display: grid; grid-template-columns: 36px 1fr auto; min-height: 72px; text-align: left; }
.reminder-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; background: #eaf2ff; color: var(--blue); }
.ai-tool-grid, .settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.ai-tool-card, .setting-tile { min-height: 140px; padding: 18px; display: grid; justify-items: start; align-content: start; text-align: left; }
.tool-icon, .setting-tile span { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 15px; color: #fff; font-weight: 950; }
.tool-icon.blue, .setting-tile span { background: linear-gradient(135deg, var(--blue), #3b82f6); }
.tool-icon.green { background: linear-gradient(135deg, #059669, var(--green)); }
.tool-icon.purple { background: linear-gradient(135deg, var(--purple), #a855f7); }
.ai-result-panel, .image-preview {
  min-height: 220px;
  padding: 16px;
  border: 1px dashed #cbd8e8;
  border-radius: 16px;
  background: #f8fbff;
  white-space: pre-wrap;
  line-height: 1.7;
}
.image-preview img { max-width: 100%; border-radius: 14px; display: block; }
.notice-item { display: grid; grid-template-columns: 12px 1fr; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; margin-bottom: 10px; cursor: pointer; }
.notice-item.is-read { opacity: .68; }
.notice-dot { width: 10px; height: 10px; margin-top: 6px; border-radius: 999px; background: var(--blue); }
.empty-state { min-height: 160px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); text-align: center; }
.empty-state span { min-width: 48px; height: 48px; padding: 0 10px; display: grid; place-items: center; border-radius: 16px; background: #eaf2ff; color: var(--blue); font-weight: 950; }
.empty-state b { color: var(--text); }
.loading-skeleton {
  border-radius: 16px;
  background: linear-gradient(90deg, #edf3fa 0%, #f9fbff 46%, #edf3fa 90%);
  background-size: 220% 100%;
  animation: skeletonMove 1.1s ease-in-out infinite;
}
@keyframes skeletonMove { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.progress-line { height: 12px; border-radius: 999px; overflow: hidden; background: #e8eef7; margin: 18px 0; }
.progress-line span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.drawer { position: fixed; inset: 0; z-index: 60; background: rgba(15,23,42,.34); display: grid; justify-content: end; }
.drawer-panel { width: min(560px, 100vw); height: 100%; background: #fff; padding: 22px; box-shadow: -20px 0 44px rgba(15,23,42,.16); overflow: auto; }
.mobile-backdrop { position: fixed; inset: 0; z-index: 39; background: rgba(15, 23, 42, .38); }
.no-access-card { min-height: 420px; display: grid; place-items: center; }

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quick-entry-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { min-height: 520px; }
  .app { display: block; }
  .mobile-menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(84vw, 310px);
    transform: translateX(-104%);
    transition: transform .22s ease;
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .main { padding: 12px; }
  .topbar { align-items: flex-start; }
  .dashboard-layout, .ai-workbench { grid-template-columns: 1fr; }
  .search-filter-bar { grid-template-columns: 1fr; }
  .ai-tool-grid, .settings-grid { grid-template-columns: 1fr; }
  .donut-card { grid-template-columns: 1fr; justify-items: center; }
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; width: 100%; min-width: 0; }
  thead { display: none; }
  tbody tr { margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow-soft); }
  td { min-height: 38px; display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; padding: 9px 4px; border-top: 0; border-bottom: 1px solid #edf2f7; white-space: normal; word-break: break-word; }
  td::before { content: attr(data-label); color: #6b7f96; font-size: 12px; font-weight: 850; }
  td:last-child { border-bottom: 0; }
  td[colspan] { display: block; }
  td[colspan]::before { display: none; }
}
@media (max-width: 620px) {
  .auth-page { padding: 12px; }
  .auth-hero { min-height: auto; padding: 22px; }
  .hero-copy { margin-top: 42px; }
  .hero-metrics { grid-template-columns: 1fr; }
  .feature-strip { position: relative; left: auto; right: auto; bottom: auto; margin-top: 24px; }
  .auth-card, .card, .page-hero { padding: 16px; }
  .topbar { display: grid; }
  .topbar-actions { justify-content: space-between; }
  .user-chip { min-width: 0; }
  .stats, .secondary-stats, .quick-entry-grid, .form-grid, .grid4 { grid-template-columns: 1fr; }
  .page-hero { display: grid; align-items: start; }
  .section-head { display: grid; }
}

/* Unified commercial UI polish */
:root {
  --radius: 16px;
  --radius-sm: 12px;
  --danger: #ef4444;
  --success: #10b981;
  --info: #2563eb;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  box-shadow: none;
}

button:not(.primary):not(.nav):not(.icon-btn):not(.quick-entry):not(.reminder-item) {
  background: #fff;
  border-color: #d9e4f2;
  color: #24405d;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(15, 23, 42, .08);
}

button:disabled:hover {
  transform: none;
  box-shadow: none;
}

.danger-btn {
  border-color: #fecaca !important;
  background: #fff1f2 !important;
  color: #be123c !important;
}

.card {
  padding: 24px;
}

.card h3 {
  color: #13243a;
  font-size: 18px;
  letter-spacing: 0;
}

.card:hover,
.module-map div:hover,
.status-grid div:hover,
.report-grid div:hover,
.setting-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(15, 23, 42, .08);
}

.auth-helper-row,
.auth-safe-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.auth-helper-row button {
  min-height: 34px;
  padding: 0;
  border: 0 !important;
  background: transparent !important;
  color: var(--primary) !important;
  font-size: 13px;
  box-shadow: none !important;
}

.auth-safe-note {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #e5edf7;
  color: #66758b;
  font-size: 12px;
}

.auth-safe-note b {
  color: #1d3550;
}

.auth-feature-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  padding: 12px 0 16px;
}

.topbar-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

.mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(15, 23, 42, .38);
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-group {
  display: grid;
  gap: 4px;
  margin: 8px 0;
}

.nav-parent {
  justify-content: space-between;
  margin-bottom: 2px;
}

.nav-chevron {
  margin-left: auto;
  font-size: 14px;
  color: #7590ab;
  transition: transform .18s ease;
}

.nav-group.is-collapsed .nav-chevron {
  transform: rotate(-90deg);
}

.nav-children {
  display: grid;
  gap: 4px;
}

.nav-group.is-collapsed .nav-children {
  display: none;
}

.nav-child {
  min-height: 38px;
  margin: 0 0 0 18px;
  padding-left: 18px;
  font-size: 13px;
  color: #5c7088;
  background: #f5f8fc;
}

.nav-child::before {
  content: "·";
}

.nav-child.active {
  background: #eaf2ff;
  color: var(--primary);
  box-shadow: none;
}

.table-wrap {
  background: #fff;
}

.search-filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(4, auto);
  gap: 10px;
  align-items: center;
  margin: 14px 0;
}

.search-filter-bar input,
.search-filter-bar select {
  margin: 0;
}

.table-thumb,
.thumb-placeholder {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #e1e9f2;
  background: #f4f8fd;
  color: #7b8fa6;
  font-size: 12px;
  object-fit: cover;
}

tbody tr {
  transition: background-color .16s ease;
}

tbody tr:hover {
  background: #f8fbff;
}

.badge,
.ok,
.danger,
.status-pill {
  border: 1px solid transparent;
  font-weight: 850;
}

.badge {
  background: #edf5ff;
  color: #1558d6;
  border-color: #cfe0ff;
}

.ok {
  color: #047857;
  background: #ecfdf5;
  border-color: #bbf7d0;
}

.danger {
  color: #be123c;
  background: #fff1f2;
  border-color: #fecdd3;
}

.status-pill.purple {
  color: #6d28d9;
  background: #f3e8ff;
  border: 1px solid #ddd6fe;
}

.empty-state {
  min-height: 132px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: #64748b;
}

.empty-state span {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: #eef4ff;
  color: var(--primary);
  font-weight: 950;
}

.empty-state b {
  color: #18324f;
}

.empty-state small {
  max-width: 360px;
  line-height: 1.6;
  white-space: normal;
}

.ai-tool-grid,
.settings-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.ai-tool-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ai-tool-card {
  margin-bottom: 0;
}

.tool-icon,
.setting-tile span {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #fff;
  font-weight: 950;
}

.tool-icon.purple { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.tool-icon.blue { background: linear-gradient(135deg, #2563eb, #4f8cff); }
.tool-icon.green { background: linear-gradient(135deg, #059669, #10b981); }

.settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.setting-tile {
  min-height: 136px;
  display: grid;
  align-content: start;
  justify-items: start;
  text-align: left;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}

button.setting-tile {
  min-height: 136px;
  margin: 0;
  color: inherit;
}

.setting-tile span {
  background: #eaf2ff;
  color: var(--primary);
}

.setting-tile b {
  color: #14243a;
  font-size: 16px;
}

.setting-tile small {
  line-height: 1.6;
}

.ticket {
  margin: 0;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .05);
}

.ticket + .ticket {
  margin-top: 12px;
}

.ticket-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ticket-head b,
.ticket-head small {
  display: block;
}

.ticket-head em {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f3e8ff;
  color: #6d28d9;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.ai-workbench-card textarea {
  min-height: 132px;
}

.donut-wrap {
  min-height: 300px;
}

.donut-card {
  min-height: 260px;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}

.donut-ring {
  width: 178px;
  height: 178px;
  border-radius: 999px;
  background:
    radial-gradient(circle at center, #fff 0 43%, transparent 44%),
    conic-gradient(#2563eb 0 38%, #10b981 38% 62%, #f97316 62% 78%, #8b5cf6 78% 92%, #ef4444 92% 100%);
  border: 1px solid #e4ecf7;
  box-shadow: inset 0 0 0 14px rgba(255, 255, 255, .35), 0 16px 36px rgba(15, 23, 42, .08);
}

.donut-list {
  display: grid;
  gap: 12px;
}

.donut-list span,
.rank-row,
.audit-log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e6eef8;
  border-radius: 14px;
  background: #f8fbff;
}

.donut-list i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 8px;
}

.rank-row {
  margin-bottom: 10px;
}

.rank-row span,
.audit-log-item span,
.audit-log-item small {
  color: var(--muted);
  line-height: 1.5;
}

.audit-log-list {
  display: grid;
  gap: 10px;
}

.audit-log-item {
  margin: 0;
}

.no-access-card {
  min-height: 420px;
  display: grid;
  place-items: center;
}

.focus-card {
  outline: 4px solid rgba(37, 99, 235, .14);
  box-shadow: 0 0 0 8px rgba(37, 99, 235, .08), var(--shadow);
}

.loading-skeleton {
  min-height: 120px;
  border-radius: 16px;
  background: linear-gradient(90deg, #eef4fb 0%, #f8fbff 44%, #eef4fb 88%);
  background-size: 220% 100%;
  animation: skeletonMove 1.2s ease-in-out infinite;
}

@keyframes skeletonMove {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

@media (max-width: 980px) {
  .mobile-menu-btn {
    display: inline-flex;
  }

  .app {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(82vw, 310px);
    z-index: 40;
    height: 100dvh;
    transform: translateX(-104%);
    transition: transform .22s ease;
  }

  .app.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
    width: 100%;
    padding: 14px;
  }

  .topbar {
    border-radius: 0 0 18px 18px;
    padding: 12px 0;
  }

  .ai-tool-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .auth-feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-wrap {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody tr {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  td {
    min-height: 38px;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 9px 4px;
    border-bottom: 1px solid #edf2f7;
    white-space: normal;
    word-break: break-word;
  }

  td::before {
    content: attr(data-label);
    color: #6b7f96;
    font-size: 12px;
    font-weight: 850;
  }

  td:last-child {
    border-bottom: 0;
  }

  td[colspan] {
    display: block;
  }

  td[colspan]::before {
    display: none;
  }

  .search-filter-bar {
    grid-template-columns: 1fr;
  }

  .donut-card {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .donut-list {
    width: 100%;
  }

  .audit-log-item,
  .rank-row,
  .donut-list span {
    display: grid;
    justify-content: stretch;
  }
}

@media (max-width: 560px) {
  .auth-page {
    padding: 10px;
  }

  .auth-card,
  .card {
    padding: 18px;
  }

  .auth-feature-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    gap: 8px;
  }

  .icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }

  .user-chip {
    min-width: 0;
    padding-right: 10px;
  }

  .user-chip small {
    font-size: 11px;
  }

  .section-head {
    display: grid;
  }
}

.compact-hero {
  margin-bottom: 18px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.status-card {
  background: #fff;
  border: 1px solid rgba(30, 64, 175, .08);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .06);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.status-card span,
.status-card small {
  color: #64748b;
  line-height: 1.55;
}

.status-card b {
  color: #0f172a;
  font-size: 20px;
}

.inline-status {
  margin-bottom: 14px;
  box-shadow: none;
  background: #f8fbff;
}

.input-action {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-action input {
  min-width: 0;
  flex: 1;
}

.input-action button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.sync-progress-card {
  background: #fff;
  border: 1px solid rgba(30, 64, 175, .08);
  border-radius: 18px;
  box-shadow: 0 16px 38px rgba(15, 23, 42, .07);
  padding: 18px;
  margin-top: 16px;
}

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

.progress-head span {
  color: #64748b;
}

.progress-track {
  height: 10px;
  background: #e5efff;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}

.progress-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #0b7cff, #38bdf8);
  border-radius: inherit;
  transition: width .25s ease;
}

.warning-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #fff7ed;
  border-color: rgba(249, 115, 22, .18);
  color: #7c2d12;
}

.warning-card span {
  color: #9a3412;
  line-height: 1.7;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.help-grid ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #475569;
  line-height: 1.8;
}

.responsive-table table {
  min-width: 760px;
}

@media (max-width: 900px) {
  .status-grid,
  .help-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .status-grid,
  .help-grid,
  .dashboard-layout,
  .ai-workbench {
    grid-template-columns: 1fr;
  }

  .progress-head,
  .warning-card,
  .input-action {
    flex-direction: column;
    align-items: stretch;
  }

  .responsive-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .responsive-table table {
    min-width: 680px;
  }
}

/* Commercial navigation shell: desktop sidebar, real collapsible groups, mobile drawer. */
.app {
  grid-template-columns: 264px minmax(0, 1fr);
  align-items: stretch;
  overflow-x: hidden;
}

.sidebar {
  position: relative;
  top: auto;
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 18px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(246,250,255,.92));
}

.sidebar nav,
#sidebarNav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 2px 16px;
  scrollbar-width: thin;
}

.nav {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  border-radius: 10px;
  color: #1b64d8;
  background: #e8f1ff;
  font-size: 13px;
  font-weight: 800;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-caret {
  margin-left: auto;
  color: #8aa0b8;
  transition: transform .18s ease;
}

.nav-group {
  display: grid;
  gap: 4px;
  margin: 2px 0;
}

.nav-parent {
  color: #344f6f;
}

.nav-group.expanded .nav-caret {
  transform: rotate(90deg);
}

.nav-children {
  display: none;
  gap: 4px;
  padding: 2px 0 4px 12px;
}

.nav-group.expanded .nav-children {
  display: grid;
}

.nav-child {
  width: calc(100% - 10px);
  min-height: 36px;
  margin: 0 0 0 10px;
  padding-left: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #657990;
  background: transparent;
}

.nav-child::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #b8c7d8;
  flex: 0 0 6px;
}

.nav-child:hover {
  color: var(--blue);
  background: #eef5ff;
}

.nav-child.active,
.nav-parent.parent-active {
  color: var(--blue);
  background: #eaf2ff;
  box-shadow: none;
}

.nav.active .nav-icon,
.nav-parent.parent-active .nav-icon {
  color: #fff;
  background: rgba(255,255,255,.2);
}

.nav.active {
  color: #fff;
  background: linear-gradient(135deg, #006bff, #2c83ff);
}

.logout-nav {
  margin-top: 8px;
}

.mobile-backdrop {
  opacity: 1;
  transition: opacity .2s ease;
}

.mobile-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(85vw, 320px);
    height: 100dvh;
    max-height: 100dvh;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 24px 0 60px rgba(15, 23, 42, .2);
  }

  .app.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .main {
    width: 100%;
    min-width: 0;
    padding: 12px;
  }

  body:has(.app.sidebar-open) {
    overflow: hidden;
  }
}

.auth-apply-title {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #eff6ff;
  color: #1d4ed8;
}

.auth-apply-title span {
  color: #5f7390;
  font-size: 13px;
}

.sync-state-board,
.ai-entry-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.sync-state-board span,
.ai-entry-strip button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid #d9e6f6;
  background: #f4f8ff;
  color: #42617f;
  font-size: 12px;
  font-weight: 700;
}

.sync-api-state {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #f8fbff;
}

.sync-api-state b {
  color: #1e3a5f;
}

.sync-api-state span {
  color: #55708c;
}

.permission-matrix {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.permission-matrix label {
  min-height: 42px;
  padding: 10px;
  border: 1px solid #e1eaf5;
  border-radius: 12px;
  background: #f8fbff;
  color: #48627d;
}

.product-preview-card {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.preview-image {
  display: grid;
  place-items: center;
  min-height: 148px;
  border: 1px dashed #c8d7ea;
  border-radius: 16px;
  background: #f5f9ff;
  color: #7187a0;
  overflow: hidden;
}

.preview-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.finance-stats {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.logistics-timeline {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.timeline-item {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 12px 14px 12px 18px;
  border-left: 3px solid #2f80ff;
  border-radius: 12px;
  background: #f7fbff;
}

.timeline-item b {
  color: #183957;
}

.timeline-item span {
  color: #60758b;
}

@media (max-width: 980px) {
  .permission-matrix,
  .product-preview-card,
  .finance-stats {
    grid-template-columns: 1fr;
  }

  .sync-api-state {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Brand and navigation polish */
.brand {
  position: relative;
}

.brand-icon,
.auth-logo {
  display: block;
  object-fit: contain;
  background: #071b33;
}

.sidebar-close {
  display: none;
  width: 34px;
  height: 34px;
  min-height: 34px;
  margin-left: auto;
  padding: 0;
  border-radius: 10px;
  color: #52677f;
  background: #f4f8fd;
  border-color: #e0e9f5;
  font-size: 20px;
  line-height: 1;
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-parent {
  width: 100%;
  justify-content: space-between;
}

.nav-chevron {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: #6f86a3;
  background: rgba(233, 240, 250, .9);
  transition: transform .18s ease, background .18s ease, color .18s ease;
}

.nav-parent:hover .nav-chevron {
  color: var(--blue);
  background: #e6f0ff;
}

.nav-group:not(.collapsed) .nav-children {
  display: grid;
}

.nav-group.collapsed .nav-children {
  display: none;
}

.nav-group.collapsed .nav-chevron {
  transform: rotate(-90deg);
}

.badge.success,
.status-pill.success { color: #047857; background: #ecfdf5; border-color: #bbf7d0; }
.badge.failed,
.status-pill.failed { color: #be123c; background: #fff1f2; border-color: #fecdd3; }
.badge.waiting,
.status-pill.waiting { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.badge.running,
.status-pill.running { color: #1558d6; background: #edf5ff; border-color: #cfe0ff; }
.badge.unconfigured,
.status-pill.unconfigured { color: #475569; background: #f1f5f9; border-color: #dbe4ee; }
.badge.development,
.status-pill.development { color: #6d28d9; background: #f5f3ff; border-color: #ddd6fe; }
.badge.no-access,
.status-pill.no-access { color: #c2410c; background: #fff7ed; border-color: #fed7aa; }
.badge.partial,
.status-pill.partial { color: #a16207; background: #fefce8; border-color: #fde68a; }

button.is-loading,
button[aria-busy="true"] {
  pointer-events: none;
  opacity: .72;
}

.webhook-status-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .9fr);
  gap: 16px;
  align-items: stretch;
}

.webhook-endpoint-box {
  display: grid;
  gap: 12px;
}

.webhook-endpoint-box label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 13px;
}

.webhook-endpoint-box input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #dbe6f5;
  border-radius: 10px;
  padding: 0 12px;
  background: #f8fbff;
  color: #0f172a;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

.no-api-1688-layout {
  grid-template-columns: minmax(320px, .78fr) minmax(0, 1.22fr);
}

.no-api-preview-card {
  align-items: stretch;
}

.no-api-preview-card .preview-content {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.no-api-preview-card h4 {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
  color: #0f172a;
}

.no-api-preview-card p {
  margin: 0;
  color: #475569;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.no-api-1688-actions .ai-entry-strip {
  margin: 0 0 10px;
}

@media (max-width: 980px) {
  .sidebar .brand {
    padding-right: 42px;
  }

  .sidebar-close {
    display: inline-flex;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
  }

  .app.sidebar-open {
    overflow: hidden;
  }

  .webhook-status-grid {
    grid-template-columns: 1fr;
  }

  .no-api-1688-layout {
    grid-template-columns: 1fr;
  }

  .no-api-preview-card {
    grid-template-columns: 1fr;
  }
}
