:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #eef6f3;
  --surface-3: #f8fafb;
  --text: #16202b;
  --muted: #657386;
  --line: #d9e1e8;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --green: #1d7a50;
  --amber: #a86405;
  --blue: #2d63b8;
  --red: #b3261e;
  --shadow: 0 14px 34px rgba(22, 32, 43, 0.08);
  --shadow-soft: 0 7px 18px rgba(22, 32, 43, 0.06);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, #f8fafb 0, var(--bg) 280px);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

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

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1.15;
}

h2 {
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

small {
  color: var(--muted);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.72rem 0.8rem;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.72);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

label {
  display: grid;
  gap: 0.38rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}

legend {
  padding: 0 0.35rem;
  color: var(--text);
  font-weight: 800;
}

.page {
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.4rem 0 3rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(217, 225, 232, 0.9);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 22px rgba(22, 32, 43, 0.05);
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  align-items: center;
  gap: 1rem;
  min-height: 70px;
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.78rem 0 0.55rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
}

.brand small {
  display: block;
  margin-top: 0.05rem;
}

.brand__mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--primary), #1e8b62);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.22);
}

.userbar,
.head-actions,
.filter-actions,
.form-actions,
.sticky-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7rem;
}

.nav-shell {
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0 0 0.65rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.nav {
  justify-content: flex-start;
}

.global-search {
  min-width: 220px;
}

.global-search input {
  min-height: 44px;
  border-color: transparent;
  padding: 0.62rem 0.85rem;
  background: var(--surface-3);
}

.nav__link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.52rem 0.82rem;
  color: #354252;
  font-size: 0.94rem;
  font-weight: 800;
}

.nav__link:hover {
  text-decoration: none;
  border-color: var(--line);
  background: #fff;
}

.nav__link.is-active {
  border-color: rgba(15, 118, 110, 0.18);
  background: var(--surface-2);
  color: var(--primary-dark);
}

.nav__link--admin {
  color: #4f5d6c;
}

.nav-more {
  flex: 0 0 auto;
  position: relative;
}

.nav-more summary {
  list-style: none;
  cursor: pointer;
}

.nav-more summary::-webkit-details-marker {
  display: none;
}

.nav-more__menu,
.action-menu > div {
  position: fixed;
  z-index: 60;
  display: grid;
  gap: 0.25rem;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.45rem;
  background: #fff;
  box-shadow: var(--shadow);
}

.nav-more__menu {
  top: 118px;
  right: max(1rem, calc((100vw - 1280px) / 2 + 1rem));
}

.nav-more__link,
.action-menu a {
  display: block;
  border-radius: 6px;
  padding: 0.62rem 0.72rem;
  color: var(--text);
  font-weight: 800;
}

.nav-more__link:hover,
.nav-more__link.is-active,
.action-menu a:hover {
  text-decoration: none;
  background: var(--surface-2);
  color: var(--primary-dark);
}

.nav-more__label {
  padding: 0.5rem 0.72rem 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.nav__divider {
  flex: 0 0 auto;
  width: 1px;
  height: 24px;
  margin: 0 0.2rem;
  background: var(--line);
}

.userbar {
  flex-wrap: nowrap;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.92rem;
}

.userbar__account {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 38px;
  color: var(--text);
  font-weight: 800;
}

.userbar__account:hover,
.userbar__logout:hover {
  text-decoration: none;
}

.userbar__avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #e8f2ef;
  color: var(--primary-dark);
  font-size: 0.86rem;
  font-weight: 900;
}

.userbar__logout {
  color: var(--muted);
  font-weight: 800;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.62rem 0.9rem;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  text-align: center;
  line-height: 1.15;
  text-wrap: balance;
  transition: transform 0.12s ease, border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.button:hover {
  text-decoration: none;
  border-color: #b9c5d2;
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.button--primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 7px 16px rgba(15, 118, 110, 0.18);
}

.button--primary:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.button--ghost {
  background: transparent;
}

.button--danger {
  border-color: #e0b3af;
  color: var(--red);
}

.button--small {
  min-height: 34px;
  padding: 0.38rem 0.62rem;
  font-size: 0.88rem;
}

.button--full {
  width: 100%;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.inline-form .button {
  width: 100%;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.45rem 0 1.35rem;
}

.page-head > div {
  min-width: 0;
}

.focus-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.focus-card {
  display: grid;
  gap: 0.35rem;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.focus-card:hover {
  text-decoration: none;
  border-color: #b9c5d2;
  box-shadow: var(--shadow);
}

.focus-card span {
  display: inline-grid;
  place-items: center;
  width: fit-content;
  min-width: 42px;
  min-height: 30px;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  background: var(--surface-2);
  color: var(--primary-dark);
  font-weight: 900;
}

.focus-card strong {
  font-size: 1.05rem;
}

.focus-card small {
  font-weight: 800;
}

.focus-card--primary {
  border-color: rgba(15, 118, 110, 0.28);
  background: #eef8f5;
}

.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.notice {
  margin: 0 0 1rem;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-weight: 700;
}

.notice--success {
  border: 1px solid #b7dec6;
  background: #e8f6ed;
  color: #135c38;
}

.notice--error {
  border: 1px solid #e7b7b3;
  background: #fff0ee;
  color: var(--red);
}

.setup,
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.setup__panel,
.login__panel {
  width: min(920px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login__panel {
  width: min(430px, 100%);
  display: grid;
  gap: 1rem;
}

.setup__header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}

.setup__header h1 {
  font-size: 1.55rem;
}

.setup__header p {
  margin-bottom: 0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-grid fieldset {
  grid-column: 1 / -1;
}

.span-2 {
  grid-column: 1 / -1;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
}

.checkline input {
  width: auto;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.stat span {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-weight: 700;
}

.stat strong {
  font-size: 1.75rem;
}

.stat--wide {
  grid-column: span 2;
  border-color: rgba(15, 118, 110, 0.18);
  background: var(--surface-2);
}

.toolbar,
.filters {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.25rem;
}

.filters {
  grid-template-columns: 2fr repeat(3, minmax(0, 1fr)) auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.bulkbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.bulkbar span {
  color: var(--muted);
  font-weight: 700;
}

.searchbar {
  display: flex;
  gap: 0.65rem;
}

.segmented {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.segmented a {
  padding: 0.68rem 0.85rem;
  color: var(--text);
  font-weight: 800;
}

.segmented a + a {
  border-left: 1px solid var(--line);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.4rem 0 0.85rem;
}

.section-title h2 {
  margin-bottom: 0;
}

.section-title--inside {
  margin-top: 0;
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.article-grid--compact {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 1.25rem;
}

.article-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.article-card:hover {
  border-color: #c3cdd6;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.article-card__image {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: linear-gradient(145deg, #e7eef4, #f3f7f9);
  color: var(--primary);
  font-weight: 900;
}

.article-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-card__body {
  display: grid;
  gap: 0.45rem;
  padding: 0.95rem;
}

.article-card__body h3 {
  margin-bottom: 0;
  font-size: 1.03rem;
}

.article-card__body p {
  margin-bottom: 0;
  color: var(--muted);
}

.article-card__meta {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 900;
}

.badge--green {
  background: #dff3e8;
  color: var(--green);
}

.badge--amber {
  background: #fff1d9;
  color: var(--amber);
}

.badge--blue {
  background: #e1ebff;
  color: var(--blue);
}

.badge--muted {
  background: #eceff3;
  color: #596273;
}

.badge--gray {
  background: #edf1f5;
  color: #475466;
}

.empty-state,
.form-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.empty-state {
  text-align: center;
}

.empty-state p,
.muted {
  color: var(--muted);
}

.info-list {
  display: grid;
  gap: 0.75rem;
}

.info-list p {
  margin-bottom: 0;
}

.check-list {
  display: grid;
  gap: 0.55rem;
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

.check-list--plain {
  padding-left: 0;
}

.action-list {
  display: grid;
  gap: 0.75rem;
}

.action-list form {
  margin: 0;
}

.action-menu {
  position: relative;
}

.action-menu summary {
  list-style: none;
  cursor: pointer;
}

.action-menu summary::-webkit-details-marker {
  display: none;
}

.action-menu > div {
  top: 106px;
  right: max(1rem, calc((100vw - 1280px) / 2 + 1rem));
}

.selection-list,
.calendar-list {
  display: grid;
  gap: 0.75rem;
}

.selection-list a {
  display: grid;
  gap: 0.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  background: #fff;
  color: var(--text);
}

.selection-list a:hover {
  text-decoration: none;
  border-color: #b9c5d2;
}

.calendar-item {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  background: var(--surface);
}

.calendar-item time {
  color: var(--primary);
  font-weight: 900;
}

.calendar-item p {
  margin: 0.25rem 0 0;
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.user-card {
  display: grid;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  background: #fff;
}

.quality-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.overview-section {
  margin-bottom: 1.25rem;
}

.overview-section > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.4rem 0 0.85rem;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 900;
  cursor: pointer;
}

.overview-section > summary small {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.notification-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.notification-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.2rem 0.75rem;
  min-height: 92px;
  border: 1px solid #f0c4a0;
  border-radius: var(--radius);
  padding: 0.85rem;
  background: #fff8ef;
  color: var(--text);
}

.notification-card:hover {
  text-decoration: none;
  border-color: #d99a68;
}

.notification-card strong {
  grid-row: span 2;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: #fff;
  color: var(--amber);
  font-size: 1.2rem;
}

.notification-card span {
  font-weight: 900;
}

.notification-card small {
  grid-column: 2;
}

.quality-card {
  display: grid;
  gap: 0.45rem;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.quality-card:hover {
  text-decoration: none;
  border-color: #b9c5d2;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.quality-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.quality-card strong {
  font-size: 1.6rem;
}

.quality-tabs {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.quality-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.quality-tabs a:hover,
.quality-tabs a.is-active {
  text-decoration: none;
  border-color: var(--primary);
}

.quality-tabs span {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  min-height: 24px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--primary);
  font-size: 0.78rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.data-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  background: #f8fafb;
}

.data-table tbody tr:hover {
  background: #fbfcfd;
}

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

.data-table small {
  display: block;
  margin-top: 0.15rem;
}

.data-table a,
.data-table td {
  overflow-wrap: anywhere;
}

.thumb-cell {
  width: 88px;
}

.select-cell {
  width: 44px;
  text-align: center;
}

.select-cell input {
  width: 18px;
  height: 18px;
}

.thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  background: #e5edf4;
}

.thumb--empty {
  display: grid;
  place-items: center;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 900;
}

.row-actions {
  white-space: nowrap;
}

.edit-layout,
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1rem;
}

.edit-layout {
  grid-template-columns: minmax(0, 1fr);
}

.edit-layout--focused {
  max-width: 980px;
  margin: 0 auto;
}

.form-panel {
  margin-bottom: 1rem;
}

.quick-create-panel {
  border-color: rgba(15, 118, 110, 0.24);
  background: #fbfefd;
}

.quick-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.quick-panel__head h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.quick-number {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: var(--surface-2);
  color: var(--primary-dark);
  font-weight: 900;
}

.quick-form {
  grid-template-columns: minmax(0, 1fr);
}

.collapsible-panel {
  padding: 0;
  overflow: hidden;
}

.collapsible-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 58px;
  padding: 0.9rem 1rem;
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}

.collapsible-panel > summary::-webkit-details-marker {
  display: none;
}

.collapsible-panel > summary::after {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--primary-dark);
  font-weight: 900;
}

.collapsible-panel[open] > summary {
  border-bottom: 1px solid var(--line);
}

.collapsible-panel[open] > summary::after {
  content: "-";
}

.collapsible-panel > summary small {
  margin-left: auto;
  font-weight: 800;
  text-align: right;
}

.collapsible-panel > :not(summary) {
  margin-left: 1rem;
  margin-right: 1rem;
}

.collapsible-panel > :last-child {
  margin-bottom: 1rem;
}

.upload-box {
  display: grid;
  place-items: center;
  gap: 0.25rem;
  min-height: 144px;
  border: 2px dashed #b8c6d4;
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--text);
  text-align: center;
  cursor: pointer;
}

.upload-box--camera {
  min-height: 168px;
  border-color: rgba(15, 118, 110, 0.35);
  background: #f2faf7;
}

.upload-box input {
  width: auto;
}

.upload-box span {
  font-size: 1rem;
}

.upload-status {
  display: none;
  margin-top: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.upload-status:not(:empty) {
  display: block;
}

.upload-status--success {
  border-color: #b7dec6;
  background: #e8f6ed;
  color: #135c38;
}

.upload-status--error {
  border-color: #e7b7b3;
  background: #fff0ee;
  color: var(--red);
}

.preview-grid,
.image-grid,
.gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.preview-grid figure,
.image-grid figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.preview-grid img,
.image-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.preview-grid figcaption,
.image-grid figcaption {
  display: grid;
  gap: 0.5rem;
  padding: 0.6rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.image-actions {
  display: grid;
  gap: 0.45rem;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  justify-content: flex-end;
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
}

.detail-main,
.detail-side,
.stack {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.compact-form {
  margin-bottom: 1rem;
}

.interest-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.interest-list article {
  display: grid;
  gap: 0.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem;
  background: #fff;
}

.interest-list p {
  margin: 0.25rem 0 0;
}

.market-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.market-links--section {
  justify-content: flex-start;
  margin-bottom: 0.85rem;
}

.price-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0 0 0.85rem;
}

.price-summary div {
  display: grid;
  gap: 0.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  background: var(--surface-3);
}

.price-summary dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.price-summary dd {
  margin: 0;
  font-weight: 900;
}

.scan-layout,
.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.scan-box {
  display: grid;
  gap: 0.75rem;
}

.scan-box video {
  width: 100%;
  min-height: 260px;
  border-radius: var(--radius);
  background: #111;
  object-fit: cover;
}

.manual-scan {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: end;
  margin-top: 1rem;
}

.quick-article {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem;
  background: var(--surface-2);
}

.quick-article h3,
.quick-article p {
  margin-bottom: 0;
}

.data-table--compact {
  min-width: 0;
}

.detail-side {
  gap: 0;
}

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

.gallery a,
.gallery__empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #e5edf4;
  color: var(--primary);
  font-weight: 900;
}

.gallery__item {
  position: relative;
}

.gallery__item .badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 1;
}

.gallery img {
  width: 100%;
  height: 100%;
  min-height: 180px;
  object-fit: cover;
}

.mini-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.mini-gallery img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 2px solid transparent;
  border-radius: 6px;
  object-fit: cover;
}

.mini-gallery img.is-ready {
  border-color: var(--green);
}

.copy-text {
  min-height: 210px;
  font-family: Consolas, Monaco, monospace;
}

.copy-text--short {
  min-height: 58px;
}

.copy-text--medium {
  min-height: 112px;
}

.note-form {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.timeline {
  display: grid;
  gap: 0.85rem;
  margin: 0;
  padding-left: 1.15rem;
}

.timeline li {
  padding-left: 0.25rem;
}

.timeline time {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.timeline p {
  margin: 0.25rem 0;
}

.detail-list {
  display: grid;
  gap: 0.7rem;
  margin: 0 0 1rem;
}

.detail-list div,
.label-card dl div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 0.8rem;
}

.detail-list dt,
.label-card dt {
  color: var(--muted);
  font-weight: 800;
}

.detail-list dd,
.label-card dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.qr-panel {
  text-align: center;
}

.qr-panel img {
  width: 220px;
  height: 220px;
  margin: 0 auto 0.7rem;
}

.qr-panel strong,
.qr-panel small {
  display: block;
}

.label-page {
  background: #fff;
}

.label-sheet {
  width: min(760px, calc(100% - 2rem));
  margin: 2rem auto;
}

.label-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 1.2rem;
  align-items: center;
  border: 2px solid #111;
  border-radius: 8px;
  padding: 1.2rem;
  background: #fff;
  color: #111;
}

.label-card p {
  margin-bottom: 0.2rem;
  font-weight: 900;
  text-transform: uppercase;
}

.label-card h1 {
  font-size: 3rem;
}

.label-card h2 {
  margin-top: 0.45rem;
}

.label-card dl {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.45rem;
  margin: 0;
}

.print-actions {
  display: flex;
  gap: 0.65rem;
  justify-content: center;
  margin-top: 1rem;
}

@media (max-width: 980px) {
  .topbar,
  .toolbar,
  .filters,
  .edit-layout,
  .detail-layout,
  .scan-layout,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: 1fr;
    min-height: auto;
    align-items: stretch;
  }

  .nav,
  .userbar {
    justify-content: flex-start;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .stats-grid,
  .focus-grid,
  .article-grid,
  .quality-grid,
  .notification-grid,
  .user-grid,
  .price-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat--wide {
    grid-column: span 1;
  }

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

@media (max-width: 760px) {
  body {
    font-size: 15px;
  }

  h1 {
    font-size: 1.48rem;
  }

  h2 {
    font-size: 1.08rem;
  }

  .page {
    width: 100%;
    padding: 0.75rem 0.75rem calc(5rem + env(safe-area-inset-bottom));
  }

  .topbar {
    width: 100%;
    padding: 0.65rem 0.75rem 0.5rem;
    gap: 0.65rem;
  }

  .nav-shell {
    width: 100%;
    padding: 0 0 0.55rem;
  }

  .brand {
    gap: 0.55rem;
  }

  .brand__mark {
    width: 36px;
    height: 36px;
    font-size: 0.92rem;
  }

  .brand strong {
    font-size: 0.98rem;
  }

  .brand small {
    font-size: 0.78rem;
  }

  .global-search {
    min-width: 0;
    width: 100%;
  }

  .nav {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    margin: 0;
    padding: 0 0.75rem 0.15rem;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav__link {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.55rem 0.72rem;
    background: #fff;
  }

  .nav__link.is-active {
    background: var(--surface-2);
  }

  .nav__divider {
    display: none;
  }

  .nav-more__menu,
  .action-menu > div {
    top: 138px;
    left: 0.75rem;
    right: 0.75rem;
    min-width: 0;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .top-actions .button {
    width: 100%;
  }

  .userbar {
    justify-content: space-between;
    gap: 0.8rem;
    padding-top: 0;
    border-top: 1px solid var(--line);
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
    margin: 0.25rem 0 0.9rem;
  }

  .page-head .button,
  .head-actions .button,
  .head-actions .inline-form {
    width: 100%;
  }

  .head-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .action-menu,
  .action-menu summary {
    width: 100%;
  }

  .quick-panel__head {
    display: grid;
  }

  .stats-grid {
    gap: 0.65rem;
  }

  .stat {
    min-height: 86px;
    padding: 0.78rem;
  }

  .stat span {
    margin-bottom: 0.35rem;
    font-size: 0.84rem;
  }

  .stat strong {
    font-size: 1.25rem;
  }

  .toolbar,
  .filters {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .filters,
  .form-panel,
  .empty-state {
    padding: 0.85rem;
  }

  .setup,
  .login {
    min-height: calc(100vh - 1.5rem);
    padding: 0;
    place-items: start stretch;
  }

  .setup__panel,
  .login__panel {
    padding: 1rem;
    box-shadow: none;
  }

  .setup__header {
    align-items: flex-start;
  }

  .setup__header h1 {
    font-size: 1.28rem;
  }

  .filter-actions,
  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .market-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .searchbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .bulkbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .bulkbar .button {
    width: 100%;
  }

  .bulkbar span {
    order: -1;
    font-size: 0.86rem;
  }

  .segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .segmented a {
    min-width: 0;
    padding: 0.6rem 0.4rem;
    font-size: 0.88rem;
    text-align: center;
  }

  .article-card__body {
    padding: 0.8rem;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .data-table {
    display: block;
    min-width: 0;
    border-collapse: separate;
  }

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

  .data-table--compact thead {
    display: table-header-group;
  }

  .data-table--compact tbody {
    display: table-row-group;
  }

  .data-table--compact tr {
    display: table-row;
    border: 0;
    border-radius: 0;
    padding: 0;
    background: transparent;
  }

  .data-table--compact td,
  .data-table--compact th {
    display: table-cell;
    padding: 0.65rem;
    border-bottom: 1px solid var(--line);
  }

  .data-table--compact td::before {
    content: none;
  }

  .data-table--compact td > * {
    grid-column: auto;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody {
    display: grid;
    gap: 0.75rem;
  }

  .data-table tr {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 0.35rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.75rem;
    background: var(--surface);
  }

  .data-table td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    align-items: start;
    gap: 0.5rem;
    padding: 0;
    border-bottom: 0;
  }

  .data-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
  }

  .data-table td > * {
    grid-column: 2;
  }

  .data-table td:nth-child(3),
  .data-table td:nth-child(4),
  .data-table td:nth-child(5),
  .data-table td:nth-child(6),
  .data-table td:nth-child(7),
  .data-table td:nth-child(8) {
    grid-column: 2;
  }

  .data-table .select-cell {
    grid-column: 1;
    grid-row: 1;
    width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .data-table .select-cell::before,
  .data-table .thumb-cell::before,
  .data-table .row-actions::before {
    display: none;
  }

  .data-table .thumb-cell {
    grid-column: 1;
    grid-row: 2 / span 4;
    width: auto;
    display: block;
  }

  .thumb {
    width: 76px;
    height: 76px;
  }

  .data-table .row-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
    margin-top: 0.35rem;
    white-space: normal;
  }

  .data-table .row-actions .button {
    width: 100%;
  }

  .calendar-item {
    grid-template-columns: 1fr;
  }

  .detail-layout {
    gap: 0;
  }

  .detail-side {
    order: -1;
  }

  .gallery a,
  .gallery__empty,
  .gallery img {
    min-height: 150px;
  }

  .detail-list {
    gap: 0.55rem;
  }

  .detail-list div,
  .label-card dl div {
    grid-template-columns: 1fr;
    gap: 0.15rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--line);
  }

  .detail-list div:last-child,
  .label-card dl div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .qr-panel img {
    width: 180px;
    height: 180px;
  }

  .copy-text {
    min-height: 180px;
    font-size: 0.9rem;
  }

  .copy-text--short {
    min-height: 58px;
  }

  .copy-text--medium {
    min-height: 112px;
  }

  .upload-box {
    min-height: 118px;
    padding: 0.9rem;
  }

  .manual-scan {
    grid-template-columns: 1fr;
  }

  .scan-box video {
    min-height: 220px;
  }

  .sticky-actions {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0.55rem;
    box-shadow: var(--shadow);
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 1rem, 1280px);
    padding-top: 0.75rem;
  }

  h1 {
    font-size: 1.55rem;
  }

  fieldset,
  .form-grid,
  .stats-grid,
  .price-summary,
  .focus-grid,
  .article-grid,
  .quality-grid,
  .preview-grid,
  .image-grid,
  .gallery,
  .label-card {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .searchbar,
  .bulkbar,
  .segmented,
  .head-actions,
  .sticky-actions {
    width: 100%;
  }

  .searchbar,
  .bulkbar,
  .head-actions,
  .sticky-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .segmented a {
    flex: 1;
    text-align: center;
  }

  .quality-tabs {
    display: grid;
    grid-template-columns: 1fr;
  }

  .market-links {
    grid-template-columns: 1fr;
  }

  .notification-grid {
    grid-template-columns: 1fr;
  }

  .user-grid {
    grid-template-columns: 1fr;
  }

  .label-card h1 {
    font-size: 2.2rem;
  }
}

@media print {
  body {
    background: #fff;
  }

  .print-actions {
    display: none;
  }

  .label-sheet {
    width: 100%;
    margin: 0;
  }

  .label-card {
    break-inside: avoid;
  }
}
