/* SMS - Sponsorship & Contracts Management System */

:root {
  --red: #d5242c;
  --red-dark: #a81b22;
  --red-soft: #fdecec;
  --ink: #1c1e21;
  --ink-soft: #5c626b;
  --line: #e3e6ea;
  --bg: #f4f5f7;
  --card: #ffffff;
  --green: #1e8e3e;
  --green-soft: #e6f4ea;
  --amber: #b26a00;
  --amber-soft: #fdf3e1;
  --blue: #1a63c9;
  --blue-soft: #e8f0fd;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 24, 31, 0.08), 0 4px 14px rgba(20, 24, 31, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}

button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- App shell ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: #1b1d22;
  color: #cfd3da;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid #2b2e35;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar .brand .brand-logo {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}
.sidebar .brand .logo {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
}
.sidebar .brand .logo span { color: var(--red); }
.sidebar .brand .sub { font-size: 11.5px; color: #8a8f99; margin-top: 3px; }

.nav { padding: 12px 10px; flex: 1; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: 8px;
  color: #cfd3da;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.nav a:hover { background: #26292f; color: #fff; }
.nav a.active { background: var(--red); color: #fff; }
.nav a .ico { width: 20px; text-align: center; }

.sidebar .userbox {
  padding: 14px 18px;
  border-top: 1px solid #2b2e35;
  font-size: 13px;
}
.sidebar .userbox .name { color: #fff; font-weight: 600; }
.sidebar .userbox a { color: #8a8f99; text-decoration: none; font-size: 12.5px; }
.sidebar .userbox a:hover { color: #fff; }

.main { flex: 1; padding: 26px 32px 60px; min-width: 0; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 14px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Cards / layout ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 15.5px; font-weight: 700; }
.card h2 .count { color: var(--ink-soft); font-weight: 500; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-row-label {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  margin: 0 2px 8px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.stat .label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.4px; }
.stat .value { font-size: 24px; font-weight: 800; margin-top: 4px; }
.stat .value.red { color: var(--red); }
.stat .value.green { color: var(--green); }
.stat .value.amber { color: var(--amber); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #f1f2f4; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.danger { color: var(--red); border-color: #f2c6c8; }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink-soft);
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #f8f9fa; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: none; }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: #eef0f2;      /* default for custom kinds/labels */
  color: var(--ink-soft);
}
.badge.active { background: var(--green-soft); color: var(--green); }
.badge.expired { background: var(--red-soft); color: var(--red); }
.badge.upcoming { background: var(--blue-soft); color: var(--blue); }
.badge.draft { background: #eef0f2; color: var(--ink-soft); }
.badge.cancelled { background: #eef0f2; color: var(--ink-soft); text-decoration: line-through; }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.physical { background: var(--blue-soft); color: var(--blue); }
.badge.digital { background: #f0e8fd; color: #6b34c9; }

/* ---------- Forms ---------- */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid .field { min-width: 0; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field select, .field input { width: 100%; min-width: 0; box-sizing: border-box; }
.money-wrap { position: relative; }
.money-wrap::before {
  content: "$";
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  font-size: 13px;
  pointer-events: none;
}
.money-wrap input { padding-left: 21px; }

.calc-value {
  padding: 8px 10px;
  background: #f1f2f4;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--red); }
.field textarea { resize: vertical; min-height: 70px; }

.inline-add { display: flex; gap: 8px; }
.inline-add input, .inline-add select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; }
.inline-add input { flex: 1; }

.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }
.error-text { color: var(--red); font-size: 13.5px; margin-top: 8px; }
.empty {
  padding: 26px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- Alert banners ---------- */

.banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 14px;
  border: 1px solid transparent;
}
.banner.warn { background: var(--amber-soft); border-color: #f0d9ab; color: #7a4b00; }
.banner.danger { background: var(--red-soft); border-color: #f2c6c8; color: var(--red-dark); }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 20, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.modal.wide { max-width: 980px; }
.modal h2 { margin: 0 0 16px; font-size: 17px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Room map ---------- */

.room-map-wrap { position: relative; user-select: none; }
.room-map {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #2f4d33;
  background-size: cover;
  background-position: center;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: default;
}
.room-map.editing { cursor: crosshair; }
.room-map .grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.07) 1px, transparent 1px);
  background-size: 5% 8.888%;
  pointer-events: none;
}
.loc {
  position: absolute;
  border: 2px solid;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  padding: 2px;
  overflow: hidden;
  line-height: 1.15;
}
.loc.available { background: rgba(30, 142, 62, 0.35); border-color: #4bd47c; color: #eafff0; cursor: pointer; }
.loc.available:hover { background: rgba(30, 142, 62, 0.6); }
.loc.occupied { background: rgba(213, 36, 44, 0.45); border-color: #ff7b81; color: #fff; cursor: pointer; }
.loc.pending { background: rgba(216, 138, 0, 0.5); border-color: #ffc14d; color: #fff; cursor: pointer; }
.loc.editing { background: rgba(26, 99, 201, 0.4); border-color: #7db1f7; color: #fff; cursor: move; }
.loc.selected { outline: 3px solid #fff; }
.loc .loc-value { display: block; font-weight: 400; font-size: 10.5px; opacity: 0.9; }
.loc.highlight {
  outline: 3px solid #ffd42a;
  box-shadow: 0 0 14px rgba(255, 212, 42, 0.9);
  z-index: 2;
}
.loc.dimmed { opacity: 0.25; }
.loc .resize-handle {
  position: absolute;
  right: -1px; bottom: -1px;
  width: 12px; height: 12px;
  background: #fff;
  border-radius: 3px 0 3px 0;
  cursor: nwse-resize;
}
.map-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12.5px; color: var(--ink-soft); flex-wrap: wrap; }
.map-legend .key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.room-list { display: flex; flex-direction: column; gap: 6px; }
.room-list .room-group-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  margin: 8px 2px 2px;
}
.room-list .room-group-label:first-child { margin-top: 0; }
.room-list button {
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}
.room-list button:hover { background: #f6f7f8; }
.room-list button.active { border-color: var(--red); background: var(--red-soft); font-weight: 600; }
.room-list .room-type { display: block; font-size: 12px; color: var(--ink-soft); }

/* ---------- Item rows (in-kind, assets) ---------- */

.item-rows { display: flex; flex-direction: column; gap: 10px; }
.item-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
  flex-wrap: wrap;
}
.item-row .field { min-width: 130px; flex: 1; }
.item-row .field.grow { flex: 2; }
.item-row .row-remove { margin-top: 22px; }
.item-row .placement-info { font-size: 12.5px; margin-top: 4px; }

/* ---------- Docs ---------- */

.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
  font-size: 14px;
}
.doc-item a { color: var(--blue); text-decoration: none; font-weight: 600; }
.doc-item a:hover { text-decoration: underline; }
.doc-item .meta { color: var(--ink-soft); font-size: 12.5px; margin-left: auto; }

/* ---------- Login ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1b1d22;
}
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 36px 34px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-card .login-logo {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto 14px;
}
.login-card .logo { font-size: 26px; font-weight: 800; text-align: center; }
.login-card .logo span { color: var(--red); }
.login-card .sub { text-align: center; color: var(--ink-soft); font-size: 13px; margin: 4px 0 24px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }

/* ---------- Chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid #bfe3cb;
  border-radius: 16px;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 600;
}
.chip button {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  opacity: 0.7;
}
.chip button:hover { opacity: 1; }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  padding: 9px 16px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.tabs button.active { color: var(--red); border-bottom-color: var(--red); }

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1b1d22;
  color: #fff;
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--red-dark); }

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav { display: flex; flex-wrap: wrap; }
  .main { padding: 18px 14px 50px; }
}
