:root {
  --bg: #edeef0;
  --panel: #ffffff;
  --text: #222831;
  --muted: #6f7985;
  --line: #dce1e6;
  --blue: #2787f5;
  --blue-dark: #1d6fd1;
  --soft-blue: #e8f2ff;
  --danger: #e64646;
  --green: #21a366;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
}

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { color: var(--blue); font-size: 22px; font-weight: 700; margin: 0 0 22px; }
.nav-link {
  display: block;
  padding: 10px 12px;
  margin-bottom: 4px;
  color: #2a5885;
  text-decoration: none;
  border-radius: 8px;
}
.nav-link:hover, .nav-link.active { background: var(--soft-blue); color: var(--blue-dark); }
.content { flex: 1; padding: 28px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
h1 { font-size: 28px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0 0 16px; }
p { color: var(--muted); margin: 0; }

.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 14px; }
.stats-grid.compact { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
.stat-card, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.stat-card { padding: 18px; }
.stat-card span { display: block; color: var(--muted); margin-bottom: 10px; }
.stat-card strong { font-size: 30px; color: var(--text); }
.stat-card.danger strong { color: var(--danger); }
.card { padding: 18px; }
.table-card { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 600; background: #f7f8fa; }
tr:hover td { background: #fafcff; }
.wrap { max-width: 320px; white-space: normal; word-break: break-word; }
.muted { color: var(--muted); }
.error-text { color: var(--danger); }
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: 12px; }
.badge.paid { color: var(--green); background: #e9f7ef; }
.badge.unpaid { color: var(--muted); background: #f0f2f5; }
.button-link, button {
  border: 0;
  background: var(--blue);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  padding: 9px 13px;
  cursor: pointer;
  font-weight: 600;
}
.button-link:hover, button:hover { background: var(--blue-dark); }
.profile-grid { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr); gap: 14px; margin-bottom: 14px; }
dl { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }

.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: min(380px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  box-shadow: 0 8px 30px rgba(0,0,0,.08);
}
.login-brand { margin-bottom: 14px; }
.login-card h1 { font-size: 24px; margin-bottom: 18px; }
.login-card label { display: block; color: var(--muted); margin: 14px 0 6px; }
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
}
.login-card button { width: 100%; margin-top: 18px; }
.alert { background: #ffefef; color: var(--danger); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.empty-card { max-width: 520px; }

@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar { width: auto; height: auto; position: static; }
  .content { padding: 18px; }
  .stats-grid, .stats-grid.compact, .profile-grid { grid-template-columns: 1fr; }
}

.media-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 140px;
}

.thumb-link {
  display: inline-block;
  width: 120px;
  height: 90px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f5f7fa;
}

.media-thumb {
  width: 120px;
  height: 90px;
  object-fit: cover;
  display: block;
}

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

.small-link {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--soft-blue);
  color: var(--blue-dark);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.small-link:hover {
  background: #d9eaff;
}

.muted-link {
  color: var(--muted);
  background: #f0f2f5;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox.open {
  display: flex;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .72);
}

.lightbox-image {
  position: relative;
  z-index: 1;
  max-width: min(1100px, 94vw);
  max-height: 90vh;
  border-radius: 10px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .35);
  background: #fff;
}

@media (max-width: 900px) {
  .media-cell { min-width: 128px; }
  .thumb-link, .media-thumb { width: 120px; height: 90px; }
  .media-actions { flex-direction: column; align-items: flex-start; }
  .lightbox { padding: 12px; }
}

.report-box {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8fa;
  color: var(--text);
  font: inherit;
  line-height: 1.55;
  white-space: pre-wrap;
}

.filter-card, .form-card { margin-bottom: 14px; }
.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}
.inline-form label { color: var(--muted); font-size: 13px; }
.inline-form input, .inline-form select {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  font: inherit;
  color: var(--text);
  background: #fff;
}
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.check-item {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8fa;
}
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.danger-button { background: var(--danger); padding: 7px 10px; }
.danger-button:hover { background: #c73535; }
@media (max-width: 900px) {
  .inline-form, .checkbox-grid { grid-template-columns: 1fr; }
}
