:root {
  font-family: "Segoe UI", Arial, sans-serif;
  color: #102a43;
  background: #f2f6fa;
  --nav: #0b3558;
  --nav2: #082944;
  --accent: #0b7ee8;
  --bg: #f2f6fa;
  --card: #fff;
  --line: #d6e2ec;
  --text: #102a43;
  --muted: #627d98;
  --ok: #087f5b;
  --warn: #c26a00;
  --bad: #c92a2a;
  --shadow: 0 8px 24px rgba(8, 41, 68, 0.08);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--accent) 8%, var(--bg)) 0,
    var(--bg) 220px
  );
  min-height: 100vh;
}
header {
  background: linear-gradient(115deg, var(--nav2), var(--nav));
  border-bottom: 3px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 5px 18px rgba(8, 41, 68, 0.2);
}
.bar {
  max-width: 1240px;
  margin: auto;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  font-weight: 700;
  font-size: 1.22rem;
  color: #fff;
  letter-spacing: -0.02em;
}
.brandidentity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brandidentity img {
  width: 42px;
  height: 42px;
  padding: 3px;
  object-fit: contain;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.96);
}
.brandidentity span {
  display: grid;
  min-width: 0;
}
.brandidentity strong,
.brandidentity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brandidentity small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
}
.grow {
  flex: 1;
}
.container {
  max-width: 1240px;
  margin: auto;
  padding: 22px 20px;
}
.card,
.result,
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.card {
  padding: 18px;
  margin-bottom: 16px;
}
.hero {
  padding: 32px 18px;
  text-align: center;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  color: var(--nav);
}
h2,
h3 {
  color: var(--nav);
  letter-spacing: -0.02em;
}
.muted {
  color: var(--muted);
}
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.row > * {
  min-width: 0;
}
input,
select,
textarea,
button {
  font: inherit;
}
input,
select,
textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #b9cad8;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}
input:focus,
select:focus,
textarea:focus {
  outline: 3px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: var(--accent);
}
button,
.btn {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-weight: 600;
}
button:hover,
.btn:hover {
  filter: brightness(0.94);
}
button.secondary,
.btn.secondary {
  background: color-mix(in srgb, var(--accent) 10%, #fff);
  color: var(--nav);
  border-color: color-mix(in srgb, var(--accent) 24%, var(--line));
}
header button.secondary,
header .btn.secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}
button.danger {
  background: var(--bad);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.search {
  display: flex;
  gap: 8px;
  max-width: 760px;
  margin: 18px auto;
}
.search input {
  font-size: 1.05rem;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}
.result {
  padding: 14px;
}
.result h3 {
  margin: 0 0 6px;
}
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e7f1fb;
  font-size: 0.8rem;
}
.ok {
  background: #dff3eb;
  color: var(--ok);
}
.warn {
  background: #fff0d9;
  color: #8b4d00;
}
.bad {
  background: #fde5e5;
  color: #9d2020;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(var(--tab-columns, 8), minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  box-shadow: var(--shadow);
}
.tab {
  background: transparent;
  color: #395b75;
  border-color: transparent;
  padding: 9px 12px;
  width: 100%;
  min-width: 0;
  white-space: nowrap;
}
.tab.active {
  background: var(--nav);
  color: #fff;
}
.hidden {
  display: none !important;
}
.tablewrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}
table {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
}
th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #e3ebf2;
  vertical-align: top;
}
th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.035em;
  color: #45657f;
  background: #edf4f9;
}
tr:hover td {
  background: #f7fafc;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 11px;
}
@media (max-width: 650px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.kpi {
  padding: 15px;
  border-top: 3px solid var(--accent);
  position: relative;
  overflow: hidden;
  min-height: 94px;
}
button.kpi {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-flow: row;
  align-content: center;
  justify-items: start;
  gap: 5px;
  text-align: left;
  background: var(--card);
  color: var(--text);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
button.kpi:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(8, 41, 68, 0.13);
}
.kpi .muted,
.kpi .n {
  display: block;
  width: 100%;
  min-width: 0;
  line-height: 1.1;
}
.kpi .muted {
  white-space: normal;
}
.kpi .n {
  font-size: clamp(1.55rem, 2vw, 2rem);
  font-weight: 750;
  color: var(--nav);
  white-space: nowrap;
  overflow: visible;
}
.formgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}
.msg {
  padding: 11px 13px;
  border-radius: 7px;
  margin: 10px 0;
  background: #e6f2fd;
  border-left: 4px solid var(--accent);
}
.error {
  background: #fde5e5;
  color: #921f1f;
  border-color: var(--bad);
}
.success {
  background: #dff3eb;
  color: #066b4c;
  border-color: var(--ok);
}
.credentialerrordialog {
  width: min(440px, calc(100% - 28px));
  padding: 26px;
  border: 0;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(60, 10, 10, 0.35);
}
.credentialerrordialog::backdrop {
  background: rgba(20, 10, 20, 0.58);
  backdrop-filter: blur(2px);
}
.credentialerrordialog .erroricon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--bad);
  color: #fff;
  font-size: 2rem;
  font-weight: 800;
}

.credentialerrordialog .successicon {
  display: grid;
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.75rem;
  place-items: center;
  border-radius: 50%;
  background: #dcfce7;
  color: #15803d;
  font-size: 1.6rem;
  font-weight: 800;
}
.credentialerrordialog h2 {
  margin: 0;
  color: var(--bad);
}
.credentialerrordialog p {
  margin: 9px 0 18px;
  color: var(--text);
}
.credentialactions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.metric-overdue_items .n,
.metric-open_fines .n {
  color: var(--bad);
}
.metric-available .n {
  color: var(--ok);
}
.metric-borrowed .n {
  color: var(--accent);
}
.sectiontitle {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--nav);
  margin-bottom: 8px;
}
.chartgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  margin: 14px 0;
}
.chartcanvas {
  display: block;
  width: 100%;
  height: 220px;
}
.chartcanvas.wide {
  height: 260px;
}
.quickactions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin: 12px 0 18px;
}
.reportcontrols,
.integration {
  border-left: 5px solid var(--accent);
}
.reporttable {
  max-height: 560px;
}
.reporttable thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}
@media (max-width: 600px) {
  .container {
    padding: 12px;
  }
  .bar {
    padding: 11px 12px;
  }
  .brand {
    font-size: 1.05rem;
  }
  .search {
    flex-direction: column;
  }
  .hero {
    padding: 20px 4px;
  }
  th,
  td {
    padding: 7px;
    font-size: 0.88rem;
  }
  .chartgrid {
    grid-template-columns: 1fr;
  }
  .bar .btn,
  .bar button {
    padding: 8px;
  }
  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .tab {
    white-space: normal;
    line-height: 1.15;
  }
}
@media print {
  header,
  .tabs,
  #msg,
  .reportcontrols,
  .quickactions {
    display: none !important;
  }
  .container {
    max-width: none;
    padding: 0;
  }
  .card,
  .kpi {
    box-shadow: none;
  }
  .panel {
    display: none !important;
  }
  #reports {
    display: block !important;
  }
  .reporttable {
    max-height: none;
    overflow: visible;
  }
  .chartcanvas {
    max-height: 220px;
  }
}
