:root {
  --bg: #f6f7f4;
  --ink: #18201d;
  --muted: #6b746f;
  --line: #d9dfda;
  --panel: #ffffff;
  --accent: #176b4d;
  --accent-dark: #0f4f39;
  --warn: #fff2d6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Malgun Gothic", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}
.brand { font-weight: 800; color: var(--accent-dark); white-space: nowrap; }
nav { display: flex; flex-wrap: wrap; gap: 10px; flex: 1; }
nav a { color: var(--muted); font-weight: 650; }
nav a:hover { color: var(--accent); }
.container { max-width: 1760px; margin: 0 auto; padding: 24px; }
h1 { font-size: 26px; margin: 0 0 18px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.panel, .login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}
.login-panel { max-width: 420px; margin: 80px auto; }
.stack { display: grid; gap: 12px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.master-flow { display: grid; gap: 24px; }
.master-section { width: 100%; overflow: visible; }
.section-head, .page-head { margin-bottom: 14px; }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.metric span { display: block; color: var(--muted); margin-bottom: 8px; }
.metric strong { font-size: 28px; }
.grid-form, .wide-form, .inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.master-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 10px;
  align-items: start;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.manager-form { grid-template-columns: repeat(5, minmax(160px, 1fr)); }
.master-form button { min-width: 88px; }
label { display: grid; gap: 6px; font-weight: 700; }
.compact-label { display: grid; gap: 4px; min-width: 180px; }
.checkbox-label { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-weight: 700; }
.checkbox-label input { min-height: auto; }
input, select, button, .button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
  background: #fff;
}
textarea {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  background: #fff;
  resize: vertical;
}
select[multiple] { min-height: 78px; }
.multi-select { position: relative; min-width: 190px; }
.multi-trigger {
  width: 100%;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  text-align: left;
  font-weight: 700;
}
.multi-menu {
  display: none;
  position: absolute;
  top: 40px;
  left: 0;
  min-width: 220px;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(24, 32, 29, 0.14);
  z-index: 5;
}
.multi-select.open .multi-menu { display: grid; gap: 4px; }
.multi-menu label { display: flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.multi-menu input { min-height: auto; }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; min-height: 22px; }
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #edf4f0;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}
button, .button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
.ghost { background: #fff; color: var(--accent); }
.secondary { background: #fff; color: var(--accent-dark); border-color: var(--line); }
.secondary-link { display: inline-flex; align-items: center; justify-content: center; background: #fff; color: var(--accent-dark); border-color: var(--line); }
.danger-button { background: #9f2f24; border-color: #9f2f24; color: #fff; }
table { width: 100%; border-collapse: collapse; table-layout: auto; min-width: 1100px; }
.table-wrap { width: 100%; overflow-x: auto; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); font-size: 13px; background: #fbfcfb; }
.pill { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 7px; border-radius: 999px; background: #e8f2ed; color: var(--accent-dark); font-size: 12px; font-weight: 800; }
.pill.danger { background: #ecefed; color: #7d2f28; }
.inactive-row { background: #faf7f6; color: #5c6360; }
.muted { color: var(--muted); font-size: 12px; }
.alert { padding: 10px; border-radius: 6px; background: #ffe7e4; color: #8b2018; }
.notice { padding: 10px; border-radius: 6px; background: var(--warn); color: #725000; }
.heading-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.status-row { display: flex; flex-wrap: wrap; gap: 8px; }
.action-row { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; white-space: nowrap; }
.action-row form { margin: 0; }
.action-row .button, .action-row button {
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 12px;
  line-height: 1;
}
.filter-bar { display: flex; gap: 8px; align-items: end; margin: 0 0 16px; }
.text-link { color: var(--accent-dark); font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
.mini-link { min-height: 24px; padding: 3px 7px; font-size: 12px; margin-top: 4px; }
.compact-inline { margin: 0; flex-wrap: nowrap; }
.compact-inline input { width: 120px; }
.compact-inline select { width: 110px; }
.bulk-tools { margin-bottom: 12px; }
.check-col { width: 42px; text-align: center; }
.orders-table { min-width: 1500px; }
.inline-edit-cell { min-width: 430px; }
.inline-order-form {
  display: grid;
  grid-template-columns: 118px 96px 132px minmax(120px, 1fr) 58px;
  gap: 6px;
  align-items: center;
  margin: 0;
}
.inline-order-form input,
.inline-order-form select,
.inline-order-form button {
  min-height: 30px;
  padding: 4px 7px;
  font-size: 12px;
}
.compact-list { margin: 8px 0 12px; padding-left: 18px; color: var(--muted); }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}
.detail-grid > div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}
.detail-grid strong { font-size: 15px; }
.detail-grid small { color: var(--muted); }
.raw-box {
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}
.table-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 10px;
}
.table-tools input, .table-tools select { min-width: 160px; }
@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .container { padding: 16px; }
  .two-col, .metric-grid, .master-form, .manager-form, .detail-grid { grid-template-columns: 1fr; }
  table { white-space: nowrap; }
}
