:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #19202a;
  --border: #d9e0eb;
  --accent: #1976d2;
  --error: #d32f2f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

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

.main-nav {
  display: flex;
  gap: 10px;
}

.logout-form {
  margin-left: 10px;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #4a5568;
}

.main-nav a.active {
  background: #e9f3ff;
  color: #0f4f97;
}

.nav-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.container {
  max-width: 1100px;
  margin: 20px auto;
  padding: 0 16px 24px;
}

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

.alert {
  background: #e8f2ff;
  border: 1px solid #b4d2f7;
  color: #184c89;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.alert-error {
  background: #ffebee;
  border-color: #f5b5bb;
  color: var(--error);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
}

table {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  border-collapse: collapse;
  overflow: hidden;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 12px;
  font-weight: 600;
}

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

.orders-table .order-row-completed td {
  background: #fafafa;
}

.badge {
  background: #e9f3ff;
  border: 1px solid #c9defa;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.badge-stock-out {
  background: #efefef;
  border-color: #d9d9d9;
  color: #4d4d4d;
}

.inline-form,
.stack-form,
.bulk-actions {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

.stack-form {
  flex-direction: column;
  align-items: stretch;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

input,
select,
button {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.pagination {
  margin-top: 14px;
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.summary-number {
  font-size: 28px;
  font-weight: 700;
  margin: 8px 0 0;
}

.bar-wrap {
  margin-top: 6px;
  height: 8px;
  background: #edf2fb;
  border-radius: 999px;
  overflow: hidden;
}

.bar {
  height: 100%;
  border-radius: 999px;
}

.bar.sales {
  background: #1f78d1;
}

.bar.orders {
  background: #13a27a;
}

.meta-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.order-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
}

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

.order-item img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.order-item-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px dashed var(--border);
  font-size: 10px;
  color: #6b7b91;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fbff;
}

.line-item-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.text-xs {
  font-size: 12px;
  line-height: 1.4;
}

.shipping-address {
  margin: 10px 0 14px;
}

.order-info p {
  margin: 4px 0;
  line-height: 1.35;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 18px;
  width: min(92vw, 360px);
}

.modal p {
  margin: 0 0 14px;
}

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

button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.hidden {
  display: none;
}

.auth-container {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(440px, 100%);
}

@media (max-width: 768px) {
  .orders-table .purchase-col {
    display: none;
  }
  .products-table .product-name-col {
    width: 40%;
  }
  .container {
    padding-bottom: 84px;
  }
  .topbar {
    padding: 10px 14px;
  }
  .topbar h1 {
    font-size: 16px;
  }
  .logout-form {
    margin-left: 0;
  }
  .logout-form button {
    font-size: 12px;
    padding: 6px 8px;
  }
  .main-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    border-top: 1px solid var(--border);
    background: #fff;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    padding: 6px 8px 10px;
  }
  .main-nav a {
    justify-content: center;
    padding: 10px 0;
  }
  .main-nav .nav-label {
    display: none;
  }
  .nav-icon {
    width: 20px;
    height: 20px;
  }
  .nav-icon svg {
    width: 20px;
    height: 20px;
  }
  .report-summary {
    grid-template-columns: 1fr;
  }
}
