:root {
  --bg: #f5fbff;
  --bg-soft: #fff7fb;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --border: #d8e9f7;
  --border-strong: #b9d8ee;
  --text: #243041;
  --muted: #6b7a90;
  --primary: #63a9d8;
  --primary-dark: #3c8ec4;
  --accent: #e99ab8;
  --accent-dark: #d8769e;
  --danger: #c45168;
  --warn: #b7822a;
  --ok: #438b72;
  --shadow: 0 16px 40px rgba(92, 135, 170, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(203, 234, 255, 0.82), rgba(255, 229, 240, 0.74) 46%, rgba(246, 252, 255, 0.95)),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 14px 30px;
  background:
    linear-gradient(90deg, rgba(232, 247, 255, 0.96), rgba(255, 239, 247, 0.96)),
    rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(184, 216, 238, 0.78);
  box-shadow: 0 10px 28px rgba(116, 157, 190, 0.12);
  backdrop-filter: blur(14px);
}

.brand {
  color: var(--text);
  font-size: 21px;
  font-weight: 800;
}

.brand::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 0 0 5px rgba(99, 169, 216, 0.14);
  vertical-align: 1px;
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.mobile-nav {
  display: none;
}

.nav a,
.logout-form button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #405168;
  background: transparent;
  font-size: 14px;
  font-weight: 650;
}

.nav a:hover,
.logout-form button:hover {
  border-color: rgba(233, 154, 184, 0.36);
  background: rgba(255, 236, 244, 0.82);
  color: var(--accent-dark);
  text-decoration: none;
}

.logout-form {
  display: inline;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 34px auto 64px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.32);
  box-shadow: 0 20px 60px rgba(108, 151, 185, 0.13);
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  color: #223348;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.12;
}

h2 {
  color: #2d3d52;
  font-size: 22px;
}

h3 {
  color: #35475d;
  font-size: 17px;
}

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

.panel,
.empty,
.details > div,
.table-wrap {
  background: var(--surface);
  border: 1px solid rgba(216, 233, 247, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  border-top: 4px solid rgba(233, 154, 184, 0.72);
}

.panel,
.empty {
  padding: 26px;
}

.narrow {
  max-width: 580px;
}

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

.grid-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: #34455a;
  font-weight: 700;
}

label span {
  font-size: 14px;
}

input,
select,
textarea,
button,
.button {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 169, 216, 0.18);
}

textarea {
  resize: vertical;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

button:hover,
.button:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 22px rgba(233, 154, 184, 0.16);
  text-decoration: none;
  transform: translateY(-1px);
}

.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 12px 24px rgba(99, 169, 216, 0.22);
}

.primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--accent-dark));
  color: #fff;
}

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

.danger-button,
.danger-link {
  border-color: rgba(196, 81, 104, 0.34);
  background: #fff0f4;
  color: var(--danger);
}

.danger-button:hover,
.danger-link:hover {
  border-color: var(--danger);
  background: #ffe4ec;
  color: var(--danger);
}

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

.message {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-solid);
  box-shadow: 0 8px 24px rgba(92, 135, 170, 0.12);
}

.message.success {
  border-color: rgba(67, 139, 114, 0.36);
  color: var(--ok);
}

.message.error {
  border-color: rgba(196, 81, 104, 0.36);
  color: var(--danger);
}

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

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid rgba(216, 233, 247, 0.9);
  text-align: left;
  vertical-align: top;
}

th {
  background: linear-gradient(90deg, rgba(226, 244, 255, 0.98), rgba(255, 235, 244, 0.98));
  color: #506177;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover {
  background: rgba(246, 251, 255, 0.72);
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-block;
  border: 1px solid rgba(150, 190, 220, 0.36);
  border-radius: 999px;
  padding: 5px 10px;
  background: #eef8ff;
  color: #49657f;
  font-size: 13px;
  font-weight: 700;
}

.status.pending {
  border-color: rgba(183, 130, 42, 0.25);
  background: #fff8e9;
  color: var(--warn);
}

.status.in_progress {
  border-color: rgba(99, 169, 216, 0.34);
  background: #eaf7ff;
  color: var(--primary-dark);
}

.status.done {
  border-color: rgba(67, 139, 114, 0.28);
  background: #edf9f5;
  color: var(--ok);
}

.status.cancelled,
.status.rejected {
  border-color: rgba(196, 81, 104, 0.28);
  background: #fff0f4;
  color: var(--danger);
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid rgba(216, 233, 247, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 30px rgba(92, 135, 170, 0.11);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(130px, 1fr) minmax(160px, 1.2fr) auto;
  gap: 8px;
}

.embedded {
  border-radius: 8px;
  box-shadow: none;
}

.type-grid,
.material-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.material-sections {
  grid-template-columns: 1fr;
}

.type-card {
  display: grid;
  gap: 12px;
  min-height: 180px;
  padding: 28px;
  border: 1px solid rgba(216, 233, 247, 0.95);
  border-top: 5px solid rgba(233, 154, 184, 0.74);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(231, 247, 255, 0.94), rgba(255, 239, 247, 0.94)),
    #fff;
  box-shadow: var(--shadow);
  color: var(--text);
}

.type-card:hover {
  border-color: rgba(99, 169, 216, 0.72);
  box-shadow: 0 18px 42px rgba(99, 169, 216, 0.22);
  text-decoration: none;
  transform: translateY(-2px);
}

.type-card__label {
  font-size: 26px;
  font-weight: 800;
}

.type-card__formats {
  color: var(--muted);
  font-weight: 700;
}

.details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.details > div {
  padding: 24px;
}

dl {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 11px 16px;
  margin: 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  color: #2f4055;
  font-weight: 650;
}

.preview {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fcff;
}

.errorlist {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--danger);
  font-weight: 500;
}

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

.check input {
  width: auto;
}

@media (max-width: 820px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 14px 18px;
  }

  .desktop-nav {
    display: none;
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
    width: 100%;
  }

  .mobile-nav label {
    min-width: 0;
  }

  .mobile-nav select {
    min-width: 0;
  }

  .section-head,
  .actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .page {
    width: min(100% - 20px, 1180px);
    margin: 18px auto 42px;
    padding: 14px;
  }

  .grid-form,
  .details,
  .filters,
  .type-grid,
  .material-sections {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  dl {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 28px;
  }

  .panel,
  .empty,
  .details > div {
    padding: 18px;
  }
}

@media (max-width: 560px) {
  .mobile-nav {
    grid-template-columns: 1fr;
  }

  .logout-form,
  .logout-form button,
  .button,
  button {
    width: 100%;
  }

  table {
    min-width: 680px;
  }

  th,
  td {
    padding: 10px;
  }

  .type-card {
    min-height: 140px;
    padding: 20px;
  }

  .type-card__label {
    font-size: 22px;
  }
}
