:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #fbfbfd;
  --surface-elevated: rgba(255, 255, 255, 0.86);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --muted-strong: #424245;
  --line: #d2d2d7;
  --line-soft: #ececf0;
  --primary: #0071e3;
  --primary-dark: #005bbd;
  --primary-soft: #eaf3ff;
  --good: #248a3d;
  --good-soft: #eaf7ee;
  --bad: #d70015;
  --bad-soft: #fff1f2;
  --warning: #b7791f;
  --warning-soft: #fff8e6;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  padding-bottom: 96px;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.menu-open {
  overflow: hidden;
}

body.menu-open::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #f7f7fa;
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid rgba(210, 210, 215, 0.72);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.85) inset;
  backdrop-filter: saturate(180%) blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0;
  font-size: 18px;
  font-weight: 850;
  color: var(--text);
}

.brand img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.brand span {
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.mobile-nav-head,
.nav-overlay,
.nav-close {
  display: none;
}

.app-nav a {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 10px;
  border-radius: var(--radius);
  transition: background 0.16s ease, color 0.16s ease;
}

.app-nav a:hover {
  background: rgba(0, 113, 227, 0.08);
  color: var(--primary);
}

.menu-toggle {
  display: none;
  align-items: center;
  gap: 5px;
  min-height: 38px;
  padding: 0 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.menu-toggle .menu-lines span {
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.menu-lines {
  display: grid;
  gap: 3px;
}

.menu-lines span {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
}

.menu-toggle strong {
  margin-left: 3px;
  font-size: 13px;
}

.logout-form {
  margin: 0;
}

.logout-form button {
  min-height: 32px;
  padding: 0 10px;
  background: var(--surface-soft);
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.page {
  width: min(1440px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.home-welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding: 10px 2px 4px;
}

.home-welcome h1 {
  margin: 6px 0 4px;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.1;
}

.home-welcome p {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

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

.home-menu-card {
  position: relative;
  display: grid;
  min-height: 178px;
  align-content: end;
  gap: 8px;
  overflow: hidden;
  padding: 24px;
  background:
    radial-gradient(circle at var(--glow-x, 12%) var(--glow-y, 12%), rgba(0, 113, 227, 0.11), transparent 32%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(246, 247, 250, 0.96)),
    var(--surface);
  border: 1px solid rgba(205, 205, 212, 0.82);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.07);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.home-menu-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, #1d1d1f, #7a7a80);
}

.home-menu-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.38), transparent 42%);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.home-menu-card:hover {
  transform: translateY(-3px);
  border-color: rgba(0, 113, 227, 0.32);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.12);
}

.home-menu-card:hover::after {
  opacity: 1;
}

.primary-menu-card::before {
  background: linear-gradient(90deg, #005bbd, #67b7ff);
}

.admin-menu-card::before {
  background: linear-gradient(90deg, #1f7a4d, #b7a06a);
}

.menu-code {
  position: absolute;
  top: 18px;
  right: 20px;
  color: rgba(29, 29, 31, 0.16);
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.home-menu-card strong {
  position: relative;
  z-index: 1;
  font-size: clamp(21px, 3.8vw, 26px);
  line-height: 1.15;
}

.home-menu-card > span:last-child {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.45;
}

.home-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 28px;
  overflow: hidden;
  min-height: 280px;
  align-items: center;
  margin-bottom: 16px;
  padding: 34px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(245, 245, 247, 0.92)),
    var(--surface);
}

.home-hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -38% 35%;
  height: 180px;
  background: linear-gradient(90deg, rgba(0, 113, 227, 0.13), rgba(36, 138, 61, 0.09));
  border-radius: 999px;
  filter: blur(48px);
  pointer-events: none;
}

.home-hero-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  max-width: 760px;
}

.eyebrow,
.action-kicker {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.home-hero h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.08;
}

.home-hero p {
  max-width: 620px;
  margin: 0;
  color: var(--muted-strong);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.65;
}

.home-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.home-hero-mark {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
}

.home-hero-mark img {
  width: min(190px, 34vw);
  opacity: 0.92;
}

.home-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.premium-action {
  min-height: 160px;
  align-content: start;
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 160px);
  place-items: center;
}

.login-panel {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 28px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  justify-self: center;
  margin-bottom: -2px;
}

.login-panel h1 {
  margin: 0 0 6px;
  text-align: center;
}

.login-panel p {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.login-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  padding: 2px 0;
}

.login-options label {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted-strong);
  font-size: 14px;
  font-weight: 800;
}

.login-save-note {
  margin-top: -6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.form-error {
  padding: 10px 12px;
  background: var(--bad-soft);
  border: 1px solid #ffb3bd;
  border-radius: var(--radius);
  color: var(--bad);
  font-weight: 800;
}

.form-message {
  padding: 10px 12px;
  background: var(--good-soft);
  border: 1px solid #b9e7c5;
  border-radius: var(--radius);
  color: var(--good);
  font-weight: 800;
}

.form-help {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  background: var(--primary-soft);
  border: 1px solid #b7d7ff;
  border-radius: var(--radius);
  color: var(--muted-strong);
}

.form-help strong {
  color: var(--primary);
  font-size: 13px;
}

.form-help p {
  margin: 0;
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.5;
}

.agreement-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.agreement-box p {
  margin: 0;
  font-size: 13px;
}

.inline-check {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.users-table-wrap input,
.users-table-wrap select {
  width: 100%;
  min-height: 34px;
  padding: 0 8px;
  font-size: 13px;
}

.user-filter-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.user-filter-panel form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px) auto;
  gap: 12px;
  align-items: end;
}

.quick-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-filters a {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.quick-filters a.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

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

.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.profile-card {
  margin-bottom: 0;
}

.profile-card-head {
  display: grid;
  gap: 4px;
}

.profile-card-head h2 {
  margin: 0;
  font-size: 18px;
}

.profile-card-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.profile-alert {
  margin-bottom: 14px;
}

.action-card,
.panel {
  background: var(--surface-elevated);
  border: 1px solid rgba(210, 210, 215, 0.74);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  backdrop-filter: saturate(160%) blur(10px);
}

.action-card {
  display: grid;
  gap: 10px;
  padding: 28px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.action-card:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 113, 227, 0.34);
  box-shadow: var(--shadow-md);
}

.action-card strong {
  font-size: 22px;
}

.action-card span,
.section-head p {
  color: var(--muted);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 18px;
}

.section-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.section-head h1 {
  margin: 0 0 6px;
  letter-spacing: 0;
  font-size: 30px;
  font-weight: 850;
}

.section-head p {
  margin: 0;
}

.order-layout {
  display: grid;
  gap: 16px;
}

.order-layout > *,
.recommendation-panel,
.table-wrap {
  min-width: 0;
}

.form-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

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

input,
select,
button,
textarea {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, transform 0.12s ease;
}

input,
select,
textarea {
  background: rgba(255, 255, 255, 0.94);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.14);
  outline: 0;
}

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

input[type="checkbox"] {
  min-height: 18px;
  width: 18px;
  padding: 0;
}

.summary-bar,
.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(180px, auto);
  gap: 12px;
  align-items: stretch;
}

.detail-summary {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 16px;
}

.filters {
  grid-template-columns: 2fr 1fr;
}

.summary-bar > div {
  display: grid;
  gap: 4px;
  padding: 14px;
  background: var(--surface-elevated);
  border: 1px solid rgba(210, 210, 215, 0.74);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.summary-bar span {
  color: var(--muted);
  font-size: 13px;
}

.summary-bar strong {
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}

.floating-summary {
  position: fixed;
  right: 18px;
  bottom: 18px;
  left: 18px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: auto;
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px;
  background: rgba(29, 29, 31, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.24);
  backdrop-filter: saturate(180%) blur(18px);
}

.floating-summary div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.floating-summary span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 850;
}

.floating-summary strong {
  color: #ffffff;
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

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

.chart-panel {
  padding: 16px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 14px;
}

.chart-head h2 {
  margin: 0;
  font-size: 18px;
}

.chart-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 150px) minmax(120px, 1fr) minmax(90px, auto);
  gap: 10px;
  align-items: center;
  min-height: 30px;
}

.bar-label {
  overflow: hidden;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 14px;
  overflow: hidden;
  background: #e9e9ed;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.bar-fill.alt {
  background: #5856d6;
}

.bar-row strong {
  text-align: right;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.compact-head {
  margin-top: 8px;
}

.summary-card {
  display: grid;
  gap: 6px;
  min-height: 86px;
  padding: 14px;
  background: var(--surface-elevated);
  border: 1px solid rgba(210, 210, 215, 0.74);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

a.summary-card {
  color: var(--text);
}

.summary-card.attention {
  border-color: #f4c35d;
  background: var(--warning-soft);
}

.summary-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.summary-card strong {
  font-size: 20px;
}

.summary-card .compact-value {
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.35;
}

.danger-text {
  color: var(--danger);
}

.template-output-card {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.template-output-card div {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.template-output-card span:first-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.template-output-card strong {
  overflow-wrap: anywhere;
  font-size: 18px;
}

.template-output-card p {
  margin: 0;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
}

.status-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  background: #f2f2f7;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 800;
}

.sheet-chip-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sheet-chip-list .status-chip {
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 8px 18px rgba(0, 113, 227, 0.18);
}

.secondary {
  background: #f5f5f7;
  border-color: #d6d6dc;
  color: var(--muted-strong);
  font-weight: 800;
  cursor: pointer;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: var(--radius);
  padding: 0 12px;
}

.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.secondary:hover,
.menu-toggle:hover,
.logout-form button:hover {
  background: #e9e9ed;
  transform: translateY(-1px);
}

.danger {
  background: #b42318;
  border-color: #b42318;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.danger:hover {
  background: #9f1f16;
  transform: translateY(-1px);
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  background: var(--surface-elevated);
  border: 1px solid rgba(210, 210, 215, 0.74);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  backdrop-filter: saturate(160%) blur(10px);
}

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

.actions-cell form {
  margin: 0;
}

.products-edit-table {
  min-width: 0;
  table-layout: fixed;
}

.products-edit-table th,
.products-edit-table td {
  padding: 7px 6px;
  font-size: 12px;
  vertical-align: middle;
}

.products-edit-table .actions-cell {
  justify-content: flex-start;
  min-width: 0;
}

.order-col-select {
  width: 7%;
}

.order-col-category {
  width: 14%;
}

.order-col-name {
  width: 35%;
}

.order-col-money {
  width: 16%;
}

.order-col-qty {
  width: 12%;
}

.product-col-id {
  width: 4%;
}

.product-col-category {
  width: 9%;
}

.product-col-name {
  width: 27%;
}

.product-col-money {
  width: 10%;
}

.product-col-grade {
  width: 3.8%;
}

.product-col-small {
  width: 7%;
}

.product-col-check {
  width: 6%;
}

.product-col-status {
  width: 6%;
}

.product-col-actions {
  width: 14%;
}

.inactive-row {
  background: #f8f8fa;
}

.inactive-row .inline-input,
.inactive-row .inline-number,
.inactive-row .inline-select {
  color: var(--muted);
}

.inline-input,
.inline-number,
.inline-select {
  width: 100%;
  min-height: 30px;
  border-radius: var(--radius);
  padding: 0 6px;
  background: #fff;
  font-size: 12px;
}

.edit-field,
.save-product-button,
.cancel-product-button {
  display: none;
}

.product-row.editing {
  background: var(--primary-soft);
}

.product-row.editing .read-value,
.product-row.editing .edit-product-button {
  display: none;
}

.product-row.editing .edit-field,
.product-row.editing .save-product-button,
.product-row.editing .cancel-product-button {
  display: inline-flex;
}

.product-row.editing input.edit-field,
.product-row.editing select.edit-field {
  display: inline-block;
}

.product-row.editing input[type="checkbox"].edit-field {
  display: inline-block;
}

.category-input {
  width: 100%;
}

.product-name-input {
  min-width: 0;
}

.money-input {
  width: 100%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.qty-input,
.row-input {
  width: 100%;
  text-align: right;
}

.grade-input {
  width: 100%;
}

.check-cell {
  text-align: center;
}

.check-cell input {
  vertical-align: middle;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
}

.status-pill.on {
  background: var(--good-soft);
  color: var(--good);
}

.status-pill.off {
  background: #efeff4;
  color: var(--muted);
}

.edit-form,
.upload-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
  margin-bottom: 16px;
}

.import-panel {
  padding: 14px;
  margin-bottom: 16px;
}

.filter-panel {
  padding: 14px;
  margin-bottom: 16px;
}

.filter-panel form {
  display: grid;
  grid-template-columns: 2fr repeat(3, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.product-filter-panel form {
  grid-template-columns: 2fr minmax(140px, 1fr) minmax(140px, 1fr) auto;
}

.dashboard-filter form {
  grid-template-columns: repeat(2, minmax(180px, 240px)) auto;
}

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

.import-panel form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.upload-form {
  padding: 0;
  margin: 0;
}

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

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

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.checkbox-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.order-management {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  padding: 18px;
  margin-bottom: 16px;
}

.order-management form:first-child {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
}

.order-management form:last-child {
  display: flex;
  justify-content: flex-end;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: normal;
  word-break: keep-all;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(245, 245, 247, 0.96);
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 850;
  backdrop-filter: saturate(160%) blur(10px);
}

tbody tr:hover {
  background: rgba(0, 113, 227, 0.035);
}

.name-cell {
  white-space: normal;
  min-width: 0;
}

.memo-cell {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.compact-input {
  width: 82px;
  min-height: 34px;
}

.recommendations,
.recommendation-panel {
  display: grid;
  gap: 14px;
}

.recommendation-panel,
.recommendation-empty {
  padding: 16px;
}

.recommendation-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.recommendation-head h2,
.selected-plan-summary h3 {
  margin: 0;
}

.recommendation-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.comparison-wrap,
.plan-detail-wrap {
  border-radius: var(--radius);
}

.comparison-table,
.plan-detail-table {
  min-width: 0;
}

@media (max-width: 900px) {
  .table-wrap {
    overflow: visible;
  }

  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap th,
  .table-wrap td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody {
    display: grid;
    gap: 10px;
    padding: 10px;
  }

  .table-wrap tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-elevated);
    box-shadow: var(--shadow-sm);
  }

  .table-wrap td {
    display: grid;
    grid-template-columns: minmax(96px, 34%) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 40px;
    border-bottom: 1px solid var(--line-soft);
    white-space: normal;
  }

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

  .table-wrap td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .table-wrap td.empty {
    display: block;
  }

  .table-wrap td.empty::before {
    display: none;
  }

  .table-wrap td.actions-cell {
    display: grid;
    grid-template-columns: minmax(96px, 34%) minmax(0, 1fr);
  }

  .actions-cell > a,
  .actions-cell > button {
    grid-column: 2;
    width: 100%;
  }

  .products-edit-table {
    min-width: 0;
  }

  .category-input,
  .product-name-input,
  .money-input,
  .qty-input,
  .row-input,
  .grade-input,
  .compact-input {
    width: 100%;
    min-width: 0;
  }

  .product-row.editing .edit-field,
  .product-row.editing .save-product-button,
  .product-row.editing .cancel-product-button {
    width: 100%;
  }

  .product-row.editing input[type="checkbox"].edit-field {
    width: 18px;
  }

  .comparison-table,
  .plan-detail-table {
    min-width: 0;
  }

  .product-picker,
  .product-master-wrap {
    overflow-x: hidden;
    overflow-y: visible;
  }

  .product-picker table,
  .product-master-wrap table {
    display: table;
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
  }

  .product-picker table {
    min-width: 0;
  }

  .product-master-wrap table {
    min-width: 0;
  }

  .product-picker thead,
  .product-master-wrap thead {
    display: table-header-group;
  }

  .product-picker tbody,
  .product-master-wrap tbody {
    display: table-row-group;
    padding: 0;
  }

  .product-picker tr,
  .product-master-wrap tr {
    display: table-row;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .product-picker th,
  .product-picker td,
  .product-master-wrap th,
  .product-master-wrap td {
    display: table-cell;
    width: auto;
    min-width: 0;
    min-height: 0;
    padding: 7px 6px;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    vertical-align: middle;
    white-space: normal;
  }

  .product-picker th,
  .product-master-wrap th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(245, 245, 247, 0.96);
  }

  .product-picker td::before,
  .product-master-wrap td::before {
    content: none;
  }

  .product-picker .name-cell,
  .product-master-wrap .name-cell {
    min-width: 0;
  }

  .product-master-wrap .actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
  }

  .product-master-wrap .actions-cell > button {
    grid-column: auto;
    min-height: 30px;
    width: auto;
    padding: 0 7px;
    font-size: 12px;
  }

  .product-picker .compact-input,
  .product-master-wrap .inline-input,
  .product-master-wrap .inline-number,
  .product-master-wrap .inline-select {
    min-height: 30px;
    font-size: 12px;
  }

  .product-picker col.order-col-category,
  .product-picker th:nth-child(2),
  .product-picker td:nth-child(2),
  .product-master-wrap col.product-col-id,
  .product-master-wrap col.product-col-category,
  .product-master-wrap col.product-col-check,
  .product-master-wrap th:nth-child(1),
  .product-master-wrap td:nth-child(1),
  .product-master-wrap th:nth-child(2),
  .product-master-wrap td:nth-child(2),
  .product-master-wrap th:nth-child(8),
  .product-master-wrap td:nth-child(8) {
    display: none;
  }

  .product-picker .order-col-select {
    width: 8%;
  }

  .product-picker .order-col-name {
    width: 38%;
  }

  .product-picker .order-col-money {
    width: 18%;
  }

  .product-picker .order-col-qty {
    width: 18%;
  }

  .product-picker th,
  .product-picker td,
  .product-master-wrap th,
  .product-master-wrap td {
    overflow-wrap: anywhere;
    padding: 6px 4px;
    font-size: 11px;
  }

  .product-picker .compact-input,
  .product-master-wrap .inline-input,
  .product-master-wrap .inline-number,
  .product-master-wrap .inline-select {
    padding: 0 4px;
    font-size: 11px;
  }

  .product-master-wrap .status-pill {
    min-height: 22px;
    padding: 0 6px;
    font-size: 11px;
  }

  .order-detail-items {
    overflow-x: hidden;
    overflow-y: visible;
  }

  .order-detail-items table {
    display: table;
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    table-layout: fixed;
  }

  .order-detail-items thead {
    display: table-header-group;
  }

  .order-detail-items tbody {
    display: table-row-group;
    padding: 0;
  }

  .order-detail-items tr {
    display: table-row;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .order-detail-items th,
  .order-detail-items td {
    display: table-cell;
    width: auto;
    min-width: 0;
    min-height: 0;
    padding: 7px 4px;
    border-bottom: 1px solid var(--line);
    font-size: 11px;
    line-height: 1.35;
    vertical-align: middle;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .order-detail-items th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(245, 245, 247, 0.96);
  }

  .order-detail-items td::before {
    content: none;
  }

  .order-detail-items .detail-col-category,
  .order-detail-items th:nth-child(1),
  .order-detail-items td:nth-child(1),
  .order-detail-items .detail-col-row,
  .order-detail-items th:nth-child(8),
  .order-detail-items td:nth-child(8) {
    display: none;
  }

  .order-detail-items .detail-col-name {
    width: 34%;
  }

  .order-detail-items .detail-col-money,
  .order-detail-items .detail-col-mileage {
    width: 18%;
  }

  .order-detail-items .detail-col-qty {
    width: 12%;
  }
}

.plan-row {
  cursor: pointer;
}

.plan-row.selected {
  background: var(--primary-soft);
}

.plan-row.selected td {
  border-bottom-color: #b7d7ff;
}

.text-button {
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 800;
  cursor: pointer;
}

.plan-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.plan-actions.horizontal {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
}

.plan-actions.horizontal button {
  width: 260px;
  max-width: calc(100vw - 48px);
}

.selected-plan-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.plan-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ok {
  color: var(--good);
}

.ng {
  color: var(--bad);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px;
}

.pager {
  display: flex;
  justify-content: center;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 900px) {
  .app-header {
    position: sticky;
    top: 0;
    z-index: 80;
    min-height: 58px;
    padding: 10px 16px;
    gap: 10px;
  }

  .app-header.menu-open {
    z-index: 130;
  }

  .brand {
    min-width: 0;
    font-size: 17px;
  }

  .menu-toggle {
    display: inline-flex;
    margin-left: auto;
    position: relative;
    z-index: 86;
    min-width: 44px;
    justify-content: center;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.06);
  }

  .menu-toggle strong {
    display: none;
  }

  .app-header.menu-open .menu-toggle {
    opacity: 0;
    pointer-events: none;
  }

  .nav-overlay {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: block;
    background: #f7f7fa;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    backdrop-filter: none;
  }

  .app-header.menu-open .nav-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .app-nav {
    position: fixed;
    inset: 0;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 120;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: auto;
    padding: 22px 18px max(22px, env(safe-area-inset-bottom));
    background: #f7f7fa;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-16px);
    transition: opacity 0.22s ease, transform 0.22s ease;
    backdrop-filter: none;
  }

  .app-nav::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    background: #f7f7fa;
  }

  .app-nav > * {
    position: relative;
    z-index: 1;
  }

  .app-header.menu-open .app-nav {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .mobile-nav-head {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    padding: max(14px, env(safe-area-inset-top)) 2px 18px;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 8px;
  }

  .mobile-nav-head img {
    width: 42px;
    height: 42px;
    object-fit: contain;
  }

  .mobile-nav-head div {
    display: grid;
    min-width: 0;
    gap: 3px;
  }

  .mobile-nav-head strong {
    color: var(--text);
    font-size: 17px;
    line-height: 1;
  }

  .mobile-nav-head span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .nav-close {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 0;
    background: #f2f2f7;
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    color: var(--muted-strong);
    font-size: 22px;
    line-height: 1;
  }

  .app-nav a,
  .app-nav .logout-form button {
    display: flex;
    width: 100%;
    min-height: 56px;
    align-items: center;
    justify-content: flex-start;
    padding: 0 14px;
    background: #ffffff;
    border: 1px solid var(--line-soft);
    border-radius: 0;
    color: var(--text);
    font-size: 15px;
    font-weight: 850;
    box-shadow: none;
  }

  .app-nav a + a,
  .app-nav a + .logout-form,
  .app-nav .mobile-nav-head + a {
    border-top-color: transparent;
  }

  .app-nav a:first-of-type {
    border-radius: 12px 12px 0 0;
  }

  .app-nav a:hover,
  .app-nav .logout-form button:hover {
    background: var(--surface);
    border-color: rgba(0, 113, 227, 0.16);
    color: var(--primary);
    transform: translateY(-1px);
  }

  .logout-form {
    margin-top: auto;
    padding-top: 10px;
    width: 100%;
  }

  .app-nav .logout-form button {
    justify-content: center;
    background: #f8f8fa;
    border-radius: 12px;
    color: var(--muted-strong);
  }

  .home-grid,
  .home-hero,
  .home-status,
  .form-panel,
  .edit-form,
  .upload-form,
  .summary-bar,
  .detail-summary,
  .history-summary,
  .dashboard-grid,
  .filters {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .template-output-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .import-panel form {
    grid-template-columns: 1fr;
  }

  .filter-panel form {
    grid-template-columns: 1fr;
  }

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

  .filter-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .order-management,
  .order-management form:first-child {
    grid-template-columns: 1fr;
  }

  .recommendation-head,
  .selected-plan-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .plan-actions.horizontal {
    width: 100%;
  }

  .plan-actions.horizontal button {
    width: 100%;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .bar-row strong {
    text-align: left;
  }

  .floating-summary {
    right: 12px;
    bottom: 12px;
    left: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: auto;
  }

  .floating-summary strong {
    font-size: clamp(19px, 5vw, 26px);
  }

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

@media (max-width: 560px) {
  .home-menu-grid {
    grid-template-columns: 1fr;
  }
}
