:root {
  color-scheme: light;
  --ink: #172027;
  --muted: #66717c;
  --line: #dbe2e7;
  --soft: #f5f8f7;
  --panel: #ffffff;
  --green: #0f7b5f;
  --green-dark: #0a5b47;
  --gold: #b98217;
  --red: #b42318;
  --blue: #2563a8;
  --shadow: 0 12px 30px rgba(25, 39, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--soft);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--green);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
  color: var(--ink);
  font-weight: 800;
}

.brand img {
  width: 128px;
  height: 40px;
  object-fit: contain;
}

.brand span {
  padding-left: 12px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.nav a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--ink);
  font-weight: 650;
  font-size: 14px;
}

.nav a:hover,
.nav .nav-strong {
  background: #e7f3ef;
  color: var(--green-dark);
  text-decoration: none;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.message,
.form-errors {
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.message.error,
.message.warning,
.form-errors {
  border-left-color: var(--red);
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.7fr);
  gap: 24px;
  align-items: start;
}

.auth-grid.compact {
  grid-template-columns: minmax(0, 560px);
  justify-content: center;
}

.auth-grid.wide {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.85fr);
}

.auth-panel,
.support-panel,
.panel,
.narrow-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel,
.support-panel {
  padding: clamp(22px, 4vw, 36px);
}

.narrow-panel {
  max-width: 760px;
  padding: clamp(18px, 3vw, 28px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
  font-weight: 800;
}

h1 {
  font-size: clamp(30px, 5vw, 48px);
}

h2 {
  font-size: 20px;
}

.lede {
  margin: 12px 0 0;
  max-width: 680px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.form-card {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.form-card.flat {
  margin-top: 12px;
  box-shadow: none;
}

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

.field label {
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c8d4db;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}

.field textarea {
  min-height: 112px;
  resize: vertical;
}

.field input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  justify-self: start;
}

.field small {
  color: var(--muted);
  line-height: 1.45;
}

.field .error {
  color: var(--red);
  font-weight: 650;
}

.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--red);
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.button:hover {
  text-decoration: none;
}

.button.primary {
  background: var(--green);
  color: #fff;
}

.button.primary:hover {
  background: var(--green-dark);
}

.button.secondary {
  background: #fff;
  border-color: #b8c7cf;
  color: var(--ink);
}

.button.secondary:hover {
  border-color: var(--green);
  color: var(--green-dark);
}

.muted-line,
.empty {
  color: var(--muted);
}

.plain-list {
  margin: 18px 0 0;
  padding-left: 20px;
  color: var(--ink);
  line-height: 1.75;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

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

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.staff-dashboard .metric-row,
.metric-row:has(.metric:nth-child(4)) {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  min-height: 88px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric span {
  display: block;
  color: var(--green-dark);
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.metric p {
  margin: 6px 0 0;
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.panel {
  min-width: 0;
  padding: 20px;
}

.panel.span-2 {
  grid-column: span 2;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

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

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef4f0;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.status-new {
  background: #edf6ff;
  color: var(--blue);
}

.status-waiting_client,
.status-rejected {
  background: #fff0eb;
  color: var(--red);
}

.status-completed,
.status-filed {
  background: #e7f3ef;
  color: var(--green-dark);
}

.stack-list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  gap: 4px;
  min-height: 64px;
  align-content: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--ink);
}

.list-item:hover {
  border-color: var(--green);
  text-decoration: none;
}

.list-item small {
  color: var(--muted);
  line-height: 1.35;
}

.list-item.static:hover {
  border-color: var(--line);
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.plan {
  display: grid;
  gap: 6px;
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.plan small {
  color: var(--muted);
  line-height: 1.45;
}

.plan span {
  color: var(--green-dark);
  font-weight: 800;
}

.filter-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(130px, 0.8fr) minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.filter-form input,
.filter-form select {
  min-height: 42px;
  border: 1px solid #c8d4db;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}

.detail-list {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px 16px;
  margin: 16px 0 0;
}

.detail-list dt {
  color: var(--muted);
  font-weight: 800;
}

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

@media (max-width: 900px) {
  .topbar,
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand span {
    display: none;
  }

  .nav {
    justify-content: flex-start;
  }

  .auth-grid,
  .auth-grid.wide,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .panel.span-2 {
    grid-column: auto;
  }

  .metric-row,
  .metric-row:has(.metric:nth-child(4)) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-form {
    grid-template-columns: 1fr;
    width: 100%;
  }

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

@media (max-width: 560px) {
  .page {
    width: min(100% - 20px, 1180px);
    padding-top: 20px;
  }

  .topbar {
    padding: 12px 10px;
  }

  .brand img {
    width: 112px;
  }

  .nav a {
    font-size: 13px;
    padding: 7px 8px;
  }

  .metric-row,
  .metric-row:has(.metric:nth-child(4)),
  .plan-grid {
    grid-template-columns: 1fr;
  }

  .heading-actions,
  .button {
    width: 100%;
  }

  .detail-list {
    grid-template-columns: 1fr;
  }
}
