/* Optitoo toolbox — page chrome, taken from MCPB Forge as it was: base type, the
   top bar, page and panel layout, form fields, tables, badges, empty states,
   notices, toasts and dialog bodies. Link after tokens.css and components.css,
   before a tool's own stylesheet. */

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}

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

h1 {
  font-size: 22px;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 14px;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
}

code,
pre,
.mono {
  font-family: var(--mono);
  font-size: 12px;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -40px;
  z-index: 100;
  padding: 6px 10px;
  color: var(--accent-text);
  background: var(--accent);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 8px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

/* Form controls: the shared ones are sized for OptiChart's dense inspector. */
main input[type="text"],
main input[type="email"],
main input[type="password"],
main input[type="number"],
main input[type="search"],
main input[type="date"],
main select,
main textarea {
  width: 100%;
  min-width: 0;
  padding: 7px 9px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

main input:focus,
main select:focus,
main textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

main input[aria-invalid="true"],
main select[aria-invalid="true"],
main textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

main input:disabled,
main select:disabled,
main textarea:disabled {
  color: var(--text-faint);
  background: var(--surface-sunken);
}

main input[type="checkbox"],
main input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.btn {
  height: 34px;
  text-decoration: none;
  color: var(--text);
}

.btn-primary {
  color: var(--accent-text);
}

.btn-sm {
  height: 28px;
  padding: 0 9px;
  font-size: 13px;
}

.btn-link {
  height: auto;
  padding: 0;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
}

.btn-link:hover {
  background: none;
  border: 0;
}

/* ------------------------------------------------------------- topbar -- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 52px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.topnav {
  display: flex;
  gap: 2px;
  min-width: 0;
  margin-right: auto;
  overflow-x: auto;
}

.topnav a {
  padding: 6px 10px;
  white-space: nowrap;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.topnav a:hover {
  color: var(--text);
  background: var(--surface-sunken);
}

.topnav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-end .icon-btn {
  color: var(--text-dim);
}

/* --------------------------------------------------------------- page -- */

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 16px 64px;
}

main:focus {
  outline: none;
}

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

.page-head .lede {
  margin-top: 4px;
  color: var(--text-dim);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel + .panel,
.section + .section {
  margin-top: 16px;
}

.section h2 {
  margin-bottom: 12px;
}

.muted {
  color: var(--text-dim);
}

.faint {
  /* --text-faint is too light for body text on white (≈3:1); keep 4.5:1. */
  color: var(--text-dim);
}

.small {
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface-sunken);
  border-radius: 999px;
  white-space: nowrap;
}

.badge-accent {
  color: var(--accent);
  background: var(--accent-soft);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12px;
  color: var(--text-dim);
}

.meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.meta .icon {
  width: 14px;
  height: 14px;
}

.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 48px 16px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.empty .icon {
  width: 36px;
  height: 36px;
  color: var(--text-faint);
  stroke-width: 1.3;
}

.empty p {
  max-width: 460px;
  color: var(--text-dim);
}

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

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

th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.table-wrap {
  overflow-x: auto;
}

pre.code {
  max-height: 460px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  color: var(--text);
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  white-space: pre;
}

details > summary {
  cursor: pointer;
  font-weight: 600;
}

details[open] > summary {
  margin-bottom: 10px;
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0;
  font-size: 13px;
}

.kv dt {
  color: var(--text-dim);
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.hint {
  font-size: 12px;
  color: var(--text-dim);
}

.row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.fieldset {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  border: 0;
}

.control {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  align-content: start;
  min-width: 0;
}

.control > label,
.control > .label {
  font-size: 13px;
  font-weight: 600;
}

.control .hint {
  font-size: 12px;
  color: var(--text-dim);
}

.control .req {
  color: var(--danger);
}

.field-error {
  font-size: 12px;
  color: var(--danger);
}

.field-error:empty {
  display: none;
}

.field-warning {
  font-size: 12px;
  color: var(--warn);
}

.field-warning:empty {
  display: none;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  cursor: pointer;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.notice {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}

.notice .icon {
  flex: none;
  color: var(--accent);
}

/* ------------------------------------------------------------ toasts -- */

.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 60;
  display: grid;
  gap: 8px;
  transform: translateX(-50%);
}

.toasts .toast {
  position: static;
  transform: none;
}

/* ---------------------------------------------------------- dialogs -- */

.modal-body {
  display: grid;
  overflow: auto;
  gap: 14px;
  padding: 16px;
}

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

@media (max-width: 760px) {
  main {
    padding: 20px 16px 48px;
  }

  .topbar {
    gap: 8px;
    padding: 0 10px;
  }

  .brand span {
    display: none;
  }

  .topnav a {
    padding: 6px 7px;
    font-size: 13px;
  }

  #user-name,
  .user-name {
    display: none;
  }
}

/* ---------------------------------------------------------- headings -- */

.section-title {
  margin: 24px 0 10px;
  font-size: 15px;
  color: var(--text-dim);
}

.plain-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
}

.plain-list li + li {
  margin-top: 3px;
}
