:root {
  --ink: #17212b;
  --muted: #617080;
  --line: #d9e0e7;
  --soft: #f5f7f9;
  --panel: #ffffff;
  --brand: #0c6b58;
  --brand-2: #174b7a;
  --accent: #c98021;
  --danger: #b73535;
  --ok: #237a4b;
  --shadow: 0 14px 35px rgba(17, 31, 45, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: #eef2f5;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 28px;
  padding: 32px;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 215, 0, .38), transparent 28%),
    linear-gradient(135deg, #fffaf0 0%, #eef6ff 52%, #fff 100%);
}

.auth-card {
  align-self: center;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 26px;
  border: 1px solid rgba(23, 33, 43, .08);
}

.auth-heading {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.auth-heading h2 {
  margin: 0;
  font-size: 24px;
}

.auth-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.forgot-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(340px, .7fr);
  gap: 28px;
  align-items: center;
  min-height: calc(100vh - 64px);
}

.home-copy {
  padding: 18px 0 18px 18px;
}

.home-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #1595d3;
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 18px;
}

.home-logo span {
  color: #fff;
  background: #c40000;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 22px;
  letter-spacing: 0;
}

.home-copy h1 {
  max-width: 760px;
  margin: 0;
  color: #050505;
  font-size: clamp(42px, 5.5vw, 82px);
  line-height: .95;
  letter-spacing: 0;
}

.home-lead {
  max-width: 720px;
  margin: 22px 0 0;
  color: #151515;
  font-size: clamp(20px, 2.2vw, 32px);
  line-height: 1.2;
  font-weight: 800;
}

.home-deal {
  display: inline-block;
  margin-top: 24px;
  color: #126bf3;
  font-size: 32px;
  line-height: 1.05;
  font-weight: 900;
}

.home-deal strong {
  display: block;
  color: #d00000;
}

.home-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 12px;
  margin-top: 28px;
}

.home-feature-grid div,
.home-numbers div {
  min-width: 0;
  background: rgba(255, 255, 255, .86);
  border: 1px solid rgba(23, 33, 43, .09);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 10px 22px rgba(17, 31, 45, .06);
}

.home-feature-grid strong,
.home-feature-grid span,
.home-numbers strong,
.home-numbers span {
  display: block;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: normal;
}

.home-feature-grid span,
.home-numbers span {
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.35;
}

.home-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr));
  gap: 12px;
  margin-top: 12px;
}

.home-numbers strong {
  color: #c40000;
  font-size: 26px;
}

.home-visual {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-visual img {
  width: min(100%, 470px);
  max-height: calc(100vh - 96px);
  object-fit: cover;
  object-position: center top;
  border-radius: 8px;
  box-shadow: 0 24px 56px rgba(0, 0, 0, .18);
}

.login-help {
  margin-top: 14px;
  font-size: 13px;
}

.sidebar {
  background: #16232f;
  color: #fff;
  padding: 22px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--brand);
  border-radius: 8px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.1;
}

.brand small {
  color: #b9c4ce;
}

.role-label {
  display: block;
  margin: 16px 0 8px;
  color: #b9c4ce;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.role-select {
  width: 100%;
  padding: 11px 10px;
  border-radius: 6px;
  border: 1px solid #405161;
  background: #223241;
  color: #fff;
}

.nav {
  margin-top: 22px;
  display: grid;
  gap: 7px;
}

.nav button {
  color: #d8e1e8;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  border-radius: 6px;
}

.nav button.active,
.nav button:hover {
  color: #fff;
  background: #263849;
}

.main {
  padding: 28px;
  overflow: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.topbar h2 {
  margin: 0 0 6px;
  font-size: 28px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.grid.stats {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.grid.two {
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.stat strong {
  display: block;
  font-size: 28px;
  margin-top: 5px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

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

.section-title h3 {
  margin: 0;
  font-size: 18px;
}

.btn {
  background: var(--brand);
  color: #fff;
  padding: 10px 13px;
  border-radius: 6px;
  font-weight: 700;
}

.btn.secondary {
  background: #e8edf1;
  color: var(--ink);
}

.btn.warn {
  background: var(--accent);
}

.btn.danger {
  background: var(--danger);
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

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

.form .full {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 82px;
  resize: vertical;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  background: #203446;
  color: #fff;
  font-size: 12px;
  letter-spacing: .03em;
  text-transform: uppercase;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #e8edf1;
  color: #344555;
}

.pill.ok { background: #def2e8; color: var(--ok); }
.pill.warn { background: #fff0d9; color: #8b540d; }
.pill.lock { background: #f4dddd; color: var(--danger); }

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.book {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.book-cover {
  height: 112px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  font-size: 36px;
  font-weight: 800;
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-body {
  padding: 13px;
}

.book-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: #e8edf1;
  color: var(--ink);
  font-size: 19px;
}

.icon-btn.available {
  background: #def2e8;
  color: var(--ok);
}

.icon-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.book h4 {
  margin: 0 0 8px;
}

.book p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 13px;
}

.order-line {
  display: grid;
  grid-template-columns: 1fr 90px 90px;
  gap: 9px;
  align-items: end;
  margin-bottom: 9px;
}

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

.ops-form {
  display: grid;
  gap: 7px;
  min-width: 220px;
  margin-bottom: 8px;
}

.ops-form input,
.ops-form select {
  padding: 8px 9px;
}

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

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.summary-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.summary-row strong {
  font-size: 18px;
}

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

.panel-option {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft);
}

.panel-option strong {
  display: block;
  margin-bottom: 6px;
}

.panel-availability,
.muted-text {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0;
}

.builder-payment-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  margin-top: 14px;
  padding: 12px;
}

.small-notice {
  font-size: 13px;
  margin-top: 10px;
  padding: 9px 10px;
}

.notice {
  padding: 12px 14px;
  border-radius: 8px;
  background: #eef7f4;
  color: #245c4d;
  border: 1px solid #cbe5dc;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(12, 22, 32, .58);
  display: grid;
  place-items: center;
  padding: 22px;
}

.modal {
  width: min(920px, 100%);
  max-height: 88vh;
  overflow: hidden;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, .28);
  display: grid;
  grid-template-rows: auto 1fr;
}

.order-modal {
  width: min(1180px, 100%);
  display: block;
  max-height: 88vh;
  overflow: auto;
  padding-bottom: 18px;
}

.order-modal h4 {
  margin: 18px 18px 10px;
}

.order-modal .table-wrap,
.order-detail-summary {
  margin: 0 18px;
}

.order-detail-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  margin-top: 18px;
  padding: 14px 16px;
}

.order-detail-summary .summary-row {
  padding: 10px 0;
}

.order-detail-summary .summary-row:first-child {
  padding-top: 0;
}

.order-detail-summary .summary-row:last-child {
  padding-bottom: 0;
}

.panel-detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 18px;
}

.panel-detail-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px 14px;
}

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

.order-detail-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--soft);
}

.order-detail-grid strong,
.order-detail-grid span {
  display: block;
}

.order-detail-grid span {
  color: var(--muted);
  margin-top: 4px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
}

.ebook-frame {
  width: 100%;
  height: 70vh;
  border: 0;
  background: var(--soft);
}

.ebook-fallback {
  padding: 28px;
}

.login-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: #cfdae4;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 30px;
}

@media (max-width: 980px) {
  .auth-shell,
  .home-hero,
  .home-feature-grid,
  .home-numbers {
    grid-template-columns: 1fr;
  }
  .auth-shell {
    padding: 18px;
    gap: 18px;
  }
  .auth-card {
    order: -1;
    width: 100%;
    max-width: 560px;
    justify-self: center;
  }
  .home-hero {
    min-height: 0;
    gap: 18px;
  }
  .home-copy {
    padding: 0;
  }
  .home-visual img {
    width: 100%;
    max-height: none;
  }
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .grid.stats,
  .grid.two,
  .filters,
  .form {
    grid-template-columns: 1fr;
  }
  .main {
    padding: 18px;
  }
  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  body {
    background: #f5f7f9;
  }

  .auth-shell {
    min-height: 100svh;
    padding: 12px;
    background: linear-gradient(180deg, #eef6ff 0%, #fffaf0 100%);
  }

  .auth-card {
    padding: 18px;
    border-radius: 8px;
  }

  .auth-heading {
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
  }

  .auth-heading h2 {
    font-size: 21px;
  }

  .auth-heading p {
    font-size: 13px;
  }

  .auth-card .form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .auth-card input,
  .auth-card button {
    min-height: 46px;
  }

  .forgot-form {
    margin-top: 12px;
    padding-top: 12px;
  }

  .home-hero {
    display: block;
  }

  .home-logo {
    font-size: 20px;
    margin-bottom: 10px;
  }

  .home-logo span {
    font-size: 16px;
    padding: 4px 9px;
  }

  .home-copy h1 {
    font-size: 34px;
    line-height: 1;
  }

  .home-lead {
    margin-top: 12px;
    font-size: 17px;
    font-weight: 700;
  }

  .home-deal {
    margin-top: 14px;
    font-size: 24px;
  }

  .home-feature-grid,
  .home-numbers {
    gap: 8px;
    margin-top: 12px;
  }

  .home-feature-grid {
    grid-template-columns: 1fr;
  }

  .home-numbers {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .home-feature-grid div,
  .home-numbers div {
    padding: 11px;
  }

  .home-feature-grid strong,
  .home-numbers strong {
    font-size: 16px;
    line-height: 1.18;
  }

  .home-feature-grid span,
  .home-numbers span {
    font-size: 13px;
    line-height: 1.28;
  }

  .home-numbers strong {
    font-size: clamp(16px, 4.8vw, 22px);
  }

  .home-visual {
    margin-top: 14px;
  }

  .home-visual img {
    max-height: 280px;
    object-fit: contain;
    background: #fff;
  }
}

@media (max-width: 420px) {
  .auth-shell {
    padding: 10px;
  }

  .auth-card {
    padding: 15px;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  .home-feature-grid {
    display: none;
  }

  .home-numbers {
    grid-template-columns: 1fr;
  }

  .home-copy h1 {
    font-size: 30px;
  }

  .home-visual img {
    max-height: 220px;
  }
}
