/* =====================================================================
   Germany · Minecraft Civilisation — design system
   Style: flat / minimalist SaaS dashboard with a sidebar navigation,
   Kaiserreich (German Empire, 1871) look:
     * near-black sidebar with a gold heraldic eagle,
     * black-white-red tricolor accents (sidebar + card top borders),
     * parchment-light content, flat white cards, no heavy shadows,
     * bold serif headings (Playfair Display → Georgia fallback),
     * iron-cross markers on the stat values, gold points, Reich red.
   ===================================================================== */

:root {
  --bg: #f4f1e9;            /* parchment content background */
  --bg-2: #ece7da;
  --panel: #ffffff;         /* cards */
  --panel-2: #f6f2e8;       /* subtle surfaces, inputs */
  --line: #e3dccb;          /* hairline borders */
  --text: #29241b;
  --muted: #7c7361;
  --gold: #9c7a1e;          /* points & highlights (readable on light) */
  --gold-dim: #b3922f;
  --red: #a31621;           /* Reich red */
  --red-soft: #bb2e2e;
  --green: #2e7d32;
  --blue: #33578f;
  --purple: #6a4fa3;
  --orange: #b45f06;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 14px 36px rgba(66, 50, 24, .16);
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sidebar-bg: #1c1712;
  --sidebar-line: #302820;
  --sidebar-text: #cfc4ad;
  /* the Reich tricolor: black - white(cream) - red */
  --tri-black: #2b2926;
  --tri-white: #efe8da;
  --tri-red: #a31621;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

code { font-family: var(--mono); background: var(--panel-2); padding: 1px 6px; border-radius: 6px; color: var(--text); }

h1, h2, h3, h4 {
  line-height: 1.25; margin: 0 0 .5em;
  font-family: var(--font-serif);
  font-weight: 700;
}
h1 { font-size: 1.75rem; letter-spacing: -.005em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
/* the hidden attribute must always win over the class rules below */
[hidden] { display: none !important; }

.gold { color: var(--gold); }
.green { color: var(--green); }
.red { color: var(--red); }
.orange { color: var(--orange); }

/* --- tricolor strip above everything ---------------------------------- */
.flag-strip {
  position: fixed; inset: 0 0 auto 0; height: 3px; display: flex; z-index: 60;
}
.flag-strip span { flex: 1; }
.flag-strip span:nth-child(1) { background: var(--tri-black); }
.flag-strip span:nth-child(2) { background: var(--tri-white); }
.flag-strip span:nth-child(3) { background: var(--tri-red); }

/* =====================================================================
   Shell: sidebar + main column
   ===================================================================== */
.shell { display: flex; min-height: 100vh; }

/* --- sidebar ---------------------------------------------------------- */
.sidebar {
  width: 252px; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; z-index: 40;
  display: flex; flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(0, 0, 0, .25);
  margin-top: 3px;                       /* below the flag strip */
  color: var(--sidebar-text);
}

.sidebar-head { padding: 16px 16px 4px; }
.brand { display: flex; align-items: center; gap: 11px; color: #f3ede0; }
.brand:hover { text-decoration: none; }
.eagle { width: 44px; height: 44px; flex-shrink: 0; color: #c9a227; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong {
  font-family: var(--font-serif); font-size: 1.02rem;
  letter-spacing: .05em; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text small { color: #8f8368; font-size: .7rem; }

.tricolor {
  display: flex; flex-direction: column; height: 9px;
  margin: 10px 16px 8px; border-radius: 2px; overflow: hidden;
  border: 1px solid rgba(243, 237, 224, .28);
}
.tricolor span { flex: 1; }
.tricolor span:nth-child(1) { background: #0a0908; }
.tricolor span:nth-child(2) { background: #efe8da; }
.tricolor span:nth-child(3) { background: var(--tri-red); }

.snav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.snav-label {
  margin: 14px 8px 5px; font-size: .66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em; color: #8f8368;
}
.snav a {
  display: block; padding: 7px 10px; border-radius: 8px;
  border-left: 3px solid transparent;
  color: var(--sidebar-text); font-size: .9rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.snav a:hover { color: #fff; background: rgba(255, 255, 255, .06); text-decoration: none; }
.snav a.active {
  color: #fff; background: rgba(163, 22, 33, .26);
  border-left-color: var(--red-soft); font-weight: 600;
}

.snav-admin { margin-top: 10px; }
.snav-admin summary {
  cursor: pointer; list-style: none; user-select: none;
  padding: 7px 10px; border-radius: 8px; color: var(--gold-dim);
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em;
}
.snav-admin summary::-webkit-details-marker { display: none; }
.snav-admin summary::after { content: "▸"; float: right; }
.snav-admin[open] summary::after { content: "▾"; }
.snav-admin summary:hover { background: rgba(255, 255, 255, .05); }
.snav-admin a { padding-left: 18px; }

.sidebar-foot {
  padding: 12px; border-top: 1px solid var(--sidebar-line);
  display: flex; flex-direction: column; gap: 9px;
}
.side-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 9px; border-radius: 10px; color: var(--sidebar-text);
}
.side-user:hover { background: rgba(255, 255, 255, .05); text-decoration: none; }
.side-user-col { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.side-user-col .user-name {
  color: #f3ede0; font-weight: 600; font-size: .88rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-user .points { color: var(--gold-dim); font-weight: 700; font-size: .82rem; }
.side-user .points small { color: #8f8368; font-weight: 500; }
.sidebar .btn-ghost { color: var(--sidebar-text); border-color: #3a332a; }
.sidebar .btn-ghost:hover { color: #fff; border-color: #554c3f; }

/* --- main column -------------------------------------------------------- */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30; margin-top: 3px;
  background: rgba(244, 241, 233, .93);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 22px;
  display: flex; align-items: center; gap: 12px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.server-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 5px 11px; border-radius: 999px; font-size: .8rem; color: var(--muted);
}
.server-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.server-chip.is-online .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(46,125,50,.18); }
.server-chip.is-offline .dot { background: var(--red-soft); }

.icon-btn {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  color: var(--text); width: 36px; height: 36px; border-radius: 9px;
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); }
/* the little red counter on the bell / sound button */
.icon-btn .badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff;
  font-size: .68rem; font-weight: 700; display: grid; place-items: center;
}
.nav-toggle { display: none; }

.user-chip {
  display: flex; align-items: center; gap: 8px; background: var(--panel);
  border: 1px solid var(--line); padding: 5px 11px; border-radius: 999px; font-size: .85rem;
  color: var(--text);
}
.user-chip:hover { text-decoration: none; border-color: #cfc5ae; }
.user-chip .user-name { font-weight: 600; }
.user-chip .points { color: var(--gold); font-weight: 700; }
.user-chip .points small { color: var(--muted); font-weight: 500; }

/* --- dropdown (notification bell) --------------------------------------- */
/* flex so the bell and the sound button sit next to each other, not stacked */
.bell-wrap { position: relative; display: flex; align-items: center; gap: 10px; }
.dropdown {
  position: absolute; right: 0; top: 44px; width: 340px; max-width: 92vw;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; z-index: 70;
}
.dropdown-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 13px; border-bottom: 1px solid var(--line); font-size: .9rem;
}
.dropdown-actions { display: flex; gap: 12px; align-items: center; }
.bell-list { max-height: 340px; overflow: auto; }
.bell-item {
  display: block; padding: 10px 13px; border-bottom: 1px solid var(--line);
  color: var(--text); font-size: .87rem; position: relative;
}
.bell-item:hover { background: var(--panel-2); text-decoration: none; }
.bell-item.unread { background: #fbf5e6; border-left: 3px solid var(--red); }
.bell-item .bell-body { color: var(--muted); font-size: .8rem; white-space: pre-line; }
.bell-item .bell-time { color: var(--muted); font-size: .72rem; }
.bell-link { color: var(--text); display: block; padding-right: 26px; }
.bell-link:hover { color: var(--red); text-decoration: none; }
.bell-del {
  position: absolute; top: 8px; right: 8px; width: 20px; height: 20px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--muted); font-size: .8rem; line-height: 1; cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.bell-del:hover { background: #f6dede; color: var(--red); border-color: var(--red-soft); }
/* the badge on the bell stays red - the generic .badge class would grey it out */
#bell-badge {
  background: var(--red); color: #fff; border: 0; padding: 0 5px;
  display: grid; place-items: center;
}

/* --- announcement + flashes ------------------------------------------ */
.announcement {
  background: linear-gradient(90deg, rgba(163,22,33,.10), rgba(201,162,39,.14));
  border-top: 1px solid var(--line); padding: 7px 20px;
  font-size: .87rem; text-align: center;
}
.flashes { max-width: 1240px; margin: 14px auto 0; padding: 0 22px; display: grid; gap: 8px; }
.flash {
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: .9rem;
  border: 1px solid var(--line); background: var(--panel); position: relative; padding-right: 34px;
}
.flash-success { border-color: #bcd4b6; background: #eef5ec; color: #1d4a20; }
.flash-error   { border-color: #e3b8b8; background: #faecec; color: #7c1218; }
.flash-warning { border-color: #e6cfa8; background: #faf3e2; color: #6e4a0e; }
.flash-info    { border-color: #b9c9e3; background: #edf2f9; color: #24406b; }
.flash-close {
  position: absolute; right: 8px; top: 6px; background: none; border: 0;
  color: var(--muted); font-size: 1.1rem; cursor: pointer;
}

/* =====================================================================
   Layout
   ===================================================================== */
.container { max-width: 1240px; margin: 0 auto; padding: 26px 22px 60px; width: 100%; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head p { margin: 0; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.layout-sidebar { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.layout-split   { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }

@media (max-width: 980px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-sidebar, .layout-split { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: auto;
    transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .4); margin-top: 0;
  }
  .sidebar.open { transform: none; }
  .nav-toggle { display: grid; }
}
@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .brand-text small { display: none; }
  .server-chip { display: none; }
}

/* =====================================================================
   Cards — flat white with the Reich tricolor top border
   ===================================================================== */
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line); border-top: 0;
  border-radius: var(--radius); padding: 18px;
}
.card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg,
    var(--tri-black) 0 33.4%, var(--tri-white) 33.4% 66.7%, var(--tri-red) 66.7% 100%);
}
.card + .card { margin-top: 16px; }
.card-title {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.card-title h2, .card-title h3 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-title { padding: 14px 18px; margin: 0; border-bottom: 1px solid var(--line); }

/* --- stat cards (iron cross marker) ------------------------------------ */
.stat {
  position: relative;
  background: var(--panel); border: 1px solid var(--line); border-top: 0;
  border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 3px;
}
.stat::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg,
    var(--tri-black) 0 33.4%, var(--tri-white) 33.4% 66.7%, var(--tri-red) 66.7% 100%);
}
.stat .stat-label {
  color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
}
.stat .stat-value { font-size: 1.5rem; font-weight: 700; font-family: var(--font-serif); }
.stat .stat-value::before {
  content: ""; display: inline-block; width: 12px; height: 12px;
  margin-right: 7px; vertical-align: -.5px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2329241b' fill-opacity='.5' d='M9 1 L15 1 L13 10 L14 11 L23 9 L23 15 L14 13 L13 14 L15 23 L9 23 L11 14 L10 13 L1 15 L1 9 L10 11 L11 10 Z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.stat .stat-value.gold { color: var(--gold); }
.stat .stat-value.green { color: var(--green); }
.stat .stat-value.red { color: var(--red-soft); }
.stat .stat-value.orange { color: var(--orange); }
.stat .stat-sub { color: var(--muted); font-size: .8rem; }
/* the dark hero stat card would swallow the black iron cross */
.hero-stat .stat-value::before { display: none; }

/* =====================================================================
   Buttons — flat, Reich red primary
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font-size: .9rem; font-weight: 600; cursor: pointer;
  background: #efe9dc; color: var(--text);
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: #e7dfcd; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: #8a121b; }
.btn-danger {
  background: var(--panel); border-color: #dca9ad; color: var(--red);
}
.btn-danger:hover { background: #faecec; border-color: var(--red-soft); }
.btn-success { background: var(--panel); border-color: #bcd4b6; color: var(--green); }
.btn-success:hover { background: #eef5ec; }
.btn-ghost { background: transparent; border-color: #d5cdb8; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--panel); }
.btn-sm { padding: 6px 11px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--red); cursor: pointer; font-size: .8rem; padding: 0; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* =====================================================================
   Forms
   ===================================================================== */
label.field { display: block; margin-bottom: 13px; }
label.field > span, .field-label {
  display: block; font-size: .82rem; color: var(--muted); margin-bottom: 5px; font-weight: 600;
}
input[type=text], input[type=password], input[type=number], input[type=search],
input[type=color], textarea, select {
  width: 100%; background: var(--panel); color: var(--text);
  border: 1px solid #d5cdb8; border-radius: 9px; padding: 9px 12px; font-size: .92rem;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(163, 22, 33, .18); border-color: var(--red);
}
textarea { min-height: 130px; resize: vertical; }
input[type=checkbox] { accent-color: var(--red); width: 16px; height: 16px; }
.check { display: flex; align-items: center; gap: 9px; font-size: .9rem; color: var(--text); cursor: pointer; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }

/* =====================================================================
   Tables
   ===================================================================== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  color: var(--muted); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .05em; font-weight: 700;
}
tbody tr:hover { background: #faf7f0; }
tbody tr:last-child td { border-bottom: 0; }
tr.row-featured { background: #fbf5e2; }
tr.row-featured:hover { background: #f8f0d6; }
tr.row-trending { background: #eef5ec; }

/* =====================================================================
   Badges & tags
   ===================================================================== */
.badge, .tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.badge-gold   { background: #f7efd9; border-color: #e0cf9a; color: #8a6d1f; }
.badge-green  { background: #e7f2e4; border-color: #bcd4b6; color: #2e7d32; }
.badge-red    { background: #f9e9e9; border-color: #e3b8b8; color: var(--red); }
.badge-blue   { background: #e8eef7; border-color: #b9c9e3; color: var(--blue); }
.badge-purple { background: #efe9f7; border-color: #cfc0e6; color: var(--purple); }
.badge-orange { background: #faf0e0; border-color: #e3cba4; color: var(--orange); }
.badge-brown  { background: #efe4d4; border-color: #d3b892; color: #7a4a21; }
.badge-white   { background: #ffffff; border-color: #c9c4b8; color: #3a3630; }
.badge-gray   { background: #e9e6df; border-color: #c6c0b4; color: #6b6558; }
.badge-out { background: transparent; }

/* blue "verified nation" check shown next to nation account names */
.badge-verified {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-left: 5px; vertical-align: -2px;
  border-radius: 50%; background: #1d9bf0; color: #fff; flex: none;
}
.badge-verified svg { display: block; }

.dot-online { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.dot-offline { width: 8px; height: 8px; border-radius: 50%; background: #b6ad99; display: inline-block; }

/* --- filters / tabs --------------------------------------------------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a, .tab {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); font-size: .86rem; font-weight: 600;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { background: #f9e9e9; border-color: #dca9ad; color: var(--red); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters input[type=search], .filters select { width: auto; min-width: 150px; }

/* =====================================================================
   Item grid (shop / sell)
   ===================================================================== */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }
.item {
  position: relative;
  background: var(--panel); border: 1px solid var(--line); border-top: 0;
  border-radius: var(--radius);
  padding: 15px; display: flex; flex-direction: column; gap: 8px;
}
.item::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg,
    var(--tri-black) 0 33.4%, var(--tri-white) 33.4% 66.7%, var(--tri-red) 66.7% 100%);
}
.item:hover { border-color: #cfc5ae; }
.item.featured { border-color: #e0cf9a; }
.item.featured::after {
  content: "ON SALE"; position: absolute; top: -9px; left: 12px;
  background: var(--gold-dim); color: #fff;
  font-size: .62rem; font-weight: 800; letter-spacing: .07em; padding: 2px 8px; border-radius: 999px;
}
.item.trending { border-color: #bcd4b6; }
.item.trending::after {
  content: "TREND"; position: absolute; top: -9px; left: 12px;
  background: var(--green); color: #fff;
  font-size: .62rem; font-weight: 800; letter-spacing: .07em; padding: 2px 8px; border-radius: 999px;
}
.item h3 { margin: 0; font-size: 1rem; }
.item .desc { color: var(--muted); font-size: .82rem; min-height: 34px; }
.item .price { font-size: 1.25rem; font-weight: 800; color: var(--gold); font-family: var(--font-serif); }
.item .price small { font-size: .72rem; color: var(--muted); font-weight: 500; }
.item .item-foot { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: auto; }

.qty { display: flex; align-items: center; gap: 6px; }
.qty input { width: 66px; text-align: center; padding: 7px 6px; }

/* =====================================================================
   Progress / ring
   ===================================================================== */
.progress {
  height: 12px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden;
}
.progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--red), var(--gold-dim));
  transition: width .5s ease;
}
.progress.green > span { background: linear-gradient(90deg, #2e7d32, #4caf50); }

.ring {
  --p: 0;
  width: 168px; height: 168px; border-radius: 50%;
  background: conic-gradient(var(--gold-dim) calc(var(--p) * 1%), var(--bg-2) 0);
  display: grid; place-items: center; position: relative;
}
.ring::before {
  content: ""; position: absolute; inset: 12px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line);
}
.ring .ring-inner { position: relative; text-align: center; }
.ring .ring-value { font-size: 1.7rem; font-weight: 800; color: var(--gold); font-family: var(--font-serif); }
.ring .ring-label { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* =====================================================================
   Streak calendar & reward ladder
   ===================================================================== */
.cal { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; }
.cal-day {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 6px; text-align: center;
  background: var(--panel); font-size: .74rem;
}
.cal-day .d-wd { color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: .66rem; }
.cal-day .d-date { font-size: .8rem; font-weight: 600; }
.cal-day .d-bar { height: 5px; border-radius: 999px; background: var(--bg-2); margin: 6px 0 4px; overflow: hidden; }
.cal-day .d-bar span { display: block; height: 100%; background: var(--red); }
.cal-day.done .d-bar span { background: var(--green); }
.cal-day.closed { opacity: .55; }
.cal-day.today { border-color: var(--red); box-shadow: 0 0 0 1px rgba(163,22,33,.25); }
.cal-day .d-state { font-size: .64rem; color: var(--muted); }
.cal-day.done .d-state { color: var(--green); font-weight: 700; }

.ladder { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.rung {
  min-width: 108px; text-align: center; padding: 10px 8px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel);
}
.rung .r-day { font-size: .74rem; color: var(--muted); }
.rung .r-points { font-size: 1.05rem; font-weight: 800; color: var(--gold); font-family: var(--font-serif); }
.rung.current { border-color: var(--red); background: #f9e9e9; }
.rung.done { border-color: #bcd4b6; }

/* =====================================================================
   Misc
   ===================================================================== */
.empty {
  text-align: center; color: var(--muted); padding: 40px 16px;
  border: 1px dashed #cfc5ae; border-radius: var(--radius); background: var(--panel);
}
.empty strong { color: var(--text); display: block; margin-bottom: 4px; }

.list { display: grid; gap: 8px; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; font-size: .9rem;
}
.list-row:hover { border-color: #cfc5ae; }

.avatar {
  width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
  background: #f7efd9; border: 1px solid #e0cf9a; font-weight: 800; font-size: .8rem;
  color: #8a6d1f; flex-shrink: 0;
}
.avatar.lg { width: 60px; height: 60px; font-size: 1.3rem; border-radius: 14px; }
/* uploaded profile pictures fill the same boxes */
img.avatar { object-fit: cover; background: var(--panel); }
.avatar-form .avatar-input { width: auto; flex: 1 1 220px; }

/* --- work: job picker + admin editor ---------------------------------- */
.job-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 12px; margin-bottom: 14px; }
.job-card { display: flex; flex-direction: column; gap: 7px; padding: 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2);
  cursor: pointer; position: relative; transition: border-color .15s, background .15s; }
.job-card:hover { border-color: var(--gold-dim); }
.job-card.selected { border-color: var(--gold); background: #fbf4dd;
  box-shadow: inset 0 0 0 1px var(--gold); }
.job-check { position: absolute; top: 10px; right: 10px; }
.job-check input { width: 17px; height: 17px; accent-color: #9c7a1e; }
.job-img { width: 100%; height: 92px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-2); }
.job-img.placeholder { display: grid; place-items: center; background: #f7efd9;
  color: #8a6d1f; font-weight: 800; font-size: 1.7rem; }
/* admin page: one editor card per job */
.job-edit { border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  background: var(--panel); }
.job-edit-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }

/* --- hero: dark imperial block ---------------------------------------- */
.hero {
  position: relative;
  border: 1px solid #2c2620; border-top: 0; border-radius: 18px; padding: 42px 34px;
  background: #1c1712;
  color: #f3ede0;
  box-shadow: var(--shadow);
}
/* the server IP stays black: on the dark hero it sits on a light chip */
.hero code { background: rgba(244, 241, 233, .97); color: #141310; padding: 2px 9px; }
.hero::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(90deg,
    var(--tri-black) 0 33.4%, var(--tri-white) 33.4% 66.7%, var(--tri-red) 66.7% 100%);
}
.hero h1 { font-size: 2.3rem; margin-bottom: .3em; color: #fff; }
.hero p { color: #cfc4ad; max-width: 62ch; }
.hero .btn-row { margin-top: 18px; }
.hero .btn-primary { background: var(--red); color: #fff; }
.hero .btn-primary:hover { background: #8a121b; }
.hero .btn-ghost { color: #cfc4ad; border-color: #4a4136; background: transparent; }
.hero .btn-ghost:hover { color: #fff; background: rgba(255,255,255,.05); }

.news-card {
  display: block; padding: 16px 18px; border: 1px solid var(--line); border-top: 0;
  border-radius: var(--radius); background: var(--panel); color: var(--text);
  position: relative;
}
.news-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg,
    var(--tri-black) 0 33.4%, var(--tri-white) 33.4% 66.7%, var(--tri-red) 66.7% 100%);
}
.news-card:hover { border-color: #cfc5ae; text-decoration: none; }
.news-card.pinned { border-color: #e0cf9a; background: #fdf9ee; }
.news-card h3 { margin: 0 0 6px; color: var(--gold); }
.news-card .meta { color: var(--muted); font-size: .78rem; margin-bottom: 6px; }
.news-body { white-space: pre-wrap; line-height: 1.7; }

.notif-admin { border-left: 3px solid var(--gold-dim); }

.footer { border-top: 1px solid var(--line); background: #e9e3d4; margin-top: 40px; }
.footer-inner {
  max-width: 1240px; margin: 0 auto; padding: 22px 22px;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: .86rem;
}
.footer a { color: var(--red); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kv { display: flex; flex-direction: column; gap: 2px; }
.kv .k { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
.kv .v { font-weight: 600; }

.inline-form { display: inline; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.streak-banner { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }

/* =====================================================================
   Images, banners & uploads
   ===================================================================== */
.page-banner {
  height: 200px; border-radius: 16px; border: 1px solid var(--line);
  background-size: cover; background-position: center; margin: -4px 0 18px;
  box-shadow: var(--shadow);
}
.item-img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-2); display: block;
}
.item-img.placeholder {
  display: grid; place-items: center; font-size: 2rem; font-weight: 800;
  color: var(--gold);
  background: linear-gradient(135deg, #f7efd9, var(--panel-2));
}
.thumb {
  width: 40px; height: 40px; object-fit: cover; border-radius: 7px;
  border: 1px solid var(--line); background: var(--bg-2); display: inline-grid;
  place-items: center; font-weight: 800; font-size: .9rem; color: var(--gold);
  vertical-align: middle; margin-right: 9px; flex-shrink: 0;
}
.thumb.placeholder { background: linear-gradient(135deg, #f7efd9, var(--panel-2)); }
.news-thumb {
  width: 100%; height: 150px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); margin-bottom: 10px; display: block;
}
.news-hero {
  width: 100%; max-height: 420px; object-fit: cover; border-radius: 12px;
  border: 1px solid var(--line); margin: 6px 0 18px; display: block;
}
.image-current {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 4px 0 14px; padding: 10px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel-2);
}
.img-preview {
  width: 110px; height: 76px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); display: block;
}
.img-preview.wide { width: 260px; height: 96px; }
input[type=file] {
  width: 100%; font-size: .82rem; color: var(--muted); background: var(--panel);
  border: 1px dashed #cfc5ae; border-radius: 9px; padding: 8px;
}
input[type=file]::file-selector-button {
  background: #efe9dc; color: var(--text); border: 1px solid #d5cdb8;
  border-radius: 7px; padding: 5px 10px; margin-right: 10px; cursor: pointer;
  font-family: inherit; font-size: .8rem;
}
.hr { height: 1px; background: var(--line); margin: 18px 0; }

/* --- split hero ------------------------------------------------------- */
.hero-split { display: grid; grid-template-columns: 1fr 250px; gap: 26px; align-items: center; }
.hero-stat {
  display: flex; flex-direction: column; gap: 4px; padding: 20px;
  background: rgba(255,255,255,.06); border: 1px solid #4a4136; border-radius: 14px;
}
@media (max-width: 760px) {
  .hero-split { grid-template-columns: 1fr; }
}

/* =====================================================================
   Rich text
   ===================================================================== */
.rich { line-height: 1.65; }
/* bios: typed line breaks are shown (same rule .news-body uses) */
.rich.bio { white-space: pre-wrap; }
.rich > :first-child { margin-top: 0; }
.rich h2 { font-size: 1.45rem; margin: 20px 0 8px; color: var(--text); }
.rich h3 { font-size: 1.2rem; margin: 16px 0 6px; color: var(--text); }
.rich h4 { font-size: 1.05rem; margin: 14px 0 6px; color: var(--gold); }
.rich p { margin: 0 0 10px; }
.rich ul { margin: 0 0 10px; padding-left: 20px; }
.rich li { margin: 2px 0; }
.rich blockquote {
  margin: 0 0 10px; padding: 8px 12px; border-left: 3px solid var(--gold-dim);
  background: #f7f3e8; border-radius: 0 8px 8px 0; color: var(--muted);
}
.rich code {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; font-size: .88em; font-family: ui-monospace, monospace;
}
.rich pre {
  background: #f0ebde; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; overflow-x: auto; margin: 0 0 10px;
}
.rich pre code { background: none; border: 0; padding: 0; }
.rich a { color: var(--red); }
.rich hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.rich strong { color: var(--text); }
.price-old { text-decoration: line-through; color: var(--muted); font-weight: 600; margin-right: 6px; }

/* =====================================================================
   Order chat
   ===================================================================== */
.chat-thread {
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  max-height: 420px; overflow-y: auto; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px;
}
.chat-msg {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; max-width: 86%;
}
.chat-msg.mine { align-self: flex-end; background: #f9e9e9; border-color: #dca9ad; }
.chat-meta { display: flex; gap: 8px; align-items: center; font-size: .78rem; margin-bottom: 4px; }
.chat-meta strong { font-size: .82rem; }
.chat-body { font-size: .9rem; }
.chat-body.rich p:last-child { margin-bottom: 0; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; }
.chat-form textarea { min-height: 44px; resize: vertical; }
.chat-form button { flex-shrink: 0; }

/* =====================================================================
   Forum: posts, comments, votes
   ===================================================================== */
.crumbs { margin: 0 0 4px; font-size: .8rem; color: var(--muted); }
.crumbs a { color: var(--gold); }

.forum-post .forum-body { margin: 12px 0 0; }
.forum-comment { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.forum-comment:last-child { border-bottom: 0; }
.forum-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: .8rem;
}
.forum-meta .avatar { width: 26px; height: 26px; font-size: .68rem; }
.forum-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 10px;
}
.forum-foot .btn-row { justify-content: flex-end; }
.reply-to { color: var(--gold); font-size: .78rem; }
.pos { color: #2e7d32; font-weight: 700; }
.neg { color: var(--red); font-weight: 700; }

.vote-arrows {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 6px;
}
.vote-arrows form { display: inline-flex; }
.vote-score { min-width: 22px; text-align: center; font-weight: 800; font-size: .8rem; }
.vote-btn {
  border: 0; background: transparent; cursor: pointer; padding: 1px 4px;
  border-radius: 4px; color: var(--muted); font-size: .7rem; line-height: 1.3;
}
.vote-btn:hover { color: var(--gold-dim); background: var(--line); }
span.vote-btn { cursor: default; }
.vote-btn.up.on { color: #2e7d32; }
.vote-btn.down.on { color: var(--red); }

/* =====================================================================
   Activity tracker bars & economy chart bars
   ===================================================================== */
.bar {
  display: flex; flex-direction: column; gap: 2px; height: 26px;
  background: var(--bg-2); border-radius: 5px; overflow: hidden; min-width: 60px;
}
.bar-fill { height: 10px; min-width: 2px; border-radius: 3px; }
.bar-fill.market { background: linear-gradient(90deg, var(--gold-dim), var(--gold)); }
.bar-fill.shop { background: linear-gradient(90deg, var(--blue), #5578ad); }

/* =====================================================================
   Item inspection: picture galleries & lightbox
   ===================================================================== */
.gallery { display: flex; flex-direction: column; gap: 10px; }
.gallery-main { display: block; width: 100%; }
.gallery-main img {
  width: 100%; max-height: 420px; object-fit: contain;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px;
}
.gallery-main:hover img { border-color: var(--gold-dim); }
.gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery-thumb { display: block; text-decoration: none; }
.gallery-thumbs img {
  width: 78px; height: 58px; object-fit: cover; cursor: pointer;
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  opacity: .65; transition: opacity .12s, border-color .12s;
}
.gallery-thumbs img:hover { opacity: 1; }
.gallery-thumbs img.is-active { opacity: 1; border-color: var(--gold-dim); }

/* the big view of a picture - pure CSS (:target), so it also works
   without JavaScript */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(20, 16, 12, .94); padding: 24px; overflow: auto;
}
.lightbox:target { display: flex; align-items: center; justify-content: center; }
.lightbox-pic { display: block; }
.lightbox-pic img {
  max-width: 94vw; max-height: 90vh; object-fit: contain;
  border-radius: var(--radius); border: 1px solid #4a4136;
  background: #fff;
}
.lightbox-close {
  position: fixed; top: 10px; right: 16px; z-index: 310;
  color: #fff; font-size: 2.2rem; line-height: 1; text-decoration: none;
  opacity: .8;
}
.lightbox-close:hover { color: var(--gold-dim); opacity: 1; text-decoration: none; }
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.gallery-cell { display: flex; flex-direction: column; gap: 4px; }
.gallery-cell img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel-2);
}


/* =====================================================================
   World map (/map)
   ===================================================================== */

/* The map page fills the viewport: wide container, no footer. */
main.container:has(.map-page) { max-width: none; padding: 12px 16px 16px; }
.main-col:has(.map-page) .footer { display: none; }
.map-head { margin-bottom: 10px; }
.map-head .map-head-actions { display: flex; gap: 8px; }

.map-stage {
  position: relative;
  overflow: hidden;
  height: calc(100vh - 176px);
  height: calc(100dvh - 176px);
  min-height: 440px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f130f;                 /* dark like squaremap's empty ocean */
  cursor: grab;
  touch-action: none;                  /* the map handles its own panning */
}
.map-stage:active { cursor: grabbing; }
.map-stage.drawing { cursor: crosshair; }

.map-tiles { position: absolute; inset: 0; }
.map-tile { position: absolute; user-select: none; }
.map-tile.map-tile-failed { visibility: hidden; }
.map-canvas { position: absolute; inset: 0; pointer-events: none; }

/* --- overlays: readout, zoom buttons, layer + admin panels ------------ */
.map-readout {
  position: absolute; left: 12px; bottom: 12px; z-index: 5;
  background: rgba(20, 18, 14, .78); color: #eee6d2;
  border-radius: 8px; padding: 5px 10px; font-size: .78rem;
  pointer-events: none;
}

.map-zoom {
  position: absolute; right: 12px; bottom: 12px; z-index: 5;
  display: flex; flex-direction: column; gap: 6px;
}
.map-zoom button {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--line); background: rgba(255, 253, 247, .95);
  color: var(--text); font-size: 1rem; font-weight: 700; cursor: pointer;
}
.map-zoom button:hover { background: #fff; }

.map-panel {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  background: rgba(255, 253, 247, .96);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 10px 12px; min-width: 158px;
  display: flex; flex-direction: column; gap: 6px;
}
.map-panel strong { font-family: var(--font-serif); font-size: .95rem; }
.map-panel .check { gap: 7px; font-size: .85rem; }
.map-panel .map-ore-hint { margin: 2px 0 0; }
.map-admin-panel { right: auto; left: 12px; min-width: 196px; }
.map-draw-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.map-draw-buttons .btn.active {
  background: var(--red); color: #fff; border-color: var(--red);
}
.map-draw-actions { display: flex; gap: 8px; }

/* --- admin draw dialog ------------------------------------------------ */
.map-dialog {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 8;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; width: min(320px, calc(100% - 24px));
}
.map-dialog .field { margin-bottom: 10px; }
.map-dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.map-error { color: var(--red-soft); }

/* --- small "saved" toast ------------------------------------------------ */
.map-toast {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 9;
  background: var(--green); color: #fff; padding: 8px 14px;
  border-radius: 999px; font-size: .85rem;
  animation: map-toast-in .18s ease-out;
}
@keyframes map-toast-in { from { opacity: 0; transform: translate(-50%, 6px); } }

.map-credit { margin: 8px 2px 0; }

/* --- admin management table (/admin/map) -------------------------------- */
.map-swatch {
  display: inline-block; width: 14px; height: 14px; border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, .25); vertical-align: -2px; margin-right: 5px;
}
.map-kind {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .75rem; background: var(--panel-2); border: 1px solid var(--line);
  white-space: nowrap;
}
.map-kind-territory { background: #f6dede; }
.map-kind-capital   { background: #f6ecd2; }
.map-kind-city      { background: #e2e9f4; }
.map-kind-road      { background: #efe4d4; }
.map-kind-ore       { background: #e4e4e4; }
.row-inactive td { opacity: .55; }
.map-edit summary { cursor: pointer; color: var(--red); }
.map-edit-form {
  display: flex; flex-direction: column; gap: 8px; min-width: 260px;
  padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel-2);
}
