:root {
  color-scheme: light;
  color: #17263a;
  background: #edf1f6;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  --accent: #0d5c58;
  --border: #dce3ed;
  --secondary: #52647c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
:focus-visible { outline: 3px solid #147a78; outline-offset: 3px; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 4.5vw, 3.15rem); letter-spacing: -.055em; line-height: 1.08; }
h2 { font-size: 1.32rem; letter-spacing: -.03em; }
h3 { font-size: 1.05rem; letter-spacing: -.02em; }
.muted, .lede { color: var(--secondary); line-height: 1.5; }
.muted { font-size: .875rem; }
.lede { margin-top: .7rem; }
.topbar { background: #15283e; color: #f5f8fd; }
.top-inner, main { max-width: 86rem; margin: 0 auto; padding-inline: clamp(1rem, 4vw, 3rem); }
.top-inner { min-height: 4.15rem; display: flex; gap: 1rem; align-items: center; justify-content: space-between; }
.product { font-size: 1.04rem; font-weight: 720; letter-spacing: -.025em; }
.top-actions, .heading-actions { display: flex; align-items: center; gap: .75rem; }
.local, .subtle-link { font-size: .875rem; white-space: nowrap; }
.local { color: #bfd3e6; }
.subtle-link { color: #f4f9ff; text-underline-offset: .2rem; }
main { padding-block: clamp(1.5rem, 4vw, 3.4rem); }
.page-heading, .panel-header, .dialog-heading {
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
}
.primary, .secondary {
  border-radius: .55rem; min-height: 2.65rem; padding: .56rem .9rem;
  font-size: .94rem; font-weight: 650; display: inline-flex; align-items: center;
  justify-content: center; text-decoration: none; border: 1px solid transparent;
}
.primary { color: white; background: var(--accent); }
.primary:hover:not(:disabled) { background: #074742; }
.secondary { color: #253e56; background: #fff; border-color: #cbd6e3; }
.secondary:hover:not(:disabled) { background: #f0f5fa; }
.small { min-height: 2.3rem; font-size: .875rem; padding: .42rem .7rem; }
.overview {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem;
  margin-block: 1.65rem 1.2rem;
}
.overview button {
  border: 1px solid var(--border); border-radius: .65rem; background: #fff;
  color: inherit; padding: .9rem 1.05rem; text-align: left; min-height: 5.4rem;
}
.overview button:hover { background: #f8fbfd; }
.overview button[aria-pressed="true"] { border-color: #2a7974; box-shadow: inset 0 0 0 1px #2a7974; }
.overview span { display: block; min-height: 1.45rem; font-size: .9rem; color: var(--secondary); }
.overview strong { display: block; margin-top: .3rem; font-size: 1.75rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.registry-panel {
  background: white; border: 1px solid var(--border); border-radius: .8rem;
  min-height: 18rem; overflow: hidden;
}
.panel-header { padding: 1.25rem 1.3rem 1rem; }
.panel-header p { margin-top: .17rem; }
.toolbar { display: flex; gap: .8rem; flex-wrap: wrap; align-items: end; padding: 0 1.3rem 1.15rem; }
.toolbar .search { flex: 1 0 14rem; max-width: 26rem; }
.field { display: grid; align-self: start; gap: .32rem; font-size: .9rem; font-weight: 620; }
input, select, textarea {
  border: 1px solid #cbd6e3; border-radius: .45rem; color: #17263a;
  background: #fff; padding: .53rem .65rem; min-height: 2.5rem; font-weight: 430;
}
input[type="file"] { height: auto; }
select {
  appearance: none; padding-right: 2.05rem;
  background-image: linear-gradient(45deg, transparent 50%, #52647c 50%), linear-gradient(135deg, #52647c 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
.registry-panel table { min-width: 55rem; }
th { background: #f1f5f9; color: #40556c; font-size: .87rem; font-weight: 650; }
th, td { padding: .74rem .9rem; border-top: 1px solid #e6ecf3; vertical-align: top; }
td { font-size: .93rem; }
th:first-child, td:first-child { padding-left: 1.28rem; }
tbody tr:hover { background: #f7fbfc; }
.plate { border: 0; background: none; padding: .1rem 0; color: #133e54; font-weight: 750; letter-spacing: .025em; text-align: left; }
.plate:hover { text-decoration: underline; text-underline-offset: .2rem; }
.cell-cue { display: block; margin-top: .35rem; font-size: .82rem; color: var(--secondary); line-height: 1.4; white-space: nowrap; }
.badge { padding: .24rem .48rem; background: #e9eef4; color: #394e67; border-radius: .38rem; font-size: .86rem; font-weight: 640; display: inline-block; }
.ok { background: #def3e9; color: #155842; }
.warning { background: #fff0d2; color: #784608; }
.danger { background: #fbe6e8; color: #922f3c; }
.empty { padding: 3.1rem 1.2rem; text-align: center; border-top: 1px solid #e6ecf3; }
.empty p { margin-top: .35rem; }
.error { color: #922f3c; border-radius: .45rem; padding: .65rem .8rem; background: #fbe7e8; font-size: .94rem; }
#page-error { margin: 0 1.3rem 1rem; }
dialog {
  border: 1px solid #c2cfdf; padding: 0; border-radius: .8rem; color: inherit;
  width: min(58rem, calc(100% - 2rem)); max-height: calc(100% - 2rem);
  box-shadow: 0 1rem 3.2rem #12273842; background: #fff;
}
dialog::backdrop { background: #10253880; }
.compact-dialog { width: min(37rem, calc(100% - 2rem)); }
.dialog-heading { padding: 1.05rem 1.3rem; border-bottom: 1px solid #e0e7ef; }
.dialog-body { padding: 1.2rem 1.3rem; display: grid; gap: .95rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.form-grid input, .form-grid select { min-width: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: .7rem; }
.upload-form { display: flex; align-items: end; gap: .65rem; flex-wrap: wrap; }
.upload-form .field { flex: 1 1 15rem; }
.upload-form input { width: 100%; }
.section-head, .checks-line, .doc-header, .doc-body {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem;
}
.detail-block { border: 1px solid var(--border); border-radius: .6rem; padding: .9rem; display: grid; gap: .7rem; }
.detail-actions { display: flex; gap: .55rem; flex-wrap: wrap; }
.doc-item { padding-top: .7rem; border-top: 1px solid #e2e9f2; display: grid; gap: .3rem; }
.doc-body { align-items: start; }
.detail-caption { display: grid; gap: .32rem; }
.history { border-top: 1px solid #e2e9f2; padding-top: .5rem; }
.history summary { cursor: pointer; font-weight: 650; color: #28435f; }
.history li { padding-block: .35rem; color: var(--secondary); font-size: .89rem; }
.preview-box { max-height: 16rem; overflow: auto; margin-top: .65rem; border: 1px solid var(--border); border-radius: .45rem; }
.preview-box table { min-width: 26rem; }
.import-summary { margin-top: .35rem; font-size: .93rem; }

@media (max-width: 740px) {
  .page-heading { align-items: flex-start; flex-direction: column; }
  .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .overview button { padding: .72rem; }
  .top-actions { gap: .5rem; }
  .local { display: none; }
  .toolbar .field { flex-grow: 1; }
}
@media (max-width: 480px) {
  .form-grid { grid-template-columns: 1fr; }
  .dialog-body, .dialog-heading, .panel-header, .toolbar { padding-inline: .9rem; }
}

/* Вход в закрытый контур: серверный режим. Локальный режим форму не показывает. */
.login-panel {
  max-width: 26rem;
  margin: 1.5rem auto;
  padding: 1.6rem;
  border: 1px solid var(--border);
  border-radius: .8rem;
  background: #fff;
}
.login-panel h2 { margin-bottom: .35rem; }
.login-form { display: grid; gap: .85rem; margin-top: 1.1rem; }
.login-form .field { display: grid; gap: .3rem; }
.login-form input {
  padding: .6rem .7rem;
  border: 1px solid var(--border);
  border-radius: .45rem;
  background: #fff;
  color: inherit;
}
.login-form button { justify-self: start; }
.subtle-link[type="button"], button.subtle-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
}
