:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --text: #1f2328;
  --muted: #6f7378;
  --line: #dedbd3;
  --accent: #8b5e18;
  --accent-2: #2e6957;
  --danger: #c73838;
  --radius: 8px;
  --shadow: 0 16px 38px rgba(45, 39, 28, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 264px 1fr; }
.guest-shell { grid-template-columns: 1fr; }
.guest-shell .sidebar, .guest-shell .topbar { display: none; }
.sidebar {
  background: #181714;
  color: white;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; margin-bottom: 28px; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f0b43a;
  color: #181714;
  font-weight: 800;
}
.brand small { display: block; color: #b9b2a6; margin-top: 2px; }
.nav { display: grid; gap: 6px; }
.nav a {
  text-decoration: none;
  color: #ece7de;
  padding: 11px 12px;
  border-radius: 7px;
}
.nav a:hover { background: rgba(255,255,255,.08); }
.main { min-width: 0; }
.topbar {
  height: 68px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30px;
  background: rgba(255,255,255,.86);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(10px);
}
.topbar span { color: var(--muted); margin-left: 10px; }
.page-head {
  padding: 34px 30px 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 18px; }
p { line-height: 1.55; }
.page-head p, .muted, .empty { color: var(--muted); }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.button {
  border: 0;
  border-radius: 7px;
  padding: 10px 14px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}
.button.primary { background: var(--accent); color: white; }
.button.secondary { background: #fff3d7; color: #855b10; }
.button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  padding: 0 30px 20px;
}
.metrics article, .panel, .form-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.metrics article { padding: 18px; }
.metrics span { color: var(--muted); display: block; margin-bottom: 8px; }
.metrics strong { font-size: 30px; }
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr);
  gap: 18px;
  padding: 0 30px 30px;
}
.panel { padding: 20px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 700; background: #f8fafc; }
.status {
  display: inline-block;
  border-radius: 999px;
  background: #e9f4ef;
  color: #21624f;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}
.status-draft { background: #eef1f5; color: #536173; }
.status-submitted { background: #e9f4ef; color: #21624f; }
.status-approved { background: #e7f6e7; color: #247236; }
.status-rejected { background: #fff1f1; color: #b22626; }
.status-corrected { background: #fff6df; color: #8a631a; }
.action-list, .stack { display: grid; gap: 10px; }
.action-list a, .row-card {
  text-decoration: none;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
}
.row-card span { display: block; color: var(--muted); margin-top: 3px; }
.row-card.is-muted { opacity: .62; }
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  font-size: 13px;
}
.row-actions a, .row-actions .link-button {
  color: #8a631a;
  font-weight: 700;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
.journal-register { margin: 0 30px 30px; padding: 0; overflow: hidden; }
.list-summary {
  margin: 0 30px 10px;
  color: var(--muted);
  font-size: 13px;
}
.toolbar {
  margin: 0 30px 16px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(220px, 320px);
  gap: 14px;
  align-items: end;
}
.toolbar label { display: grid; gap: 6px; }
.journal-category { border-bottom: 1px solid var(--line); }
.journal-category:last-child { border-bottom: 0; }
.journal-category h2 {
  padding: 18px 20px 10px;
  color: #3a352e;
  font-size: 15px;
  text-transform: uppercase;
}
.journal-list { display: grid; }
.journal-row {
  display: grid;
  grid-template-columns: 170px minmax(260px, 1fr) minmax(220px, .8fr);
  gap: 16px;
  align-items: center;
  padding: 14px 20px;
  text-decoration: none;
  border-top: 1px solid #ece8df;
}
.journal-row:hover { background: #fbf8f1; }
.journal-type {
  color: #8a631a;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.journal-row strong { line-height: 1.35; }
.journal-row small { color: var(--muted); line-height: 1.35; }
.form-grid { display: grid; gap: 12px; }
.form-grid p, .form-card p, .compact-form p { margin: 0; display: grid; gap: 6px; }
label { color: #3a4558; font-size: 13px; font-weight: 700; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  font: inherit;
  background: white;
}
input[type="checkbox"] { width: auto; }
.entry-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.field-row {
  display: grid;
  gap: 6px;
  align-content: start;
}
.field-row:has(textarea) { grid-column: 1 / -1; }
.field-row small { color: var(--muted); }
.required-mark { color: var(--danger); margin-left: 3px; }
.field-error, .field-errors { color: var(--danger); }
.has-error input, .has-error textarea, .has-error select { border-color: var(--danger); }
.notice {
  margin: 0 30px 14px;
  max-width: 980px;
  padding: 12px 14px;
  border-radius: 7px;
  background: #eef7f4;
  color: #21624f;
  border: 1px solid #c8eadf;
}
.notice.warning { background: #fff8e8; color: #8a631a; border-color: #f1d79c; }
.notice a { font-weight: 800; }
.inline-form { display: inline; margin: 0; }
.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: #8a631a;
  font: inherit;
  cursor: pointer;
  min-height: 34px;
}
.compact-form { display: grid; gap: 10px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.wide-form { margin: 0 30px 30px; max-width: 980px; }
.auth-panel { max-width: 560px; margin: 70px auto; padding: 0 20px; }
.form-card { padding: 22px; display: grid; gap: 14px; }
.requisites-box {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #f1d79c;
  border-radius: 7px;
  background: #fffaf0;
}
.requisites-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 10px;
}
.requisites-row .button { white-space: nowrap; }
.requisites-box small { color: var(--muted); }
.error-text { color: var(--danger) !important; }
.messages { padding: 16px 30px 0; display: grid; gap: 8px; }
.message { padding: 12px 14px; border-radius: 7px; background: #eef7f4; color: #21624f; border: 1px solid #c8eadf; }
.message.error { background: #fff1f1; color: var(--danger); border-color: #ffd0d0; }
.actions { white-space: nowrap; }
.actions a { margin-right: 10px; color: #8a631a; }
.actions a, .actions .link-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  font-weight: 700;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid, .metrics { grid-template-columns: 1fr; }
  .page-head { align-items: stretch; flex-direction: column; }
  .toolbar, .entry-fields, .requisites-row { grid-template-columns: 1fr; }
  .journal-row { grid-template-columns: 1fr; gap: 6px; }
}

@media (max-width: 700px) {
  .table-wrap { overflow-x: visible; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  tr {
    border: 1px solid var(--line);
    border-radius: 7px;
    margin-bottom: 12px;
    background: white;
    overflow: hidden;
  }
  td {
    border-bottom: 1px solid #ece8df;
    display: grid;
    grid-template-columns: minmax(110px, .45fr) minmax(0, 1fr);
    gap: 10px;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
  }
  td.actions { display: flex; gap: 12px; white-space: normal; }
  td.actions::before { content: ""; display: none; }
}
