/* =====================================================================
   Blue Coin — Operations panel
   Dense, dark, keyboard-friendly. Deliberately plainer than the mini app:
   this is a tool, not a storefront.
   ===================================================================== */

:root {
  --bg:        #0A0D13;
  --surface:   #111721;
  --surface-2: #161E2B;
  --line:      #222C3B;
  --text:      #E6ECF5;
  --mute:      #7C8BA1;
  --blue:      #4C8DF6;
  --coin:      #F2B33D;
  --jade:      #2FBF87;
  --rose:      #FF5E6C;
  --r:         10px;
  --sidebar:   232px;
  font-synthesis-weight: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--mute); }
.right { text-align: right; }
.center { text-align: center; }
.plus { color: var(--jade); }
.minus { color: var(--rose); }
.coin { color: var(--coin); }

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

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

.sidebar {
  width: var(--sidebar);
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 22px; }

.brand__mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-weight: 700;
  color: #0A0D13;
  background: linear-gradient(150deg, #7FB4FF, var(--blue));
}

.brand__text { font-weight: 700; line-height: 1.15; display: flex; flex-direction: column; }
.brand__text small { font-weight: 500; font-size: 11px; color: var(--mute); }
.brand--big { justify-content: center; padding-bottom: 26px; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r);
  color: var(--mute);
  font-weight: 500;
  transition: background .14s ease, color .14s ease;
}

.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.is-active { background: rgba(76, 141, 246, .14); color: #A8CBFF; }

.nav__item i {
  width: 16px;
  height: 16px;
  flex: none;
  background: currentColor;
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
}

i[data-icon="grid"]   { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Crect x='3' y='3' width='7' height='7'/%3E%3Crect x='14' y='3' width='7' height='7'/%3E%3Crect x='3' y='14' width='7' height='7'/%3E%3Crect x='14' y='14' width='7' height='7'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Crect x='3' y='3' width='7' height='7'/%3E%3Crect x='14' y='3' width='7' height='7'/%3E%3Crect x='3' y='14' width='7' height='7'/%3E%3Crect x='14' y='14' width='7' height='7'/%3E%3C/svg%3E"); }
i[data-icon="users"]  { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.87'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.87'/%3E%3C/svg%3E"); }
i[data-icon="play"]   { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cpolygon points='5 3 19 12 5 21 5 3'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cpolygon points='5 3 19 12 5 21 5 3'/%3E%3C/svg%3E"); }
i[data-icon="ledger"] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cpath d='M4 3h14a2 2 0 0 1 2 2v16l-4-2-4 2-4-2-4 2V5a2 2 0 0 1 2-2z'/%3E%3Cpath d='M8 8h8M8 12h8'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cpath d='M4 3h14a2 2 0 0 1 2 2v16l-4-2-4 2-4-2-4 2V5a2 2 0 0 1 2-2z'/%3E%3Cpath d='M8 8h8M8 12h8'/%3E%3C/svg%3E"); }
i[data-icon="check"]  { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cpath d='M9 11l3 3L22 4'/%3E%3Cpath d='M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cpath d='M9 11l3 3L22 4'/%3E%3Cpath d='M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11'/%3E%3C/svg%3E"); }
i[data-icon="send"]   { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cline x1='22' y1='2' x2='11' y2='13'/%3E%3Cpolygon points='22 2 15 22 11 13 2 9 22 2'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cline x1='22' y1='2' x2='11' y2='13'/%3E%3Cpolygon points='22 2 15 22 11 13 2 9 22 2'/%3E%3C/svg%3E"); }
i[data-icon="gear"]   { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06A1.65 1.65 0 0 0 15 19.4a1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c.14.35.42.63.77.77H21a2 2 0 1 1 0 4h-.09c-.35.14-.63.42-.77.77z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06A1.65 1.65 0 0 0 15 19.4a1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c.14.35.42.63.77.77H21a2 2 0 1 1 0 4h-.09c-.35.14-.63.42-.77.77z'/%3E%3C/svg%3E"); }

.sidebar__foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.who strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.who span { font-size: 11px; color: var(--mute); }

.content { flex: 1; min-width: 0; padding: 22px 26px 60px; }

.topline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.topline h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.topline__right { display: flex; align-items: center; gap: 10px; }

/* ---------- primitives ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--mute);
}

.pill.is-up { color: var(--jade); border-color: rgba(47, 191, 135, .4); }
.pill.is-down { color: var(--rose); border-color: rgba(255, 94, 108, .4); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--r);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: filter .14s ease, transform .1s ease;
}

.btn:hover { filter: brightness(1.18); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--blue); color: #061019; }
.btn--coin { background: var(--coin); color: #241902; }
.btn--danger { background: rgba(255, 94, 108, .14); color: #FF9AA3; border-color: rgba(255, 94, 108, .35); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--mute); }
.btn--sm { padding: 6px 11px; font-size: 12px; }
.btn--block { width: 100%; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
}

.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card__title { font-size: 15px; font-weight: 600; }

.grid { display: grid; gap: 14px; }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.kpi__label { font-size: 12px; color: var(--mute); text-transform: uppercase; letter-spacing: .06em; }
.kpi__value { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 600; margin-top: 6px; letter-spacing: -.02em; }
.kpi__foot { font-size: 12px; color: var(--mute); margin-top: 4px; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--mute);
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface-2);
}

tbody td { padding: 11px 14px; border-bottom: 1px solid rgba(34, 44, 59, .6); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(76, 141, 246, .05); }

.uname { display: flex; align-items: center; gap: 9px; }

.uavatar {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  background: var(--surface-2) center / cover;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--mute);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--mute);
  border: 1px solid var(--line);
}

.tag--live { color: var(--jade); border-color: rgba(47, 191, 135, .4); }
.tag--warn { color: var(--coin); border-color: rgba(242, 179, 61, .4); }
.tag--bad  { color: var(--rose); border-color: rgba(255, 94, 108, .4); }
.tag--info { color: #A8CBFF; border-color: rgba(76, 141, 246, .4); }

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

/* ---------- forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; color: var(--mute); font-weight: 500; }

input[type="text"], input[type="password"], input[type="number"], input[type="search"],
select, textarea, .field input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

input:focus, select:focus, textarea:focus { outline: 2px solid rgba(76, 141, 246, .5); outline-offset: 1px; }
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type="search"], .toolbar select { width: auto; min-width: 170px; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 21px; border-radius: 999px; background: var(--line); position: relative; transition: background .16s ease; cursor: pointer; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: var(--mute); transition: transform .16s ease, background .16s ease; }
.switch input:checked { background: rgba(76, 141, 246, .5); }
.switch input:checked::after { transform: translateX(17px); background: var(--blue); }

/* ---------- misc ---------- */

.flash { padding: 11px 14px; border-radius: var(--r); margin-bottom: 16px; font-size: 13px; border: 1px solid; }
.flash--ok { background: rgba(47, 191, 135, .1); border-color: rgba(47, 191, 135, .4); color: #8FE3C1; }
.flash--error { background: rgba(255, 94, 108, .1); border-color: rgba(255, 94, 108, .4); color: #FFA8B0; }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pager a, .pager span { padding: 6px 11px; border-radius: 8px; border: 1px solid var(--line); font-size: 12px; color: var(--mute); }
.pager .is-current { background: var(--blue); border-color: var(--blue); color: #061019; font-weight: 600; }

.bars { display: flex; align-items: flex-end; gap: 5px; height: 90px; margin-top: 8px; }
.bars div { flex: 1; background: linear-gradient(180deg, var(--blue), rgba(76, 141, 246, .25)); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; }
.bars div span { position: absolute; bottom: -19px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--mute); }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login { width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 26px; }

dialog { border: 0; background: transparent; }
dialog::backdrop { background: rgba(4, 7, 12, .7); }
.sheet { width: min(440px, 92vw); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; gap: 12px; overflow-x: auto; padding: 12px; }
  .brand { padding: 0 8px 0 0; }
  .nav { flex-direction: row; }
  .sidebar__foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .content { padding: 16px; }
  .grid--4, .grid--3, .grid--2 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .grid--4, .grid--3, .grid--2 { grid-template-columns: 1fr; }
}
