:root {
  /* Light Brutalism Tokens */
  --bg-canvas: #f3ede0;
  --surface: #ffffff;
  --surface-subtle: #ebe3d3;
  --ink: #111111;
  --ink-muted: #525252;
  --ink-shadow: #111111;

  --text-primary: #111111;
  --text-secondary: #1f1f1f;
  --text-muted: #4a4a4a;

  --brutal-border: 2px solid var(--ink);
  --brutal-border-thick: 2.5px solid var(--ink);
  --brutal-shadow: 5px 5px 0 var(--ink-shadow);
  --brutal-shadow-sm: 3px 3px 0 var(--ink-shadow);
  --brutal-shadow-xs: 2px 2px 0 var(--ink-shadow);
  --modal-shadow: 8px 8px 0 var(--ink-shadow);
  --modal-backdrop: rgba(17, 17, 17, 0.56);

  --table-head-bg: #ebe3d3;
  --table-border: #111111;
  --table-row-hover: #faf6ed;
  --row-overdue-bg: #fee2e2;
  --row-overdue-hover: #fecaca;
  --stat-overdue-bg: #ffe4e6;
  --stat-overdue-border: var(--ink);

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-highlight: #fde047;
  --accent-highlight-ink: #111111;
  --accent-soft: #dbeafe;

  --status-available-bg: #bbf7d0;
  --status-available-text: #052e16;
  --status-available-border: #111111;

  --status-borrowed-bg: #bfdbfe;
  --status-borrowed-text: #172554;
  --status-borrowed-border: #111111;

  --status-overdue-bg: #fecaca;
  --status-overdue-text: #450a0a;
  --status-overdue-border: #111111;

  --radius-md: 4px;
  --radius-lg: 6px;
  --sidebar-width: 266px;
}

[data-theme="dark"] {
  /* Dark Brutalism Tokens */
  --bg-canvas: #0f1116;
  --surface: #181b23;
  --surface-subtle: #11141b;
  --ink: #f4efe6;
  --ink-muted: #cbd5e1;
  --ink-shadow: #475569;

  --text-primary: #f8fafc;
  --text-secondary: #e2e8f0;
  --text-muted: #cbd5e1;

  --brutal-border: 2px solid var(--ink);
  --brutal-border-thick: 2.5px solid var(--ink);
  --brutal-shadow: 5px 5px 0 var(--ink-shadow);
  --brutal-shadow-sm: 3px 3px 0 var(--ink-shadow);
  --brutal-shadow-xs: 2px 2px 0 var(--ink-shadow);
  --modal-shadow: 8px 8px 0 var(--ink-shadow);
  --modal-backdrop: rgba(5, 7, 12, 0.78);

  --table-head-bg: #11141b;
  --table-border: rgba(244, 239, 230, 0.48);
  --table-row-hover: #222733;
  --row-overdue-bg: rgba(220, 38, 38, 0.24);
  --row-overdue-hover: rgba(220, 38, 38, 0.34);
  --stat-overdue-bg: #2c161c;
  --stat-overdue-border: #f87171;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-highlight: #fde047;
  --accent-highlight-ink: #111111;
  --accent-soft: rgba(59, 130, 246, 0.24);

  --status-available-bg: #14532d;
  --status-available-text: #dcfce7;
  --status-available-border: #4ade80;

  --status-borrowed-bg: #1e3a8a;
  --status-borrowed-text: #dbeafe;
  --status-borrowed-border: #60a5fa;

  --status-overdue-bg: #7f1d1d;
  --status-overdue-text: #fee2e2;
  --status-overdue-border: #f87171;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(rgba(17, 17, 17, 0.15) 0.9px, transparent 0.9px);
  background-size: 22px 22px;
  color: var(--text-primary);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

[data-theme="dark"] body {
  background-image: radial-gradient(rgba(244, 239, 230, 0.08) 0.9px, transparent 0.9px);
  letter-spacing: 0.005em;
}

h1,
h2,
h3,
.brand-title {
  font-family: "Bricolage Grotesque", sans-serif;
  color: var(--text-primary);
  margin: 0;
}

p {
  margin: 0;
}

.mono,
.tabular-nums {
  font-family: "JetBrains Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

/* Shell Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: var(--brutal-border-thick);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: var(--brutal-border);
  box-shadow: var(--brutal-shadow-sm);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-text {
  min-width: 0;
  flex: 1;
}

.school-logo-badge {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: var(--brutal-border);
  box-shadow: var(--brutal-shadow-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  overflow: hidden;
  color: var(--text-primary);
}

.school-logo-badge-sm {
  width: 34px;
  height: 34px;
  border-radius: 3px;
  padding: 4px;
}

.school-logo-badge svg,
.school-logo-badge img,
.school-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-title {
  display: block;
  font-size: 1.04rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.18;
}

.brand-subtitle {
  display: block;
  margin-top: 2px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 44px;
  padding: 9px 13px;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.12s ease, border-color 0.12s ease;
}

.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.nav-btn:hover {
  background: var(--surface-subtle);
  color: var(--text-primary);
  border-color: var(--ink);
  box-shadow: var(--brutal-shadow-xs);
  transform: translate(-1px, -1px);
}

.nav-btn.active {
  background: var(--accent-highlight);
  color: var(--accent-highlight-ink);
  font-weight: 800;
  border: var(--brutal-border);
  box-shadow: var(--brutal-shadow-sm);
}

.nav-btn.active .nav-icon {
  color: var(--accent-highlight-ink);
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 2px dashed var(--table-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.theme-toggle-btn {
  justify-content: center;
}

.theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.theme-icon-btn {
  width: 38px;
  padding: 0;
}

/* Mobile Header */
.mobile-header {
  display: none;
  background: var(--surface);
  border-bottom: var(--brutal-border-thick);
  position: sticky;
  top: 0;
  z-index: 30;
}

.mobile-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
}

.mobile-brand-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.mobile-header-top .brand-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.96rem;
}

.mobile-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.mobile-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 14px 12px;
  border-top: 1.5px solid var(--table-border);
}

.mobile-nav-btn {
  border: var(--brutal-border);
  background: var(--surface);
  box-shadow: var(--brutal-shadow-xs);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

.mobile-nav-btn.active {
  background: var(--accent-highlight);
  color: var(--accent-highlight-ink);
  font-weight: 800;
  box-shadow: var(--brutal-shadow-xs);
}

/* Main Content */
.main-content {
  flex: 1;
  width: 100%;
  min-width: 0;
  max-width: 1220px;
  margin: 0 auto;
  padding: 28px 34px 52px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: var(--brutal-border-thick);
  box-shadow: var(--brutal-shadow);
  margin-bottom: 26px;
}

.page-kicker {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.page-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.page-subtitle {
  margin-top: 5px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: var(--brutal-border);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--brutal-shadow-sm);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.12s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-md);
  box-shadow: var(--brutal-shadow-xs);
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--ink);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink-shadow);
}

.btn-primary:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink-shadow);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--ink);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-highlight);
  color: var(--accent-highlight-ink);
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink-shadow);
}

.btn-secondary:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink-shadow);
}

.btn-danger {
  background: #dc2626;
  border-color: var(--ink);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink-shadow);
}

.btn-danger:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink-shadow);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: var(--brutal-border);
  background: var(--surface);
  box-shadow: var(--brutal-shadow-xs);
  color: var(--text-primary);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--accent-highlight);
  color: var(--accent-highlight-ink);
}

.icon-btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* Cards & Grids */
.card {
  background: var(--surface);
  border: var(--brutal-border-thick);
  border-radius: var(--radius-lg);
  box-shadow: var(--brutal-shadow);
  padding: 22px;
  min-width: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}

.stat-card {
  background: var(--surface);
  border: var(--brutal-border-thick);
  border-radius: var(--radius-lg);
  box-shadow: var(--brutal-shadow-sm);
  padding: 18px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.stat-card-overdue {
  background: var(--stat-overdue-bg);
  border-color: var(--stat-overdue-border);
}

.stat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stat-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-secondary);
}

.stat-icon-well {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-subtle);
  color: var(--text-primary);
  border: var(--brutal-border);
  box-shadow: var(--brutal-shadow-xs);
  flex-shrink: 0;
}

.stat-icon-well svg {
  width: 17px;
  height: 17px;
}

.stat-icon-accent {
  color: var(--accent-highlight-ink);
  background: var(--accent-highlight);
}

.stat-icon-green {
  color: var(--status-available-text);
  background: var(--status-available-bg);
}

.stat-icon-blue {
  color: var(--status-borrowed-text);
  background: var(--status-borrowed-bg);
}

.stat-icon-red {
  color: var(--status-overdue-text);
  background: var(--status-overdue-bg);
}

.stat-value {
  margin-top: 2px;
  font-family: "JetBrains Mono", monospace;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.08;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-sublabel {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.stat-value-green {
  color: var(--status-available-text);
}

[data-theme="dark"] .stat-value-green {
  color: #4ade80;
}

.stat-value-blue {
  color: var(--status-borrowed-text);
}

[data-theme="dark"] .stat-value-blue {
  color: #60a5fa;
}

.stat-value-red {
  color: #b91c1c;
}

[data-theme="dark"] .stat-value-red {
  color: #fca5a5;
}

/* Dashboard Analytics & Charts */
.analytics-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 22px;
  margin-bottom: 26px;
}

.analytics-grid>* {
  min-width: 0;
}

.chart-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.chart-subtitle {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 3px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  border: 1.5px solid var(--ink);
  display: inline-block;
  flex-shrink: 0;
}

.legend-swatch-borrowed {
  background: #3b82f6;
}

.legend-swatch-returned {
  background: #10b981;
}

.legend-swatch-available {
  background: #10b981;
}

.legend-swatch-overdue {
  background: #ef4444;
}

.chart-svg-wrap {
  background: var(--surface-subtle);
  border: var(--brutal-border);
  border-radius: var(--radius-md);
  padding: 14px 12px 10px;
  overflow: hidden;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-bar-rect {
  stroke: var(--ink);
  stroke-width: 1.5;
}

.chart-gridline {
  stroke: var(--table-border);
  stroke-opacity: 0.35;
  stroke-dasharray: 4 4;
  stroke-width: 1;
}

.chart-baseline {
  stroke: var(--ink);
  stroke-width: 2;
}

.chart-axis-text {
  fill: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  font-family: "Plus Jakarta Sans", sans-serif;
}

.chart-val-text {
  fill: var(--text-primary);
  font-size: 10.5px;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
}

.chart-footer-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.chart-mini-stat {
  background: var(--surface-subtle);
  border: var(--brutal-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: var(--brutal-shadow-xs);
}

.chart-mini-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

.chart-mini-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.donut-layout {
  display: flex;
  align-items: center;
  gap: 18px;
}

.donut-wrap {
  position: relative;
  width: 152px;
  height: 152px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-subtle);
  border: var(--brutal-border);
  box-shadow: var(--brutal-shadow-xs);
}

.donut-svg {
  width: 134px;
  height: 134px;
  transform: rotate(-90deg);
}

.donut-track {
  fill: none;
  stroke: var(--surface);
  stroke-width: 14;
}

.donut-seg {
  fill: none;
  stroke-width: 14;
  stroke-linecap: butt;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.donut-pct {
  font-family: "JetBrains Mono", monospace;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.donut-sub {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 3px;
}

.donut-legend-list {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.donut-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: var(--brutal-border);
  box-shadow: var(--brutal-shadow-xs);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.donut-legend-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.donut-legend-val {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.category-bars {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 12px;
  border-top: 2px solid var(--table-border);
}

.category-bars-title {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cat-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cat-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cat-count {
  font-family: "JetBrains Mono", monospace;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.cat-track {
  height: 10px;
  border-radius: 2px;
  background: var(--surface-subtle);
  border: 1.5px solid var(--ink);
  overflow: hidden;
}

.cat-fill {
  height: 100%;
  border-radius: 0;
  background: var(--accent);
}

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

.two-col-grid>*,
.scan-layout>* {
  min-width: 0;
}

.col-stack {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

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

.section-header .section-title {
  margin-bottom: 0;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 16px;
}

.link-btn {
  background: var(--surface);
  border: var(--brutal-border);
  border-radius: var(--radius-md);
  padding: 5px 10px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--brutal-shadow-xs);
  transition: transform 0.1s ease, background-color 0.12s ease;
  white-space: nowrap;
}

.link-btn:hover {
  background: var(--accent-highlight);
  color: var(--accent-highlight-ink);
  transform: translate(-1px, -1px);
}

/* Status Indicators (Icon + Text + Color, high-contrast Brutalist frame) */
.status-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 3px;
  font-size: 0.78rem;
  font-weight: 800;
  border: 1.5px solid var(--ink);
  box-shadow: var(--brutal-shadow-xs);
  white-space: nowrap;
}

.status-available,
.status-returned {
  background: var(--status-available-bg);
  color: var(--status-available-text);
  border-color: var(--status-available-border);
}

.status-borrowed {
  background: var(--status-borrowed-bg);
  color: var(--status-borrowed-text);
  border-color: var(--status-borrowed-border);
}

.status-overdue {
  background: var(--status-overdue-bg);
  color: var(--status-overdue-text);
  border-color: var(--status-overdue-border);
}

/* Forms & Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-grow {
  flex: 1;
  min-width: 220px;
}

label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select {
  min-height: 44px;
  padding: 10px 14px;
  border: var(--brutal-border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--brutal-shadow-xs);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  width: 100%;
}

input::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}

input[type="file"] {
  padding: 10px;
  border: var(--brutal-border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--brutal-shadow-xs);
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 600;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid var(--accent-highlight);
  outline-offset: 2px;
}

/* Tables */
.table-wrap {
  background: var(--surface);
  border: var(--brutal-border-thick);
  border-radius: var(--radius-lg);
  box-shadow: var(--brutal-shadow-sm);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
}

thead {
  background: var(--table-head-bg);
  border-bottom: var(--brutal-border);
}

th {
  padding: 12px 14px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1.5px solid var(--table-border);
  color: var(--text-primary);
  vertical-align: middle;
}

td.mono {
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--table-row-hover);
}

tr.row-overdue {
  background: var(--row-overdue-bg);
}

tr.row-overdue:hover {
  background: var(--row-overdue-hover);
}

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

.row-actions .btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
  min-height: 32px;
}

/* Scan Desk UI */
.scan-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: start;
}

.step-indicator {
  display: flex;
  gap: 16px;
  margin-bottom: 22px;
}

.step-box {
  flex: 1;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: var(--brutal-border);
  background: var(--surface);
  box-shadow: var(--brutal-shadow-sm);
}

.step-box.active {
  background: var(--accent-highlight);
  color: var(--accent-highlight-ink);
  border-color: var(--ink);
}

.step-box.active .step-num {
  color: var(--accent-highlight-ink);
}

.step-box.done {
  background: var(--status-available-bg);
  color: var(--status-available-text);
  border-color: var(--status-available-border);
}

.step-num {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
}

.step-title {
  font-size: 0.95rem;
  font-weight: 800;
  margin-top: 2px;
}

.scanner-box {
  border: var(--brutal-border-thick);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--brutal-shadow);
  padding: 22px;
}

.qr-reader-viewport {
  width: 100%;
  min-height: 240px;
  border: var(--brutal-border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 14px 0;
  padding: 14px;
  text-align: center;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
}

.manual-scan-form {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.feedback-banner {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: var(--brutal-border);
  box-shadow: var(--brutal-shadow-xs);
  font-size: 0.92rem;
  font-weight: 700;
}

.feedback-success {
  background: var(--status-available-bg);
  border-color: var(--status-available-border);
  color: var(--status-available-text);
}

.feedback-error {
  background: var(--status-overdue-bg);
  border-color: var(--status-overdue-border);
  color: var(--status-overdue-text);
}

.feedback-info {
  background: var(--status-borrowed-bg);
  border-color: var(--status-borrowed-border);
  color: var(--status-borrowed-text);
}

.summary-kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 12px;
  font-size: 0.9rem;
  margin-top: 12px;
}

.summary-kv dt {
  color: var(--text-muted);
  font-weight: 700;
}

.summary-kv dd {
  margin: 0;
  font-weight: 700;
  color: var(--text-primary);
}

/* QR Code Container & Print Sheet */
.qr-preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px;
  border: var(--brutal-border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.qr-preview-box #modal-qr-target {
  padding: 10px;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 2px solid #111111;
  box-shadow: 3px 3px 0 #111111;
}

.qr-inline-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: var(--brutal-border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.qr-inline-preview-slot {
  width: 68px;
  height: 68px;
  flex-shrink: 0;
  background: #ffffff;
  border: 2px solid #111111;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.qr-inline-preview-slot canvas,
.qr-inline-preview-slot img {
  width: 58px !important;
  height: 58px !important;
  display: block;
}

.student-qr-thumb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: var(--brutal-shadow-xs);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.student-qr-thumb-btn:hover {
  transform: translate(-1px, -1px);
}

.student-qr-thumb {
  width: 38px;
  height: 38px;
  display: block;
}

.print-sheet-header {
  display: none;
}

.qr-print-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 18px;
}

.qr-print-card {
  border: var(--brutal-border-thick);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--brutal-shadow-sm);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  break-inside: avoid;
}

.qr-print-card .qr-slot {
  padding: 8px;
  background: #ffffff;
  border: 2px solid #111111;
  border-radius: var(--radius-md);
}

.qr-print-label {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-primary);
}

.qr-print-id {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.settings-logo-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: var(--brutal-border);
  background: var(--surface-subtle);
}

.settings-logo-preview {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--brutal-shadow-xs);
  border: var(--brutal-border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  overflow: hidden;
}

.settings-logo-preview svg,
.settings-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: var(--brutal-border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--brutal-shadow-xs);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.check-item input {
  width: 18px;
  height: 18px;
  min-height: auto;
  box-shadow: none;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: var(--brutal-border-thick);
  border-radius: var(--radius-lg);
  box-shadow: var(--modal-shadow);
}

.modal-card-sm {
  max-width: 420px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  background: var(--surface-subtle);
  border-bottom: var(--brutal-border);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.modal-body {
  padding: 22px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

.confirm-text {
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Admin Lock Screen */
.auth-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--modal-backdrop);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: var(--brutal-border-thick);
  border-radius: var(--radius-lg);
  box-shadow: var(--modal-shadow);
  padding: 28px;
}

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

.auth-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
}

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

.password-input-wrap input {
  flex: 1;
  min-width: 0;
}

.auth-hint {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: var(--brutal-border);
  background: var(--surface-subtle);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: var(--brutal-border);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  box-shadow: var(--brutal-shadow-sm);
  font-size: 0.86rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: auto;
}

.toast-success {
  background: var(--status-available-bg);
  border-color: var(--status-available-border);
  color: var(--status-available-text);
}

.toast-error {
  background: var(--status-overdue-bg);
  border-color: var(--status-overdue-border);
  color: var(--status-overdue-text);
}

.toast-info {
  background: var(--status-borrowed-bg);
  border-color: var(--status-borrowed-border);
  color: var(--status-borrowed-text);
}

.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

/* Responsive Breakpoints */
@media (max-width: 1080px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .analytics-grid,
  .scan-layout,
  .two-col-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    display: none;
  }

  .mobile-header {
    display: block;
  }

  .main-content {
    padding: 20px 16px 40px;
  }

  .page-header {
    padding: 16px 18px;
  }

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

  .stats-grid .stat-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .manual-scan-form {
    flex-direction: column;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

@media (max-width: 640px) {
  .donut-layout {
    flex-direction: column;
    align-items: center;
  }

  .donut-legend-list {
    width: 100%;
  }

  .chart-footer-stats {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/* Print Styles for QR Sheet */
@media print {

  body,
  [data-theme="dark"] body {
    background: #ffffff;
    background-image: none;
    color: #0f172a;
  }

  .no-print,
  .sidebar,
  .mobile-header,
  .modal-backdrop,
  .auth-backdrop,
  .toast-container {
    display: none !important;
  }

  .main-content {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  .print-sheet-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: 2px solid #111111;
    color: #0f172a;
  }

  .print-sheet-header .school-logo-badge {
    background: #ffffff;
    box-shadow: none;
    border: 1.5px solid #111111;
  }

  .qr-print-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .qr-print-card {
    background: #ffffff;
    box-shadow: none;
    border: 1.5px solid #111111;
    color: #0f172a;
  }

  .qr-print-card .qr-print-label,
  .qr-print-card .qr-print-id {
    color: #0f172a;
  }

  .qr-print-card .qr-slot {
    box-shadow: none;
    border: 1px solid #111111;
  }
}

/* Login screen */
.auth-brand {
  flex-direction: column;
  align-items: center;
  text-align: center;
}

#auth-school-logo {
  width: 140px;
  height: 140px;
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}

#auth-library-name {
  display: inline-block;
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.15;
  background: var(--accent-highlight);
  color: var(--accent-highlight-ink);
  padding: 4px 10px;
  border: var(--brutal-border);
  box-shadow: var(--brutal-shadow-xs);
}

.auth-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Logo badges: show logo without a frame */
.school-logo-badge {
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}

/* Brand text */
.sidebar .brand-title {
  font-size: 1.2rem;
}

.mobile-header-top .brand-title {
  font-size: 1.05rem;
}