:root {
  --bg: #14161c;
  --bg2: #101217;
  --panel: #1a1d26;
  --border: #262b38;
  --border2: #232733;
  --text: #d9dce3;
  --muted: #6b7180;
  --dim: #8b91a0;
  --gold: #e8b04a;
  --gold-dim: #e8b04a55;
  --green: #4ade80;
  --red: #f87171;
  --blue: #60a5fa;
  --input: #12151c;
  --radius: 10px;
  --font: Inter, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
button, .btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
}
.btn-primary, button.primary {
  background: var(--gold);
  color: #14161c;
  border-color: var(--gold);
  font-weight: 600;
}
.btn-primary:hover, button.primary:hover { filter: brightness(1.05); }
.btn-danger { color: var(--red); border-color: #5a2a2a; background: #241618; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-dim);
}
label { display: block; color: var(--dim); font-size: 12.5px; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.err {
  background: #2a1618;
  border: 1px solid #5a2a2a;
  color: #fca5a5;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
}
.ok {
  background: #16241c;
  border: 1px solid #3a6b4a;
  color: #7ee2a0;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
}

/* Auth */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 0%, #e8b04a14, transparent 50%),
    radial-gradient(ellipse at 80% 100%, #3a2f1811, transparent 45%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}
.brand b {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--gold); color: #14161c;
  display: grid; place-items: center; font-size: 17px;
}
.auth-sub { color: var(--muted); margin-bottom: 22px; font-size: 13.5px; }
.auth-card h1 { font-size: 20px; color: #fff; margin-bottom: 16px; }
.auth-footer { margin-top: 18px; color: var(--muted); font-size: 13px; text-align: center; }
.demo-hint {
  margin-top: 16px;
  padding: 10px 12px;
  background: #12151c;
  border: 1px dashed #2a2f3c;
  border-radius: 8px;
  color: var(--dim);
  font-size: 12.5px;
}
.demo-hint code { color: var(--gold); }

/* App shell */
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}
.side {
  background: var(--bg2);
  border-right: 1px solid var(--border2);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side .brand { padding: 0 8px 18px; font-size: 20px; }
.sec {
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--muted);
  font-weight: 600;
  margin: 16px 10px 6px;
}
.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #aab0bd;
  font-size: 14px;
}
.nav:hover { background: #1a1d26; color: #fff; text-decoration: none; }
.nav.on {
  background: #1e2230;
  color: #fff;
  box-shadow: inset 3px 0 0 var(--gold);
}
.nav.on i, .nav.on .ico { color: var(--gold); }
.nav .ico { width: 18px; text-align: center; opacity: .85; }
.side-foot {
  margin-top: auto;
  border-top: 1px solid var(--border2);
  padding-top: 12px;
}
.chip {
  background: #1a1d26;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.chip .n { color: #fff; font-weight: 600; }
.chip .z { color: var(--muted); font-size: 12px; margin-top: 2px; }

.main { padding: 26px 34px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.top h1 { font-size: 26px; color: #fff; font-weight: 700; margin-right: auto; }
.pill {
  border: 1px solid #3a6b4a;
  color: #7ee2a0;
  background: #16241c;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
}
.pill.gold {
  border-color: #6b5420;
  color: var(--gold);
  background: #2a2314;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.panel h2 { font-size: 16px; color: #fff; margin-bottom: 4px; }
.panel .h { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; gap: 14px; align-items: center;
}
.card .ic {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px;
  background: #3a2f18; color: var(--gold);
}
.card .lbl { color: var(--dim); font-size: 12.5px; }
.card .val { font-size: 24px; font-weight: 700; color: #fff; }
.card .sub { color: var(--muted); font-size: 12px; }

.group-list { display: grid; gap: 12px; }
.group-item {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
}
.group-item:hover { border-color: #3a4050; text-decoration: none; }
.group-item .gname { font-size: 16px; font-weight: 600; color: #fff; }
.group-item .gmeta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.group-item .grow { margin-left: auto; color: var(--gold); font-size: 13px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 14px;
}
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; align-items: center; }

/* Tabs stay in the document. [hidden] only changes which panel is shown. */
.group-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}
.group-panel[hidden] { display: none !important; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border2); margin-bottom: 4px; }
.tab {
  padding: 10px 16px;
  color: var(--dim);
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
}
.tab:hover { color: #fff; text-decoration: none; }
.tab.on {
  color: #fff;
  background: var(--panel);
  border-color: var(--border);
  box-shadow: inset 0 -2px 0 var(--gold);
}

/* Loot table */
.table-wrap { overflow-x: auto; }
table.loot {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.loot th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border2);
  white-space: nowrap;
}
table.loot td {
  padding: 10px;
  border-bottom: 1px solid #1e2230;
  vertical-align: top;
}
table.loot tr:hover td { background: #1c2030; }
table.loot .loot-name { color: #c084fc; font-weight: 600; }
table.loot .share {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
table.loot .muted { color: var(--muted); }
table.loot .att { max-width: 220px; color: var(--dim); font-size: 12.5px; }
.actions { display: flex; gap: 6px; }

/* .form-grid sets display:grid, which overrides the UA display:none for
   closed <details>. Those edit inputs then stay in layout and autofill. */
details.edit-row:not([open]) > :not(summary) { display: none; }
details.edit-row { margin-top: 6px; }
details.edit-row summary {
  cursor: pointer;
  color: var(--dim);
  font-size: 12px;
  list-style: none;
}
details.edit-row summary::-webkit-details-marker { display: none; }
details.edit-row[open] summary { margin-bottom: 8px; color: var(--gold); }

/* Chat */
.chat-layout {
  display: grid;
  grid-template-rows: 1fr auto;
  height: min(62vh, 560px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-log {
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg { max-width: 720px; }
.msg .who {
  font-size: 12.5px;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 2px;
}
.msg .when { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 11.5px; }
.msg .body {
  background: #12151c;
  border: 1px solid #222733;
  border-radius: 8px;
  padding: 8px 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.mine .who { color: #7ee2a0; }
.msg.mine .body { border-color: #2a3d30; background: #142018; }
.chat-compose {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border2);
  background: var(--bg2);
}
.chat-compose input { flex: 1; }
.chat-status { font-size: 12px; color: var(--muted); padding: 0 18px 8px; }
.chat-status.live::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  margin-right: 6px;
}

.members { display: grid; gap: 8px; }
.member {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: #12151c;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.member .avatar {
  width: 34px; height: 34px; border-radius: 8px;
  background: #3a2f18; color: var(--gold);
  display: grid; place-items: center; font-weight: 700;
}
.member .name { color: #fff; font-weight: 600; }
.member .meta { color: var(--muted); font-size: 12px; }
.role-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid #6b5420;
  color: var(--gold);
  background: #2a2314;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.invite-box {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 12px;
}
.invite-box input { flex: 1; min-width: 220px; font-family: ui-monospace, monospace; font-size: 12.5px; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 36px 16px;
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 18px 16px; }
}

.member .actions-inline, .member form { margin-left: 8px; }
.inline-delete { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--muted); font-weight: 400; font-size: 12.5px; }

.name-suggest {
  position: fixed;
  z-index: 50;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #12151c;
  border: 1px solid #3a4050;
  border-radius: 8px;
  box-shadow: 0 12px 28px #000c;
  max-height: 220px;
  overflow-y: auto;
}
.name-suggest li {
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
.name-suggest li.active,
.name-suggest li:hover {
  background: #2a2314;
  color: var(--gold);
}
