:root {
  color-scheme: light;
  --bg: #111315;
  --surface: #fffdf8;
  --surface-2: #f8f3ec;
  --text: #171716;
  --muted: #746d66;
  --line: #e3d9cf;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #f4c867;
  --danger: #dc2626;
  --cream: #f3e9e1;
  --dark: #111315;
  --shadow: 0 18px 40px rgba(24, 20, 16, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  overscroll-behavior-y: auto;
}

body.task-running {
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px calc(88px + env(safe-area-inset-bottom));
  overscroll-behavior-y: auto;
  background:
    linear-gradient(180deg, #111315 0, #111315 148px, var(--cream) 148px, var(--cream) 100%);
}

body.task-running .app-shell {
  overscroll-behavior-y: contain;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 18px;
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.topbar-logo {
  display: block;
  width: 128px;
  height: auto;
}

.app-name {
  flex: 0 0 auto;
  color: #fffdf8;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0;
}

.app-version {
  flex: 0 0 auto;
  align-self: flex-end;
  margin-bottom: 2px;
  padding: 2px 6px;
  border: 1px solid rgba(255, 253, 248, 0.18);
  border-radius: 999px;
  color: rgba(255, 253, 248, 0.72);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.3;
}

.hero-kicker {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2,
h3,
p {
  margin-top: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 18px;
}

.icon-button {
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: #202225;
  color: #fffdf8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 12px 28px rgba(0, 0, 0, 0.22);
}

.icon-button svg,
.text-button svg,
.primary-button svg,
.ghost-button svg,
.nav-item svg,
.action-tile svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.hero-panel {
  overflow: hidden;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background:
    radial-gradient(circle at 16% 18%, rgba(244, 200, 103, 0.4), transparent 34%),
    radial-gradient(circle at 86% 16%, rgba(117, 221, 190, 0.35), transparent 36%),
    linear-gradient(135deg, #fff7cf 0%, #daf4e7 100%);
  box-shadow: 0 18px 44px rgba(10, 10, 10, 0.18);
}

body[data-view="dashboardView"] .hero-panel,
body[data-view="pendingView"] .hero-panel,
body[data-view="pendingView"] .stats-grid,
body[data-view="pendingView"] .duplicate-panel,
body[data-view="pendingView"] .incomplete-panel,
body[data-view="pendingView"] .completion-result-panel,
body[data-view="peopleView"] .hero-panel,
body[data-view="peopleView"] .stats-grid,
body[data-view="peopleView"] .duplicate-panel,
body[data-view="peopleView"] .incomplete-panel,
body[data-view="peopleView"] .completion-result-panel,
body[data-view="aiView"] .hero-panel,
body[data-view="aiView"] .stats-grid,
body[data-view="aiView"] .duplicate-panel,
body[data-view="aiView"] .incomplete-panel,
body[data-view="aiView"] .completion-result-panel {
  display: none !important;
}

.hero-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-tile {
  display: flex;
  min-height: 86px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.9);
  color: var(--text);
  font-weight: 850;
  box-shadow: 0 10px 26px rgba(38, 32, 25, 0.1);
}

.action-tile input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

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

.stat-card {
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid rgba(227, 217, 207, 0.72);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  text-align: left;
  box-shadow: 0 8px 22px rgba(38, 32, 25, 0.08);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.stat-card:active {
  transform: translateY(1px) scale(0.99);
}

.stat-card.active {
  border-color: rgba(15, 118, 110, 0.34);
  background: linear-gradient(135deg, #fff4c9, #dff8ed);
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.14);
}

.stat-card span {
  display: block;
  font-size: 24px;
  font-weight: 850;
  line-height: 1;
}

.stat-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.type-stat {
  box-shadow: none;
}

.task-progress {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 12px 28px rgba(38, 32, 25, 0.1);
}

.task-progress[hidden] {
  display: none;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.progress-header strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.task-progress:not(.done) .progress-header strong::before {
  content: "";
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(15, 118, 110, 0.22);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: progressSpin 0.8s linear infinite;
}

.progress-header span {
  color: var(--muted);
  font-weight: 800;
}

.progress-bar {
  position: relative;
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #eadfd4;
}

.task-progress:not(.done) .progress-bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
  transform: translateX(-120%);
  animation: progressScan 1.25s ease-in-out infinite;
}

.progress-bar span {
  position: relative;
  z-index: 1;
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #75ddb8);
  transition: width 180ms ease;
}

.task-progress p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.task-progress.done {
  border-color: rgba(15, 118, 110, 0.28);
}

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

@keyframes progressScan {
  0% {
    transform: translateX(-120%);
  }

  55%,
  100% {
    transform: translateX(260%);
  }
}

.duplicate-panel,
.incomplete-panel,
.completion-result-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid rgba(220, 38, 38, 0.18);
  border-radius: 8px;
  background: #fff7f3;
  box-shadow: 0 10px 24px rgba(38, 32, 25, 0.07);
}

.incomplete-panel {
  border-color: rgba(245, 158, 11, 0.24);
  background: #fffbeb;
}

.completion-result-panel {
  border-color: rgba(15, 118, 110, 0.24);
  background: #f0fdfa;
}

.completion-result-panel .icon-button {
  width: 36px;
  height: 36px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--brand-dark);
  box-shadow: none;
}

.duplicate-panel[hidden],
.incomplete-panel[hidden],
.completion-result-panel[hidden] {
  display: none;
}

.duplicate-panel header,
.incomplete-panel header,
.completion-result-panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.duplicate-panel header h3,
.incomplete-panel header h3,
.completion-result-panel header h3 {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0;
  font-size: 16px;
}

.duplicate-panel header p,
.incomplete-panel header p,
.completion-result-panel header p,
.duplicate-item small,
.incomplete-item p,
.panel-footnote {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.duplicate-list,
.incomplete-list,
.completion-result-list {
  display: grid;
  gap: 8px;
}

.duplicate-item,
.incomplete-item,
.completion-result-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(220, 38, 38, 0.16);
  border-radius: 8px;
  background: #fffdf8;
}

.incomplete-item {
  border-color: rgba(245, 158, 11, 0.22);
}

.completion-result-item {
  border-color: rgba(15, 118, 110, 0.2);
}

.incomplete-item strong {
  display: block;
  font-size: 14px;
}

.incomplete-actions,
.completion-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.completion-result-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.completion-result-title strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.completion-final-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.completion-final-fields div {
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(15, 118, 110, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
}

.completion-final-fields span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.completion-final-fields strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.completion-changes {
  display: grid;
  gap: 6px;
}

.completion-change {
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.completion-change span {
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 850;
}

.completion-change p {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.completion-change del {
  text-decoration-thickness: 1px;
}

.completion-change strong {
  color: var(--ink);
}

.completion-no-change {
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.duplicate-rows {
  display: grid;
  gap: 6px;
}

.duplicate-rows div {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 8px;
  align-items: start;
}

.duplicate-rows span {
  padding: 4px 6px;
  border-radius: 8px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 11px;
  font-weight: 850;
  text-align: center;
}

.duplicate-rows .keep-row span {
  background: #e1f5ec;
  color: var(--brand-dark);
}

.duplicate-rows p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.danger-mini {
  background: #fee2e2;
  color: #b91c1c;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.summary-share-box {
  position: relative;
}

.summary-share-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 8;
  display: grid;
  min-width: 136px;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: 0 16px 34px rgba(24, 20, 16, 0.16);
}

.summary-share-menu[hidden] {
  display: none;
}

.summary-share-menu button {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-weight: 850;
  text-align: left;
}

.summary-share-menu button:active,
.summary-share-menu button:hover {
  background: #f3e9e1;
}

.search-panel {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 -14px 14px;
  padding: 10px 14px;
  background: rgba(243, 233, 225, 0.92);
  backdrop-filter: blur(16px);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.sort-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.select-trigger {
  position: relative;
  display: grid;
  gap: 4px;
  min-width: 0;
  min-height: 44px;
  padding: 7px 32px 7px 10px;
  border: 1px solid #d8cdc2;
  border-radius: 8px;
  background: #fbf7f0;
  color: var(--text);
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.select-trigger::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #746d66;
  border-bottom: 2px solid #746d66;
  transform: translateY(-65%) rotate(45deg);
  transition: transform 160ms ease;
}

.select-trigger[aria-expanded="true"] {
  border-color: rgba(15, 118, 110, 0.38);
  background: #fffdf8;
}

.select-trigger[aria-expanded="true"]::after {
  transform: translateY(-35%) rotate(225deg);
}

.select-trigger span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
}

.select-trigger strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-panel {
  margin-top: 6px;
  padding: 6px;
  border: 1px solid rgba(227, 217, 207, 0.95);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: 0 12px 24px rgba(38, 32, 25, 0.1);
}

.picker-panel[hidden] {
  display: none;
}

.picker-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf3;
}

.picker-search svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--muted);
}

.picker-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.picker-options {
  display: grid;
  gap: 2px;
  max-height: 232px;
  margin-top: 6px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px;
  border-radius: 8px;
}

.picker-options.compact {
  max-height: 216px;
  margin-top: 0;
}

.picker-option {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}

.picker-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-option.active {
  background: #e8f7f1;
  color: var(--brand);
}

.picker-option.active::after {
  content: "";
  width: 7px;
  height: 12px;
  flex: 0 0 auto;
  border-right: 2px solid var(--brand);
  border-bottom: 2px solid var(--brand);
  transform: rotate(45deg);
}

.filter-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-chip {
  flex: 0 0 auto;
  min-width: 74px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.filter-chip.active {
  border-color: rgba(15, 118, 110, 0.18);
  background: linear-gradient(135deg, #f7d681, #75ddb8);
  color: #131615;
}

.team-filter-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.team-chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid rgba(227, 217, 207, 0.9);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(38, 32, 25, 0.06);
}

.team-chip span {
  margin-left: 4px;
  color: var(--muted);
  font-weight: 750;
}

.team-chip.active {
  border-color: rgba(15, 118, 110, 0.18);
  background: linear-gradient(135deg, #f7d681, #75ddb8);
  color: #131615;
}

.team-chip.active span {
  color: rgba(19, 22, 21, 0.72);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0 10px;
}

.section-actions {
  display: flex;
  flex: 1 1 220px;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.text-button,
.primary-button,
.ghost-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 800;
}

.text-button {
  border: 1px solid var(--line);
  background: #fffdf8;
  color: #151513;
  box-shadow: 0 8px 22px rgba(38, 32, 25, 0.08);
}

.text-button:disabled,
.text-button.is-busy {
  opacity: 0.78;
  cursor: wait;
}

.button-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(15, 118, 110, 0.2);
  border-top-color: var(--brand);
  border-radius: 999px;
  animation: progressSpin 0.8s linear infinite;
}

.text-button input,
input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  max-width: 1px;
  opacity: 0;
  pointer-events: none;
}

.settings-tool {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf7f0;
}

.settings-tool strong,
.settings-tool p {
  margin: 0;
}

.settings-refresh-button {
  width: 100%;
}

.settings-auth-status {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.8);
  color: var(--muted);
  font-size: 13px;
}

.settings-auth-status strong {
  color: var(--text);
}

.settings-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.settings-action-grid .text-button {
  width: 100%;
}

.primary-button {
  width: 100%;
  background: linear-gradient(135deg, #f7d681, #75ddb8);
  color: #151513;
}

.ghost-button {
  width: 100%;
  border: 1px solid rgba(220, 38, 38, 0.26);
  background: #fff;
  color: var(--danger);
}

.content-view {
  display: none;
}

.content-view.active {
  display: block;
}

.patent-list,
.people-list,
.certificate-list,
.kanban {
  display: grid;
  gap: 10px;
}

.patent-card,
.person-card,
.certificate-card,
.stage-card {
  border: 1px solid rgba(227, 217, 207, 0.72);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(38, 32, 25, 0.08);
}

.patent-card {
  padding: 14px;
}

.patent-card header,
.certificate-card header,
.person-card header,
.stage-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.patent-card h4,
.certificate-card h4,
.person-card h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
}

.certificate-card {
  padding: 14px;
}

.certificate-card header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.certificate-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.certificate-meta span {
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.certificate-meta .warning-chip {
  background: #fff1cb;
  color: #92400e;
}

.person-summary-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: 0 10px 24px rgba(38, 32, 25, 0.07);
}

.person-summary-panel[hidden] {
  display: none;
}

.person-summary-panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.person-summary-panel h3 {
  margin: 0;
}

.person-summary-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.summary-list {
  display: grid;
  gap: 8px;
}

.summary-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(227, 217, 207, 0.72);
  border-radius: 8px;
  background: #fbf7f0;
}

.summary-item small,
.summary-item span {
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  line-height: 1.35;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 5px 8px;
  border-radius: 8px;
  background: #e1f5ec;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
}

.status-badge.pending {
  background: #fff1cb;
  color: #92400e;
}

.status-badge.warning {
  background: #fee2e2;
  color: #b91c1c;
}

.patent-badges {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 850;
}

.type-invention {
  background: #e8f1ff;
  color: #1d4ed8;
}

.type-utility {
  background: #e8f8ef;
  color: #15803d;
}

.type-design {
  background: #f5ecff;
  color: #7e22ce;
}

.type-international {
  background: #fff0e8;
  color: #c2410c;
}

.patent-card[data-status="granted"] {
  border-left: 5px solid var(--brand);
}

.patent-card[data-status="pending"] {
  border-left: 5px solid var(--accent);
}

.patent-card[data-kind="invention"] {
  box-shadow: inset 0 0 0 1px rgba(29, 78, 216, 0.08), 0 10px 26px rgba(38, 32, 25, 0.08);
}

.patent-card[data-kind="utility"] {
  box-shadow: inset 0 0 0 1px rgba(21, 128, 61, 0.08), 0 10px 26px rgba(38, 32, 25, 0.08);
}

.patent-card[data-kind="design"] {
  box-shadow: inset 0 0 0 1px rgba(126, 34, 206, 0.08), 0 10px 26px rgba(38, 32, 25, 0.08);
}

.patent-card[data-kind="international"] {
  box-shadow: inset 0 0 0 1px rgba(194, 65, 12, 0.08), 0 10px 26px rgba(38, 32, 25, 0.08);
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.meta-item {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.meta-item small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.meta-item span {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 4px;
  font-weight: 750;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 8px;
}

.mini-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 8px;
  background: #f6eadb;
  color: #2c2620;
  font-size: 13px;
  font-weight: 800;
}

.mini-button svg {
  width: 16px;
  height: 16px;
}

.person-card {
  padding: 12px;
  border-color: rgba(227, 217, 207, 0.84);
  background: linear-gradient(180deg, #fffdf8 0%, #fbf7f0 100%);
  box-shadow: 0 8px 18px rgba(38, 32, 25, 0.06);
}

.person-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.person-title h4 {
  margin: 0;
}

.person-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.person-avatar {
  display: inline-grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: #e1f5ec;
  color: var(--brand-dark);
  font-size: 16px;
  font-weight: 900;
}

.person-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.person-stats span {
  padding: 6px 8px;
  border-radius: 8px;
  background: #fff7e3;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.person-editor {
  display: grid;
  gap: 8px;
}

.person-editor label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.person-editor input,
.person-editor select {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(227, 217, 207, 0.95);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
}

.person-editor p {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.stage-card {
  overflow: hidden;
}

.stage-card header {
  padding: 12px 14px;
  background: #f7eee5;
}

.stage-card .patent-card {
  margin: 10px;
  box-shadow: none;
}

.ai-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--text);
  color-scheme: light;
  outline: 0;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, #5f5a54 50%) right 17px center / 6px 6px no-repeat,
    linear-gradient(135deg, #5f5a54 50%, transparent 50%) right 12px center / 6px 6px no-repeat,
    #fffdf8;
}

select option {
  background: #fffdf8;
  color: var(--text);
}

input,
select {
  height: 46px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
}

.ai-result {
  min-height: 120px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  line-height: 1.65;
  white-space: pre-wrap;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(227, 217, 207, 0.72);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(18px);
}

.nav-item {
  display: grid;
  min-width: 0;
  min-height: 54px;
  place-items: center;
  gap: 3px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.nav-item.active {
  background: #e1f5ec;
  color: #0f625b;
}

.sheet-dialog {
  width: min(calc(100% - 24px), 460px);
  max-height: calc(100vh - 36px);
  margin: auto auto 12px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sheet-dialog::backdrop {
  background: rgba(8, 20, 17, 0.42);
  backdrop-filter: blur(4px);
}

.viewer-dialog {
  width: min(calc(100% - 16px), 480px);
  height: min(calc(100vh - 28px), 820px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.viewer-dialog::backdrop {
  background: rgba(8, 20, 17, 0.62);
  backdrop-filter: blur(5px);
}

.viewer-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  padding: 12px;
}

.viewer-pages {
  min-height: 0;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #d9d4ce;
}

.pdf-page {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto 10px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(24, 20, 16, 0.16);
}

.share-fallback-dialog {
  margin-bottom: max(12px, env(safe-area-inset-bottom));
}

.share-fallback-shell {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.share-file-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 8px;
  background: #f3fbf7;
}

.share-file-note > svg {
  width: 24px;
  height: 24px;
  color: var(--brand-dark);
}

.share-file-note small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.share-file-note strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-fallback-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.share-fallback-actions .primary-button {
  grid-column: 1 / -1;
}

.certificate-image-page {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto 10px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(24, 20, 16, 0.16);
}

.sheet-dialog form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.person-pick-panel {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.person-pick-panel:empty {
  display: none;
}

.person-pick-panel button,
.person-pick-panel span {
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 999px;
  background: #edf8f3;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 750;
}

.person-pick-panel span {
  border-color: rgba(91, 83, 76, 0.14);
  background: #f7f1e9;
  color: var(--muted);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.source-panel {
  overflow: hidden;
  border: 1px solid rgba(227, 217, 207, 0.9);
  border-radius: 8px;
  background: #fbf7f0;
}

.source-panel summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 12px;
  color: var(--text);
  cursor: pointer;
  font-weight: 850;
}

.source-panel summary small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-actions {
  padding: 0 12px 10px;
}

.source-panel pre {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border-top: 1px solid rgba(227, 217, 207, 0.9);
  background: #fffdf8;
  color: #2c2620;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.empty-state {
  padding: 28px 18px;
  border: 1px dashed #cbbb9e;
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  left: 18px;
  z-index: 20;
  max-width: 444px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 8px;
  background: #10201d;
  color: #fff;
  opacity: 0;
  transform: translateY(10px);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 481px) {
  body {
    background: var(--bg);
  }
}
