/* src/dashboard/dashboard.css */
:root {
  --bg: #0b0e14;
  --panel: #141925;
  --panel-2: #1c2333;
  --border: #232b3d;
  --text: #d7dce6;
  --muted: #7c8499;
  --accent: #5b8cff;
  --accent-2: #8b5bff;
  --green: #3fb950;
  --yellow: #d9a441;
  --red: #f0556a;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--accent);
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 12px;
  transition: background .12s, border-color .12s;
}

button:hover {
  background: #273150;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: #4878e6;
}

button.danger {
  color: var(--red);
  border-color: #4a2230;
}

button.danger:hover {
  background: #3a1c26;
}

button.sm {
  padding: 3px 9px;
  font-size: 12px;
}

input, textarea, select {
  font: inherit;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  width: 100%;
  padding: 8px 10px;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
}

.login-wrap {
  display: grid;
  place-items:  center;
  height: 100vh;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 340px;
  padding: 32px;
  box-shadow: 0 20px 60px #0006;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.login-card p {
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 13px;
}

.login-card .err {
  color: var(--red);
  margin-top: 10px;
  font-size: 13px;
}

.login-card form {
  display: grid;
  gap: 12px;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 22px 60px;
}

.floatbar {
  position: sticky;
  z-index: 30;
  display: flex;
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  background: #141925b8;
  border: 1px solid #ffffff17;
  border-radius: 16px;
  align-items:  center;
  gap: 12px;
  margin: 6px 0 22px;
  padding: 8px 10px 8px 16px;
  top: 14px;
  box-shadow: 0 10px 34px #0006;
}

.brand {
  letter-spacing: .3px;
  white-space: nowrap;
  font-size: 17px;
  font-weight: 700;
}

.dot {
  display: inline-block;
  border-radius: 50%;
  width: 9px;
  height: 9px;
}

.dot.on {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.dot.off {
  background: var(--red);
}

.barright {
  position: relative;
  display: flex;
  align-items:  center;
  gap: 8px;
  margin-left: auto;
}

.barright button {
  display: inline-flex;
  border-radius: 9px;
  align-items:  center;
  height: 34px;
  padding: 0 13px;
  font-size: 13px;
}

.iconbtn {
  gap: 7px;
}

.iconbtn .caret {
  color: var(--muted);
  font-size: 10px;
}

.infopop {
  position: absolute;
  z-index: 40;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  animation: fadeUp .16s ease both;
  background: #141925f5;
  border-radius: 12px;
  min-width: 190px;
  padding: 8px;
  top: calc(100% + 10px);
  right: 0;
  box-shadow: 0 12px 36px #00000080;
}

.infopop > div {
  display: flex;
  color: var(--muted);
  justify-content: space-between;
  gap: 16px;
  padding: 5px 8px;
  font-size: 12.5px;
}

.infopop > div + div {
  border-top: 1px solid #ffffff0a;
}

.infopop code {
  color: var(--text);
  font-family: var(--mono);
}

nav.tabs {
  display: flex;
  flex-wrap: wrap;
  flex: 1;
  justify-content: center;
  gap: 4px;
}

.tabsel {
  display: none;
  width: auto;
  max-width: 200px;
  padding: 7px 10px;
}

.tab {
  color: var(--muted);
  display: flex;
  background: none;
  border: 1px solid #0000;
  border-radius: 10px;
  align-items:  center;
  gap: 7px;
  padding: 7px 13px;
}

.tab:hover {
  color: var(--text);
  background: #ffffff0f;
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: #0000;
  font-weight: 600;
  box-shadow: 0 4px 14px #5b8cff59;
}

.tab .pill {
  color: var(--text);
  background: #ffffff1f;
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}

.tab.active .pill {
  color: #fff;
  background: #ffffff40;
}

@media (width <= 820px) {
  nav.tabs {
    display: none;
  }

  .tabsel {
    display: block;
  }
}

.pager {
  display: flex;
  justify-content: center;
  align-items:  center;
  gap: 14px;
  margin-top: 14px;
}

.filter {
  width: 260px;
  max-width: 50%;
  padding: 6px 10px;
  font-size: 13px;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card, section.panel {
  animation: fadeUp .3s ease both;
}

.cards .card:first-child {
  animation-delay: 0s;
}

.cards .card:nth-child(2) {
  animation-delay: 50ms;
}

.cards .card:nth-child(3) {
  animation-delay: .1s;
}

.cards .card:nth-child(4) {
  animation-delay: .15s;
}

@media (prefers-reduced-motion: reduce) {
  .card, section.panel {
    animation: none;
  }
}

.grid {
  display: grid;
  gap: 16px;
}

.cards {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.card .k {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-size: 12px;
}

.card .v {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 650;
}

.card .v small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

section.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 18px;
  padding: 18px;
}

section.panel > h2 {
  display: flex;
  align-items:  center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 15px;
}

section.panel > h2 .count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

section.panel > h2 .spacer {
  flex: 1;
}

.cols2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.cols2 > * {
  min-width: 0;
}

@media (width <= 900px) {
  .cols2 {
    grid-template-columns: 1fr;
  }
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

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

th, td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
}

th {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  font-size: 11.5px;
  font-weight: 500;
}

td.num, th.num {
  text-align: right;
  font-family: var(--mono);
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--panel-2);
}

.badge {
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}

.badge.active {
  color: var(--green);
  background: #14331f;
}

.badge.error {
  color: var(--red);
  background: #3a1c26;
}

.badge.expired {
  color: var(--yellow);
  background: #3a2f17;
}

.badge.reserved {
  color: var(--accent);
  background: #1f2a47;
}

.badge.revoked {
  color: var(--muted);
  background: #2a2f3d;
}

.bar {
  background: var(--panel-2);
  overflow: hidden;
  border-radius: 4px;
  min-width: 70px;
  height: 6px;
}

.bar > span {
  display: block;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  height: 100%;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-form {
  display: flex;
  flex-wrap: wrap;
  align-items:  end;
  gap: 8px;
}

.row-form .fld {
  flex: 1;
  min-width: 140px;
}

.fld label {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
  font-size: 12px;
}

.chk {
  display: flex;
  color: var(--muted);
  white-space: nowrap;
  align-items:  center;
  gap: 6px;
  font-size: 13px;
}

.chk input {
  width: auto;
}

.feed {
  font-family: var(--mono);
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 360px;
  font-size: 12px;
}

.feed.tall {
  max-height: calc(100vh - 240px);
}

.feed .line {
  display: flex;
  border-bottom: 1px solid #ffffff08;
  gap: 8px;
  padding: 2px 0;
}

.feed .line > span:last-child {
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  min-width: 0;
}

.feed .t {
  color: var(--muted);
  flex-shrink: 0;
}

.feed .ev-start {
  color: var(--accent);
}

.feed .ev-finish {
  color: var(--green);
}

.feed .ev-error {
  color: var(--red);
}

.feed .ev-quota {
  color: var(--yellow);
}

.feed .ev-downgrade {
  color: var(--accent-2);
}

.feed .ev-log {
  color: var(--text);
  opacity: .8;
}

.toast {
  position: fixed;
  z-index: 50;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 380px;
  padding: 12px 16px;
  bottom: 20px;
  right: 20px;
  box-shadow: 0 10px 40px #00000080;
}

.toast.err {
  border-color: #4a2230;
}

.toast .secret {
  font-family: var(--mono);
  word-break: break-all;
  color: var(--green);
  margin-top: 6px;
}

.empty {
  color: var(--muted);
  padding: 8px 2px;
  font-size: 13px;
}

.muted {
  color: var(--muted);
}

.chart-wrap {
  width: 100%;
  min-width: 0;
  height: 240px;
}

code.inline {
  font-family: var(--mono);
  background: var(--panel-2);
  color: var(--text);
  white-space: nowrap;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 12.5px;
}

button.copy {
  padding: 3px 9px;
  font-size: 11px;
}

.codeblock {
  border: 1px solid var(--border);
  overflow: hidden;
  border-radius: 10px;
  margin-bottom: 14px;
}

.codeblock:last-child {
  margin-bottom: 0;
}

.codeblock-head {
  display: flex;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  justify-content: space-between;
  align-items:  center;
  padding: 6px 8px 6px 12px;
  font-size: 12px;
}

pre.code {
  overflow-x: auto;
  font-family: var(--mono);
  background: var(--bg);
  white-space: pre;
  margin: 0;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.55;
}

.docs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (width <= 900px) {
  .docs-grid {
    grid-template-columns: 1fr;
  }
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  overflow: hidden;
  border-radius: 8px;
}

.seg button {
  background: var(--panel);
  color: var(--muted);
  border: none;
  border-radius: 0;
  padding: 5px 12px;
  font-size: 12.5px;
}

.seg button:hover {
  background: var(--panel-2);
  color: var(--text);
}

.seg button.on {
  background: var(--accent);
  color: #fff;
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

.app {
  width: 100%;
}

@media (width <= 640px) {
  body {
    font-size: 13.5px;
  }

  .app {
    padding: 10px 10px 50px;
  }

  .floatbar {
    border-radius: 14px;
    gap: 8px;
    padding: 7px 8px 7px 12px;
    top: 8px;
  }

  .brand {
    font-size: 15px;
  }

  .hide-sm {
    display: none;
  }

  .tabsel {
    max-width: 150px;
  }

  section.panel {
    padding: 14px;
  }

  section.panel > h2 {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  section.panel > h2 .spacer {
    display: none;
  }

  .filter {
    width: 100%;
    max-width: 100%;
  }

  .cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .card .v {
    font-size: 22px;
  }

  .toast {
    max-width: none;
    bottom: 12px;
    left: 12px;
    right: 12px;
  }
}
