:root {
  --black: #111111;
  --ink: #201f1b;
  --muted: #6d675d;
  --line: #d8cfbd;
  --cream: #f6efe1;
  --paper: #fffaf0;
  --gold: #b68a2f;
  --gold-dark: #7f5c18;
  --white: #ffffff;
  --danger: #9d2c21;
  --ok: #2d6540;
  --warn-bg: #fff4cf;
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

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

.sidebar {
  background: var(--black);
  color: var(--white);
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  border: 1px solid var(--gold);
  display: grid;
  place-items: center;
  color: var(--gold);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #c9b98e;
  font-size: 12px;
  margin-top: 2px;
}

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

.nav button {
  border: 1px solid #39352d;
  background: transparent;
  color: #f4ecdb;
  text-align: left;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 2px;
}

.nav button:hover,
.nav button.is-active {
  border-color: var(--gold);
  background: #211d16;
  color: var(--white);
}

.sidebar-note {
  margin-top: auto;
  color: #c9b98e;
  font-size: 12px;
}

.sidebar-note p {
  margin: 0 0 8px;
}

.main {
  min-width: 0;
  padding: 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.25;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
}

h2 {
  font-size: 18px;
}

.top-actions,
.inline-actions,
.form-actions,
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 16px;
}

.button {
  min-height: 40px;
  border: 1px solid var(--black);
  border-radius: 2px;
  padding: 9px 13px;
  background: var(--white);
  color: var(--black);
  font-weight: 700;
}

.button-dark {
  background: var(--black);
  color: var(--white);
}

.button-gold {
  background: var(--gold);
  border-color: var(--gold-dark);
  color: var(--black);
}

.button-ghost {
  background: transparent;
  border-color: var(--line);
}

.status {
  min-height: 26px;
  color: var(--muted);
  margin: 0 0 18px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

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

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

.metric {
  padding: 18px;
  box-shadow: 0 1px 0 rgba(17, 17, 17, .04);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
  line-height: 1.1;
}

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

.metric-date {
  font-size: 14px !important;
  line-height: 1.45 !important;
}

.panel {
  padding: 20px;
}

.layout-two,
.layout-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.layout-editor {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.activity-list,
.plain-list {
  margin: 0;
  padding-left: 1.2em;
}

.activity-list li,
.plain-list li {
  margin: 8px 0;
}

.form-grid,
.editor {
  display: grid;
  gap: 13px;
}

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

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

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

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 1px;
  background: var(--white);
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
}

tbody tr:nth-child(even) {
  background: #fffdf7;
}

tbody tr:hover {
  background: #fbf2de;
}

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

th {
  background: #161616;
  color: var(--white);
  white-space: nowrap;
}

td {
  max-width: 280px;
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.tiny-button {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 2px;
  padding: 5px 8px;
  font-size: 12px;
}

.tiny-button:hover {
  border-color: var(--gold);
}

.badge {
  display: inline-block;
  min-width: 70px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge-ok {
  border-color: var(--ok);
  color: var(--ok);
}

.badge-warn {
  border-color: var(--gold-dark);
  color: var(--gold-dark);
}

.badge-off {
  border-color: var(--muted);
  color: var(--muted);
}

.priority {
  min-width: 42px;
}

.priority-high {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff1ed;
}

.priority-mid {
  border-color: var(--gold-dark);
  color: var(--gold-dark);
  background: var(--warn-bg);
}

.priority-low {
  border-color: var(--muted);
  color: var(--muted);
  background: #f5f0e6;
}

.needs-check {
  display: inline-block;
  border: 1px solid var(--gold-dark);
  background: var(--warn-bg);
  color: var(--gold-dark);
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
}

.panel-note {
  margin: -6px 0 14px;
  color: var(--muted);
}

.json-preview {
  min-height: 560px;
  max-height: 68vh;
  overflow: auto;
  margin: 0;
  padding: 16px;
  background: #111111;
  color: #f8efd9;
  border: 1px solid #302a1d;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.instruction-output {
  min-height: 620px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.6;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .layout-two,
  .layout-editor {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    padding: 18px;
  }

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

  .main {
    padding: 22px 16px;
  }

  .topbar,
  .panel-head,
  .top-actions,
  .inline-actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .form-grid,
  .form-grid.compact {
    grid-template-columns: 1fr;
  }
}

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

  .metric {
    padding: 15px;
  }

  th,
  td {
    font-size: 12px;
  }
}
