:root {
  --bg: #0f1317;
  --bg-2: #13191f;
  --panel: #1a2128;
  --panel-2: #202932;
  --panel-3: #262f39;
  --line: #394452;
  --line-soft: rgba(255,255,255,0.06);
  --text: #e4e8ec;
  --text-strong: #f4f7fa;
  --muted: #8d98a6;
  --accent: #9cc86a;
  --accent-2: #d4b06a;
  --accent-danger: #cf6464;
  --accent-good: #5bb57a;
  --accent-info: #6f9ecf;
  --accent-warning: #c9a75f;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --radius-sm: 3px;
  --radius-md: 4px;
  --sidebar-width: 232px;
  --topbar-height: 54px;
  --content-gap: 12px;
  --card-pad: 10px;
  --transition: 0.15s ease;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    linear-gradient(rgba(10, 12, 14, 0.9), rgba(10, 12, 14, 0.9)),
    radial-gradient(circle at top left, rgba(156, 200, 106, 0.08), transparent 32%),
    radial-gradient(circle at bottom right, rgba(212, 176, 106, 0.06), transparent 25%),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

img {
  max-width: 100%;
  display: block;
}

h1,
h2,
h3,
h4,
h5,
h6,
p {
  margin-top: 0;
}

/* =========================================================
   APP SHELL
========================================================= */
.topbar {
  height: var(--topbar-height);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, #171d23, #12181d);
  display: grid;
  /*grid-template-columns: 250px 1fr 320px;*/
  grid-template-columns: auto 1fr 320px;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  position: sticky;
  top: 0;
  z-index: 100;
}



.brand {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--text-strong);
  line-height: 1;
   margin-right: 12px;
}

.brand span {
  color: var(--accent);
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  font-size: 14px;
  color: var(--muted);
}

.topnav a {
  transition: color var(--transition);
}

.topnav a:hover,
.topnav a:focus-visible {
  color: var(--text-strong);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: calc(100vh - var(--topbar-height));
}

.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(to bottom, #161c22, #13181d);
  padding: 12px;
}

.content {
  padding: 12px;
  display: grid;
  gap: var(--content-gap);
}

/* =========================================================
   COMMON PANELS
========================================================= */
.card,
.panel,
.summary-card,
.building-card,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.card-header,
.panel-header,
.summary-header,
.table-header {
  background: linear-gradient(to bottom, #313a44, #1f262e);
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-strong);
}

.card-body,
.panel-body,
.summary-body,
.table-body {
  padding: var(--card-pad);
}

.section-title {
  margin: 0;
  font-size: 22px;
  color: var(--text-strong);
}

.subtext {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

/* =========================================================
   UTILITY TEXT / STATUS
========================================================= */
.muted {
  color: var(--muted);
}

.text-strong {
  color: var(--text-strong);
}

.accent {
  color: var(--accent);
}

.good {
  color: var(--accent-good);
}

.warn {
  color: var(--accent-warning);
}

.danger {
  color: var(--accent-danger);
}

.info {
  color: var(--accent-info);
}

.center {
  text-align: center;
}

.right {
  text-align: right;
}

.hidden {
  display: none !important;
}

/* =========================================================
   BUTTONS / INPUTS
========================================================= */
.search,
.mini-btn,
.button,
.btn,
.input,
.select {
  height: 34px;
  border: 1px solid var(--line);
  background: #0f1419;
  color: var(--text);
  border-radius: var(--radius-md);
}

.search,
.input,
.select {
  padding: 0 10px;
}

.search {
  width: 180px;
}

.mini-btn,
.button,
.btn {
  padding: 0 12px;
  font-size: 13px;
  cursor: pointer;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    transform var(--transition);
}

.mini-btn:hover,
.button:hover,
.btn:hover,
.mini-btn:focus-visible,
.button:focus-visible,
.btn:focus-visible {
  border-color: #566272;
  background: #151b21;
}

.button.primary,
.btn.primary {
  border-color: #5f714d;
  background: linear-gradient(to bottom, #607549, #435333);
  color: #eef6e7;
}

.button.primary:hover,
.btn.primary:hover,
.button.primary:focus-visible,
.btn.primary:focus-visible {
  border-color: #748861;
  background: linear-gradient(to bottom, #6d8454, #4c5f3b);
}

.button.warn,
.btn.warn {
  border-color: #8e723b;
  background: linear-gradient(to bottom, #b08a44, #8f6d33);
  color: #fff4e1;
}

.button.danger,
.btn.danger {
  border-color: #8f4c4c;
  background: linear-gradient(to bottom, #a75555, #844343);
  color: #fff2f2;
}

.button:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =========================================================
   TICKER / NOTICES / PAGE TITLE
========================================================= */
.ticker {
  border: 1px solid var(--line);
  background: linear-gradient(to right, #1c232a, #141a1f);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
}

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.page-title h1 {
  margin: 0;
  font-size: 38px;
  line-height: 1;
  letter-spacing: 0.5px;
  color: var(--text-strong);
}

.page-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notice {
  border: 1px solid var(--line);
  background: linear-gradient(to right, #253226, #1d2620);
  padding: 12px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.notice.secondary {
  background: linear-gradient(to right, #312b1f, #232016);
}

.notice.danger {
  background: linear-gradient(to right, #372222, #251818);
}

/* =========================================================
   SIDEBAR / PROFILE / VITALS
========================================================= */
.profile-grid {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 10px;
  align-items: start;
}

.avatar {
  width: 76px;
  height: 76px;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, #2a3139, #1b2229);
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 6px;
}

.statlines {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.statline {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 4px;
}

.bar-block {
  margin-bottom: 8px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 4px;
  color: #d7dce0;
}

.bar {
  width: 100%;
  height: 12px;
  background: #0f1419;
  border: 1px solid var(--line);
  overflow: hidden;
}

.fill {
  height: 100%;
}

.fill.energy {
  background: linear-gradient(to right, #85c95c, #63993f);
}

.fill.stamina {
  background: linear-gradient(to right, #d0ad62, #a98439);
}

.fill.health {
  background: linear-gradient(to right, #6da2d9, #426f9b);
}

.fill.alert,
.fill.heat {
  background: linear-gradient(to right, #cf6d6d, #9a4747);
}

.side-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 1px solid var(--line);
  background: linear-gradient(to bottom, #2a3139, #20262d);
  padding: 9px 10px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #d9dfe4;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition);
}

.nav-item:hover,
.nav-item:focus-visible {
  background: linear-gradient(to bottom, #303843, #242b33);
  border-color: #495564;
}

.nav-item.active {
  background: linear-gradient(to bottom, #364130, #293124);
  border-color: #556548;
  color: #eef6e5;
  font-weight: 700;
}

.badge {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent-2);
  color: #111;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

/* =========================================================
   GRIDS / LAYOUT HELPERS
========================================================= */
.quick-stats,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 12px;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.four-col {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

/* =========================================================
   MINI STATS / SUMMARY BLOCKS
========================================================= */
.mini-stat,
.summary-item {
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 10px;
}

.mini-stat .label,
.summary-item .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mini-stat .value,
.summary-item .value {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-strong);
}

/* =========================================================
   TABLES
========================================================= */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
}

th {
  background: #232b33;
  color: #eef2f5;
  font-weight: 700;
}

td.label,
.table-label {
  width: 42%;
  color: #c7cfd6;
  background: rgba(255, 255, 255, 0.015);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.015);
}

/* =========================================================
   LISTS / MISSIONS / ROW BLOCKS
========================================================= */
.mission-list,
.row-list {
  display: grid;
  gap: 8px;
}

.mission,
.row-item {
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.mission-title,
.row-title {
  font-weight: 700;
  margin-bottom: 3px;
}

.mission-sub,
.row-sub {
  font-size: 12px;
  color: var(--muted);
}

/* =========================================================
   BUILDINGS / MODULE CARDS
========================================================= */
.buildings-grid,
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.building-card {
  overflow: hidden;
}

.building-top {
  background: linear-gradient(to bottom, #222b33, #1a2128);
  border-bottom: 1px solid var(--line);
  padding: 10px;
}

.building-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text-strong);
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.building-body {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 7px;
  border-radius: 3px;
  border: 1px solid transparent;
}

.status-ok {
  background: #213225;
  border-color: #3e6a49;
  color: #a9ddb5;
}

.status-warn {
  background: #332a1d;
  border-color: #7e6737;
  color: #e6c985;
}

.status-bad {
  background: #362222;
  border-color: #815050;
  color: #e1a3a3;
}

.locked-card {
  opacity: 0.88;
  background: linear-gradient(to bottom, #1a2026, #171c21);
}

/* =========================================================
   MEDIA / PLACEHOLDER BLOCKS
========================================================= */
.property,
.media-panel,
.image-placeholder {
  min-height: 275px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background:
    linear-gradient(rgba(19, 24, 29, 0.82), rgba(19, 24, 29, 0.82)),
    repeating-linear-gradient(135deg, rgba(255,255,255,0.02) 0 12px, rgba(0,0,0,0) 12px 24px);
  border-top: 1px solid var(--line);
  text-align: center;
  padding: 20px;
}

/* =========================================================
   RESPONSIVE
========================================================= */
@media (max-width: 1250px) {
  .buildings-grid,
  .module-grid,
  .three-col,
  .four-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-grid,
  .two-col,
  .info-grid,
  .summary-grid,
  .quick-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: 1fr;
    height: auto;
    padding: 10px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .buildings-grid,
  .module-grid,
  .three-col,
  .four-col {
    grid-template-columns: 1fr;
  }

  .page-title,
  .notice,
  .mission,
  .row-item {
    grid-template-columns: 1fr;
    display: grid;
  }

  .page-title {
    align-items: start;
  }

  .top-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .search {
    width: 100%;
    max-width: 280px;
  }
}

/* =========================================================
   OPTIONAL THEME HELPERS
========================================================= */
.theme-dark {
  color-scheme: dark;
}

.compact-page {
  width: 100%;
}
