:root {
  --ink: #171512;
  --muted: #6d665d;
  --paper: #f7f1e8;
  --panel: #fffaf1;
  --line: #2a2722;
  --brass: #bd8d22;
  --green: #136f52;
  --red: #b24131;
  --blue: #295c9b;
  --shadow: rgba(23, 21, 18, .16);
  --mono: "Cascadia Mono", "Consolas", monospace;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    linear-gradient(90deg, rgba(42, 39, 34, .055) 1px, transparent 1px),
    linear-gradient(0deg, rgba(42, 39, 34, .045) 1px, transparent 1px),
    radial-gradient(circle at 78% 22%, rgba(189, 141, 34, .18), transparent 28%),
    var(--paper);
  background-size: 34px 34px, 34px 34px, auto, auto;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 22px;
  align-items: stretch;
}

.shell.result-hidden {
  grid-template-columns: 1fr;
}

.admin-shell {
  grid-template-columns: 430px 1fr;
}

.console,
.result-panel,
.admin-panel {
  border: 2px solid var(--line);
  background: rgba(255, 250, 241, .92);
  box-shadow: 10px 10px 0 var(--shadow);
}

.console,
.admin-panel {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
  overflow: hidden;
}

.console::before,
.admin-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, transparent 0 70%, rgba(19, 111, 82, .07) 70% 100%),
    repeating-linear-gradient(0deg, transparent 0 23px, rgba(23, 21, 18, .035) 24px);
  mix-blend-mode: multiply;
}

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 2px solid var(--line);
  background: #e9dfcf;
}

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

.seal {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fffaf1;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 19px;
  background: var(--ink);
  border: 2px solid var(--ink);
  outline: 2px solid var(--brass);
  outline-offset: -7px;
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(24px, 4vw, 46px);
  line-height: .95;
  letter-spacing: 0;
}

.brand span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
}

.status-pill {
  flex: 0 0 auto;
  padding: 8px 10px;
  color: var(--green);
  border: 2px solid currentColor;
  background: #f3ead6;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.workspace {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 22px;
  align-content: center;
  padding: 30px;
}

.ticket {
  display: grid;
  grid-template-columns: 1fr 92px;
  min-height: 224px;
  border: 2px solid var(--line);
  background: #fff7e7;
}

.ticket-main {
  padding: 24px;
  border-right: 2px dashed var(--line);
}

label,
.field-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.cdk-input,
.text-input,
.json-input {
  width: 100%;
  padding: 14px 16px;
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 0;
  outline: none;
  background: #fffdf7;
  font-family: var(--mono);
  letter-spacing: 0;
  box-shadow: inset 0 0 0 999px transparent;
  transition: box-shadow .2s ease, transform .2s ease;
}

.cdk-input {
  min-height: 72px;
  font-size: clamp(18px, 3.4vw, 32px);
  font-weight: 800;
  text-transform: uppercase;
}

.text-input {
  min-height: 48px;
  font-size: 15px;
}

.json-input {
  min-height: 260px;
  resize: vertical;
  font-size: 13px;
  line-height: 1.55;
}

.cdk-input:focus,
.text-input:focus,
.json-input:focus {
  box-shadow: inset 0 -6px 0 rgba(189, 141, 34, .25);
  transform: translateY(-1px);
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.ticket-side {
  display: grid;
  place-items: center;
  padding: 12px;
  background:
    repeating-linear-gradient(90deg, rgba(23, 21, 18, .09) 0 2px, transparent 2px 9px),
    #eadcc0;
}

.ticket-side span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

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

.btn {
  min-height: 46px;
  padding: 0 17px;
  border: 2px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: #fffaf1;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 4px 4px 0 rgba(23, 21, 18, .18);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 rgba(23, 21, 18, .18);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(23, 21, 18, .18);
}

.btn.primary {
  color: #fffaf1;
  background: var(--green);
}

.btn.danger {
  color: #fffaf1;
  background: var(--red);
}

.message {
  min-height: 24px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.message.ok {
  color: var(--green);
}

.message.bad {
  color: var(--red);
}

.ledger {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 2px solid var(--line);
  background: #eadcc0;
}

.metric {
  padding: 17px;
  border-right: 2px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric b {
  display: block;
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1;
}

.metric span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.result-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: calc(100vh - 56px);
  background: #12100d;
  color: #fff7e7;
  overflow: hidden;
}

.panel-head {
  padding: 17px;
  border-bottom: 2px solid #fff7e7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  letter-spacing: 0;
}

.signal {
  width: 11px;
  height: 11px;
  background: var(--brass);
  box-shadow: 17px 0 0 var(--green), 34px 0 0 var(--blue);
}

.json-wrap {
  margin: 0;
  padding: 19px;
  overflow: auto;
  background:
    linear-gradient(rgba(255, 247, 231, .045) 50%, transparent 50%),
    #12100d;
  background-size: 100% 44px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.panel-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 2px solid #fff7e7;
}

.panel-foot .btn {
  border: 0;
  border-right: 2px solid #fff7e7;
  box-shadow: none;
  background: #242019;
  color: #fff7e7;
}

.panel-foot .btn:last-child {
  border-right: 0;
}

.admin-form {
  display: grid;
  gap: 16px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
}

.cdk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.cdk-table th,
.cdk-table td {
  padding: 11px 10px;
  border-bottom: 1px solid rgba(255, 247, 231, .24);
  text-align: left;
  vertical-align: top;
}

.cdk-table th {
  color: #d5b260;
  font-family: var(--mono);
  text-transform: uppercase;
}

.cdk-table code {
  color: #fff7e7;
  font-family: var(--mono);
}

.badge {
  display: inline-block;
  padding: 3px 7px;
  border: 1px solid currentColor;
  font-family: var(--mono);
  font-size: 11px;
}

.badge.ok {
  color: #8fd0b7;
}

.badge.used {
  color: #e5a08f;
}

.login-card {
  display: grid;
  gap: 12px;
  align-self: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .shell,
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .console,
  .admin-panel,
  .result-panel {
    min-height: auto;
  }

  .result-panel {
    height: 520px;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 18px, 1180px);
    padding: 9px 0;
  }

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

  .workspace {
    padding: 16px;
  }

  .ticket,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .ticket-main {
    border-right: 0;
    border-bottom: 2px dashed var(--line);
    padding: 18px;
  }

  .ticket-side {
    min-height: 54px;
  }

  .ticket-side span {
    writing-mode: horizontal-tb;
    transform: none;
  }

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

  .metric {
    border-right: 0;
    border-bottom: 2px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }
}
