:root {
  --ink: #172126;
  --muted: #647178;
  --paper: #f4f6f4;
  --surface: #ffffff;
  --line: #dfe5e1;
  --brand: #164f45;
  --brand-deep: #0d3831;
  --brand-soft: #e2f0eb;
  --accent: #e67d31;
  --accent-soft: #fff0e4;
  --danger: #b63d42;
  --danger-soft: #fdebec;
  --warning: #b66b16;
  --warning-soft: #fff4dd;
  --success: #267257;
  --shadow: 0 14px 35px rgba(23, 33, 38, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, .button { cursor: pointer; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr);
  background: var(--surface);
}
.login-visual {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(32px, 6vw, 88px);
  color: #fff;
  background:
    radial-gradient(circle at 82% 16%, rgba(230,125,49,.36), transparent 28%),
    linear-gradient(145deg, #0b302a 0%, #16574b 65%, #1f6c5d 100%);
}
.login-visual::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  right: -160px;
  bottom: -150px;
  box-shadow: 0 0 0 48px rgba(255,255,255,.035), 0 0 0 96px rgba(255,255,255,.025);
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: .04em;
}
.brand-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--brand-deep);
  background: #fff;
  border-radius: 12px;
  font-weight: 900;
}
.login-copy { position: relative; z-index: 1; max-width: 680px; }
.eyebrow {
  display: inline-block;
  margin-bottom: 16px;
  color: #b9dfd3;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.login-copy h1 {
  max-width: 620px;
  margin: 0 0 18px;
  font-size: clamp(40px, 6vw, 78px);
  line-height: .98;
  letter-spacing: -.055em;
}
.login-copy p { max-width: 560px; color: #d7ebe5; font-size: 18px; }
.login-panel {
  display: grid;
  place-items: center;
  padding: 32px;
}
.login-card { width: min(100%, 430px); }
.login-card h2 { margin: 0 0 8px; font-size: 32px; letter-spacing: -.03em; }
.login-card > p { margin: 0 0 30px; color: var(--muted); }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: 260px;
  padding: 26px 18px 20px;
  color: #e7f1ee;
  background: var(--brand-deep);
}
.sidebar .brand-mark { padding: 0 10px 28px; }
.sidebar .brand-icon { color: #fff; background: var(--accent); }
.nav-section {
  margin: 12px 12px 8px;
  color: #83a89e;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  margin: 3px 0;
  padding: 0 13px;
  color: #c4d8d2;
  border-radius: 12px;
  font-weight: 650;
}
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(255,255,255,.1); }
.nav-glyph {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  font-size: 15px;
  font-weight: 850;
}
.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 0;
  border-top: 1px solid rgba(255,255,255,.12);
}
.user-chip { font-size: 13px; color: #a9c4bd; }
.user-chip strong { display: block; margin-bottom: 3px; color: #fff; font-size: 14px; }
.logout-link { display: inline-block; margin-top: 12px; color: #efb28a; font-size: 13px; }

.main { margin-left: 260px; padding: 26px clamp(22px, 4vw, 56px) 60px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  margin-bottom: 26px;
}
.topbar h1 { margin: 0; font-size: clamp(27px, 3vw, 38px); letter-spacing: -.04em; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.clock-card {
  min-width: 100px;
  padding: 10px 16px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.clock-card strong { display: block; font-size: 20px; }
.clock-card span { color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.menu-toggle { display: none; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  color: #fff;
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 11px;
  font-weight: 750;
  transition: transform .16s ease, box-shadow .16s ease;
}
.button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(22,79,69,.18); }
.button.accent { background: var(--accent); border-color: var(--accent); }
.button.light { color: var(--brand); background: var(--surface); border-color: var(--line); }
.button.danger { color: var(--danger); background: var(--danger-soft); border-color: #f5cfd1; }
.button.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.button.full { width: 100%; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  position: relative;
  min-height: 146px;
  padding: 22px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 18px rgba(23,33,38,.035);
}
.stat-card::after {
  content: "";
  position: absolute;
  width: 76px;
  height: 76px;
  right: -20px;
  bottom: -22px;
  background: var(--brand-soft);
  border-radius: 50%;
}
.stat-card.warning::after { background: var(--warning-soft); }
.stat-card.danger::after { background: var(--danger-soft); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.stat-value { margin: 12px 0 3px; font-size: 38px; font-weight: 850; letter-spacing: -.05em; }
.stat-note { color: var(--muted); font-size: 13px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr); gap: 20px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 5px 22px rgba(23,33,38,.04);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2, .panel-head h3 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.panel-body { padding: 20px; }
.panel-empty { padding: 48px 24px; color: var(--muted); text-align: center; }
.panel-empty strong { display: block; margin-bottom: 6px; color: var(--ink); font-size: 17px; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
.data th {
  padding: 12px 16px;
  color: var(--muted);
  background: #fafbf9;
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.data td { padding: 15px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.data tbody tr:hover { background: #fbfcfb; }
.person strong, .tool-name strong { display: block; }
.person small, .tool-name small { color: var(--muted); }
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 800;
  border-radius: 99px;
  text-transform: uppercase;
}
.status::before { content: ""; width: 7px; height: 7px; background: currentColor; border-radius: 50%; }
.status.active { color: var(--warning); background: var(--warning-soft); }
.status.overdue { color: var(--danger); background: var(--danger-soft); }
.status.returned { color: var(--success); background: var(--brand-soft); }
.status.partial { color: #596caf; background: #eef0fb; }
.status.available { color: var(--success); background: var(--brand-soft); }
.status.unavailable { color: var(--danger); background: var(--danger-soft); }
.due-time { font-weight: 750; }
.due-time.overdue { color: var(--danger); }

.quick-card {
  padding: 25px;
  color: #fff;
  background: linear-gradient(145deg, var(--brand-deep), var(--brand));
  border-radius: var(--radius);
}
.quick-card .eyebrow { margin-bottom: 10px; }
.quick-card h2 { margin: 0 0 10px; font-size: 28px; letter-spacing: -.035em; }
.quick-card p { margin: 0 0 22px; color: #cae0da; }
.quick-card .button { color: var(--brand-deep); background: #fff; border-color: #fff; }
.cutoff {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding: 15px;
  color: #dbece7;
  background: rgba(255,255,255,.09);
  border-radius: 12px;
  font-size: 13px;
}
.cutoff strong { color: #fff; }

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.search {
  width: min(100%, 420px);
  min-height: 44px;
  padding: 0 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
}
.search:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: #72a99b;
  box-shadow: 0 0 0 3px rgba(22,79,69,.1);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.tool-card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.tool-photo {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  color: #81918b;
  background: linear-gradient(145deg, #edf2ef, #e4ebe7);
  font-size: 36px;
  font-weight: 900;
}
.tool-photo img { width: 100%; height: 100%; object-fit: cover; }
.tool-card-body { padding: 17px; }
.tool-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tool-card h3 { margin: 0 0 3px; font-size: 17px; }
.tool-card p { margin: 10px 0 15px; color: var(--muted); font-size: 13px; }
.tool-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.tool-actions { display: flex; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }

.form-card { max-width: 980px; padding: clamp(20px, 4vw, 34px); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 800; letter-spacing: .03em; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 45px;
  padding: 10px 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d7ded9;
  border-radius: 10px;
  outline: none;
}
.field textarea { min-height: 95px; resize: vertical; }
.field small { color: var(--muted); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.photo-preview { width: 160px; height: 105px; margin-top: 8px; object-fit: cover; border-radius: 10px; }

.loan-tool-list { display: grid; gap: 9px; margin-top: 12px; }
.loan-tool-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 100px;
  align-items: center;
  gap: 13px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border .15s ease, background .15s ease;
}
.loan-tool-row.selected-tool { background: var(--brand-soft); border-color: #9cc8ba; }
.mini-photo { display: grid; place-items: center; width: 48px; height: 48px; overflow: hidden; color: var(--brand); background: #eaf0ed; border-radius: 9px; font-weight: 850; }
.mini-photo img { width: 100%; height: 100%; object-fit: cover; }
.qty-input { width: 78px; min-height: 40px; padding: 7px; text-align: center; border: 1px solid var(--line); border-radius: 9px; }
.loan-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.summary-box { padding: 15px; background: #f8faf8; border: 1px solid var(--line); border-radius: 12px; }
.summary-box span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 800; }
.summary-box strong { display: block; margin-top: 6px; }
.return-input { width: 72px; min-height: 38px; text-align: center; border: 1px solid var(--line); border-radius: 8px; }

.flash { margin-bottom: 18px; padding: 13px 16px; border-radius: 11px; font-weight: 650; }
.flash.success { color: #185b44; background: #dff1e9; border: 1px solid #b9dfd1; }
.flash.error { color: #8f2e33; background: var(--danger-soft); border: 1px solid #f1c6c9; }
.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 15px 18px;
  color: #8b2f34;
  background: var(--danger-soft);
  border: 1px solid #f1c6c9;
  border-radius: 13px;
}
.alert-banner strong { display: block; }
.alert-banner span { font-size: 13px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { min-height: 330px; padding: 34px 26px; }
  .login-copy h1 { font-size: 44px; }
  .login-panel { padding: 38px 22px; }
  .sidebar {
    width: min(290px, 86vw);
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.is-open { transform: translateX(0); }
  .main { margin-left: 0; padding: 18px 16px 42px; }
  .menu-toggle {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 11px;
  }
  .topbar { align-items: flex-start; }
  .topbar h1 { font-size: 28px; }
  .clock-card { display: none; }
  .stats-grid { gap: 10px; }
  .stat-card { min-height: 128px; padding: 18px; }
  .stat-value { font-size: 32px; }
  .tools-grid, .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .toolbar { flex-direction: column; }
  .search { width: 100%; }
  .loan-tool-row { grid-template-columns: 48px minmax(0,1fr) 72px; }
  .loan-summary { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-note { font-size: 11px; }
  .top-actions .button span { display: none; }
  .data th, .data td { padding: 12px 10px; }
}

