/* Granite Hill Ledger — dark fantasy, mobile-first */

:root {
  --bg: #120e0a;
  --bg-2: #1a1410;
  --surface: #1e1712;
  --surface-2: #29201735;
  --card: #211913;
  --border: #3d2f1f;
  --border-soft: #2e2317;
  --gold: #d4a94e;
  --gold-dim: #9a7c3d;
  --ember: #c96f2f;
  --text: #ece2cf;
  --muted: #a4917a;
  --ok: #7fb069;
  --warn: #e0a458;
  --bad: #c8553d;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 70% -10%, #2a1d1040, transparent),
    linear-gradient(180deg, var(--bg-2), var(--bg) 300px);
  background-color: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15.5px;
  line-height: 1.55;
  min-height: 100vh;
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
}

h1, h2, h3, .brand-name { font-family: Cinzel, Georgia, serif; letter-spacing: 0.02em; }
h1 { font-size: 1.5rem; margin: 0.2em 0 0.5em; color: var(--gold); }
h2 { font-size: 1.15rem; margin: 1.4em 0 0.5em; color: var(--gold); }
h3 { font-size: 1rem; margin: 1em 0 0.4em; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .muted { color: var(--muted); }

/* --- Top bar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: linear-gradient(180deg, #241a11, #1c140d);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none !important; }
.brand-crest { font-size: 1.7rem; filter: drop-shadow(0 0 6px #d4a94e55); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { color: var(--gold); font-weight: 700; font-size: 1.05rem; }
.brand-sub { color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.18em; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-chip img { width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--gold-dim); }
.user-chip-text { display: flex; flex-direction: column; line-height: 1.15; }
.user-chip-text strong { font-size: 0.85rem; }
.user-chip-text small { font-size: 0.68rem; color: var(--gold-dim); }
@media (max-width: 480px) { .user-chip-text strong { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(180deg, #7a5a23, #5d431a);
  color: #f5ecd8; border: 1px solid var(--gold-dim);
  padding: 9px 16px; border-radius: 10px;
  font: inherit; font-weight: 600; font-size: 0.9rem;
  cursor: pointer; text-decoration: none !important;
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.15); }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-discord { background: linear-gradient(180deg, #5865f2, #4450d8); border-color: #6a76ff; }
.btn-danger { background: linear-gradient(180deg, #8a3b2a, #6d2d20); border-color: #a4573f; }
.btn-ok { background: linear-gradient(180deg, #4c7a3f, #3a6130); border-color: #6f9d5f; }
.btn-block { width: 100%; justify-content: center; }
.btn-support {
  background: linear-gradient(180deg, #c9a227, #9a7418);
  border-color: #e0c15a;
  color: #1a140a;
}
.cta-pair {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center;
}

/* Sister holds + Halfcrest hub on the home page */
.hold-net {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px;
  margin: -4px 0 16px; font-size: 0.86rem; color: var(--muted);
}
.hold-net a { color: var(--gold); text-decoration: none; }
.hold-net a:hover { text-decoration: underline; }
.hold-net-hub { font-weight: 600; }
.hold-net-here { color: var(--text); font-weight: 600; }
.hold-net-sep { opacity: 0.45; padding: 0 2px; }
@media (max-width: 520px) {
  .topbar-right .btn-support { padding: 6px 9px; font-size: 0.72rem; }
  .topbar-right .btn-discord { padding: 6px 10px; font-size: 0.78rem; }
}

/* --- Cards / layout --- */
.content { max-width: 1080px; margin: 0 auto; padding: 18px 14px 30px; }
.grid { display: grid; gap: 14px; }
@media (min-width: 760px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
.card {
  background: linear-gradient(180deg, #221a13, #1d1610);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 4px 18px #00000055;
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.stat {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 12px 14px;
}
.stat .stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.stat .stat-value { font-family: Cinzel, serif; font-size: 1.35rem; color: var(--gold); font-weight: 700; }
.stat .stat-value.ok { color: var(--ok); }
.stat .stat-value.bad { color: var(--bad); }

/* --- Flash --- */
.flash {
  max-width: 1080px; margin: 10px auto 0; padding: 10px 16px;
  border-radius: 10px; font-weight: 500; font-size: 0.9rem;
  transition: opacity 0.6s;
}
.flash-ok { background: #2c3f2455; border: 1px solid #4c7a3f; color: #b9d8ad; }
.flash-err { background: #4f261d55; border: 1px solid #8a3b2a; color: #eab5a7; }
.flash-hide { opacity: 0; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
th { color: var(--gold-dim); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; }
tr:last-child td { border-bottom: none; }
td.wrap { white-space: normal; }

/* --- Badges --- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.03em;
}
.badge-ok { background: #2c3f24; color: #a8d59a; }
.badge-warn { background: #4a3517; color: #eec888; }
.badge-bad { background: #4f261d; color: #eaa392; }
.badge-dim { background: #2a2118; color: var(--muted); }
.badge-gold { background: #4a3a15; color: var(--gold); }

/* --- Forms --- */
form.inline { display: inline; }
.form-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; color: var(--muted); }
input, select, textarea {
  background: #171009; color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 11px; font: inherit; font-size: 0.92rem;
  min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 1.5px solid var(--gold-dim); }
textarea { min-height: 70px; resize: vertical; }

/* --- Feed (mirrored Discord messages) --- */
.feed { display: flex; flex-direction: column; gap: 10px; }
.feed-item {
  display: flex; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 10px 12px;
}
.feed-item img.avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.feed-body { min-width: 0; }
.feed-meta { font-size: 0.75rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.feed-meta strong { color: var(--gold); }
.feed-text { white-space: pre-wrap; word-break: break-word; font-size: 0.92rem; margin-top: 2px; }
.feed-attachment { display: block; margin-top: 6px; max-width: 100%; border-radius: 8px; max-height: 260px; }

/* --- Events --- */
.event-card {
  border-left: 3px solid var(--ember);
  background: var(--surface); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 10px;
}
.event-when { color: var(--warn); font-size: 0.8rem; font-weight: 600; }
.event-title { font-family: Cinzel, serif; font-weight: 700; color: var(--gold); }
.event-body { font-size: 0.9rem; white-space: pre-wrap; }

/* --- On duty pulse --- */
.pulse {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--ok); margin-right: 7px;
  box-shadow: 0 0 0 0 #7fb06988; animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 #7fb06988; }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* --- Bottom navigation (mobile-first) --- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: linear-gradient(180deg, #221912f5, #170f09fa);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  backdrop-filter: blur(8px);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  color: var(--muted); font-size: 0.66rem; font-weight: 600;
  text-decoration: none !important; padding: 4px 10px; border-radius: 10px;
  min-width: 52px;
}
.nav-item span { font-size: 1.25rem; line-height: 1.2; filter: grayscale(0.5) opacity(0.75); }
.nav-item.active { color: var(--gold); background: #d4a94e14; }
.nav-item.active span { filter: none; }

@media (min-width: 900px) {
  body { padding-bottom: 66px; }
  .bottomnav {
    justify-content: center; gap: 6px;
    padding: 6px 16px;
  }
  .nav-item { flex-direction: row; gap: 7px; font-size: 0.85rem; padding: 7px 14px; }
  .nav-item span { font-size: 1.05rem; }
}

/* --- Audit sheet look --- */
.audit-sheet { border: 1px solid var(--gold-dim); border-radius: var(--radius); overflow: hidden; }
.audit-sheet .audit-head {
  background: linear-gradient(180deg, #3a2c15, #2a2011);
  padding: 14px 18px; border-bottom: 1px solid var(--gold-dim);
}
.audit-sheet .audit-head h2 { margin: 0; }
.audit-lines { padding: 6px 0; }
.audit-line {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 7px 18px; font-size: 0.94rem;
}
.audit-line.sub { padding-left: 34px; color: var(--muted); font-size: 0.85rem; }
.audit-line.total {
  border-top: 1px solid var(--gold-dim); margin-top: 6px; padding-top: 12px;
  font-weight: 700; font-family: Cinzel, serif; color: var(--gold);
}
.audit-line .amount { font-variant-numeric: tabular-nums; }

/* Utility */
.mt { margin-top: 14px; }
.row-flex { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
hr.rule { border: none; border-top: 1px solid var(--border-soft); margin: 14px 0; }
