* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #fafafa;
  color: #171717;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: #171717; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 28px;
  width: 100%;
  max-width: 340px;
}

.login-card h1 { font-size: 16px; font-weight: 600; margin-bottom: 20px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  color: #525252;
  margin-bottom: 4px;
}

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid #d4d4d4;
  border-radius: 4px;
  background: #fff;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #171717;
}

button, .btn {
  display: inline-block;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid #d4d4d4;
  background: #fff;
  color: #171717;
  border-radius: 4px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}

button:hover:not(:disabled), .btn:hover { background: #f5f5f5; }

button.primary {
  background: #171717;
  color: #fff;
  border-color: #171717;
}
button.primary:hover:not(:disabled) {
  background: #333;
  border-color: #333;
}
button:disabled { opacity: .5; cursor: not-allowed; }

button.danger { color: #b91c1c; border-color: #fecaca; }
button.danger:hover:not(:disabled) { background: #fef2f2; }

.topbar {
  border-bottom: 1px solid #e5e5e5;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { font-weight: 600; font-size: 15px; }
.brand-sub { color: #737373; font-size: 12px; margin-left: 8px; font-weight: 400; }

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 0;
}

.burger {
  width: 36px;
  height: 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  background: #fff;
}

.burger:hover { background: #f5f5f5; }

.burger span {
  display: block;
  width: 16px;
  height: 2px;
  background: #171717;
}

.app-shell {
  display: flex;
  height: calc(100vh - 57px);
  overflow: hidden;
}

.sidebar {
  width: 220px;
  border-right: 1px solid #e5e5e5;
  background: #fff;
  padding: 12px 0;
  transition: width .18s;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar.collapsed { width: 0; border-right: none; }

.sidebar-nav { display: flex; flex-direction: column; }

.sidebar-item {
  display: block;
  padding: 10px 16px;
  font-size: 13px;
  color: #404040;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  font-family: inherit;
}

.sidebar-item:hover { background: #f5f5f5; color: #171717; }

.sidebar-item.active {
  background: #f5f5f5;
  color: #171717;
  font-weight: 600;
  border-left: 3px solid #171717;
  padding-left: 13px;
}

.main-area {
  flex: 1;
  padding: 16px;
  min-width: 0;
  height: calc(100vh - 57px);
  overflow: hidden;
}

.panel { display: none; height: 100%; }
.panel.active { display: flex; flex-direction: column; height: 100%; }

.reader-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 57px);
  overflow: hidden;
}

@media (max-width: 900px) {
  .reader-layout { grid-template-columns: 1fr; height: auto; }
}

.readers-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
  height: calc(100vh - 57px - 32px);
  overflow: hidden;
}

@media (max-width: 1000px) {
  .readers-split { grid-template-columns: 1fr; height: auto; }
}

.section {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.section + .section { margin-top: 16px; }
.section.grow { flex: 1; min-height: 0; }

.section-header {
  padding: 12px 14px;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.section-header h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #525252;
}

.section-body {
  padding: 0;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.section-body.padded { padding: 14px; flex: 0 0 auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  font-weight: 500;
  color: #525252;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e5e5;
  background: #fafafa;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .02em;
  position: sticky;
  top: 0;
  z-index: 1;
}

td { padding: 8px 10px; border-bottom: 1px solid #f0f0f0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fafafa; }
tbody tr.selected { background: #f0f9ff; }
tbody tr.selected:hover { background: #e0f2fe; }

.empty { padding: 24px; text-align: center; color: #a3a3a3; font-size: 13px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.filters input[type="text"],
.filters select {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid #d4d4d4;
  border-radius: 4px;
  background: #fff;
  width: auto;
  min-width: 160px;
}

.filters select { cursor: pointer; }

.section-header .search-input {
  flex: 1;
  min-width: 220px;
  max-width: 480px;
}

.msg { padding: 10px 12px; border-radius: 4px; font-size: 13px; margin-bottom: 12px; }
.msg.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.msg.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.msg.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal {
  background: #fff;
  border-radius: 6px;
  width: 100%;
  max-width: 460px;
  border: 1px solid #e5e5e5;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid #e5e5e5;
  font-weight: 600;
  font-size: 14px;
}

.modal-body { padding: 18px; }
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid #e5e5e5;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.hidden { display: none !important; }
.muted { color: #737373; }
.small { font-size: 12px; }
.hint { color: #737373; font-size: 12px; margin-bottom: 8px; }

.status-returned { color: #15803d; }
.status-issued { color: #1d4ed8; }
.status-overdue { color: #b91c1c; font-weight: 600; }

.profile {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  font-size: 13px;
}

.profile .label { color: #737373; font-size: 12px; }
.profile .value { color: #171717; }

.tabs {
  display: flex;
  border-bottom: 1px solid #e5e5e5;
  background: #fafafa;
  flex-shrink: 0;
}

.tab {
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: #525252;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
}

.tab:hover { color: #171717; }

.tab.active {
  color: #171717;
  border-bottom-color: #171717;
  font-weight: 600;
}