:root {
  --ink: #172026;
  --muted: #66727d;
  --line: #dce3e8;
  --panel: #ffffff;
  --bg: #f4f7f6;
  --nav: #101820;
  --green: #198754;
  --amber: #b7791f;
  --blue: #2f5d8c;
  --red: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}

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

.app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--nav);
  color: #f8fbff;
  padding: 28px 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 36px;
}

.mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: #273747;
  font-weight: 800;
}

.brand p,
.brand h1,
.eyebrow,
.label {
  margin: 0;
}

.brand p,
.eyebrow,
.label {
  color: var(--muted);
  font-size: 12px;
}

.brand p {
  color: #9fb0bd;
}

.brand h1 {
  font-size: 18px;
  letter-spacing: 0;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item,
button,
select,
input,
textarea {
  border-radius: 8px;
}

.nav-item {
  min-height: 44px;
  border: 0;
  color: #dce7ef;
  background: transparent;
  text-align: left;
  padding: 0 14px;
  cursor: pointer;
}

.nav-item.active {
  color: #ffffff;
  background: #2f5d8c;
}

.source-panel {
  display: grid;
  gap: 10px;
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.source-panel a {
  color: #d8eaff;
  font-size: 13px;
  text-decoration: none;
}

.main {
  padding: 28px;
}

.topbar,
.section-head,
.table-toolbar,
.panel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid #f1d28a;
  border-radius: 8px;
  background: #fff8e6;
  color: #5f4310;
  font-size: 13px;
}

.notice span {
  color: #765a20;
}

.topbar h2 {
  margin: 4px 0 0;
  font-size: 26px;
  letter-spacing: 0;
}

.actions {
  display: flex;
  gap: 10px;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
}

.primary-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.icon-button {
  min-width: 58px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 16px;
  margin: 24px 0;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-strip > div {
  display: grid;
  grid-template-columns: 12px auto;
  column-gap: 10px;
  row-gap: 2px;
  min-width: 0;
}

.status-strip p,
.status-strip strong {
  margin: 0;
}

.status-strip p {
  color: var(--muted);
  font-size: 12px;
}

.status-strip strong {
  font-size: 14px;
  line-height: 1.45;
  word-break: keep-all;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 4px;
}

.ok {
  background: var(--green);
}

.warn {
  background: var(--amber);
}

.info {
  background: var(--blue);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  min-height: 132px;
  padding: 18px;
}

.metric p,
.metric span {
  margin: 0;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 28px;
}

.metric.alert strong {
  color: var(--red);
}

.metric.warning strong {
  color: var(--amber);
}

.dashboard-grid,
.integration-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  padding: 18px;
}

.section-head h3 {
  margin: 2px 0 0;
  font-size: 17px;
}

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

.bar-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 120px;
  align-items: center;
  gap: 12px;
}

.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

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

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2f5d8c, #198754);
}

.bar-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.closing-box,
.api-list,
.check-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.closing-box > div,
.api-list > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.closing-box p,
.api-list p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.closing-box strong,
.api-list strong {
  font-size: 17px;
}

.check-list {
  padding-left: 22px;
  line-height: 1.7;
}

.check-list li {
  padding-left: 4px;
}

.table-toolbar {
  margin-bottom: 12px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  background: #ffffff;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

input {
  width: min(420px, 100%);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  background: #f9fbfb;
  font-size: 12px;
  font-weight: 700;
}

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

.status-pill.good {
  color: #14532d;
  background: #dcfce7;
}

.status-pill.need {
  color: #7f1d1d;
  background: #fee2e2;
}

.restock-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.restock-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.restock-card.is-needed {
  border-color: #f1d28a;
  background: #fffaf0;
}

.restock-card p,
.restock-card h4,
.restock-card dl,
.restock-card dd {
  margin: 0;
}

.restock-card p {
  color: var(--muted);
  font-size: 12px;
}

.restock-card h4 {
  margin-top: 3px;
  font-size: 18px;
}

.restock-card dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.restock-card dt {
  color: var(--muted);
  font-size: 12px;
}

.restock-card dd {
  margin-top: 4px;
  font-weight: 700;
}

.restock-card strong {
  color: var(--blue);
}

.memo-box {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.memo-box p {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
  line-height: 1.7;
}

textarea {
  width: 100%;
  min-height: 280px;
  margin-top: 18px;
  padding: 14px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.panel-actions button {
  flex: 1 1 180px;
}

.wide {
  width: 100%;
  margin-top: 16px;
}

dialog {
  width: min(520px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
  background: rgba(16, 24, 32, 0.42);
}

.dialog-body {
  padding: 24px;
}

.dialog-body h3 {
  margin: 0 0 12px;
}

.dialog-body p {
  color: var(--muted);
  line-height: 1.8;
  white-space: pre-line;
}

@media (max-width: 920px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .metrics,
  .dashboard-grid,
  .integration-grid {
    grid-template-columns: 1fr;
  }

  .restock-card dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .table-toolbar,
  .notice {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }
}

@media (max-width: 920px) {
  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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