:root {
  color-scheme: dark;
  --bg: #07111f;
  --gradient: #251052;
  --panel: rgba(15, 23, 42, .78);
  --header: rgba(15, 23, 42, .95);
  --line: rgba(147, 177, 215, .30);
  --line-strong: rgba(147, 177, 215, .48);
  --text: #eaf3ff;
  --muted: color-mix(in srgb, var(--text) 64%, transparent);
  --accent: #8b5cf6;
  --primary: #22d3ee;
  --danger: #ff667d;
  --overlay-color: #020617;
  --overlay-opacity: .35;
  --radius: 12px;
  --row-height: 44px;
  --cell-pad-y: 10px;
  --cell-pad-x: 12px;
  --cell-padding: 12px;
  --title-align: left;
  --header-align: left;
  --body-align: left;
  --table-max-width: 100%;
  --font-size: 14px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html,
body { min-height: 100%; }

body {
  margin: 0;
  background: linear-gradient(135deg, var(--bg), var(--gradient));
  color: var(--text);
  font-family: var(--font-family);
  font-size: var(--font-size);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  z-index: -2;
  background-image: var(--image-bg);
  background-size: var(--image-size, cover);
  background-position: var(--image-position, center);
  background-repeat: no-repeat;
  opacity: 0;
}

body.has-bg-image::before { opacity: 1; }

body::after {
  z-index: -1;
  background: var(--overlay-color);
  opacity: var(--overlay-opacity);
}

.wrap {
  width: min(var(--table-max-width), calc(100vw - 48px));
  max-width: calc(100vw - 48px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 0;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .22);
  backdrop-filter: blur(16px);
}

.title-block {
  min-width: 220px;
  text-align: var(--title-align);
}

h1 {
  font-size: 24px;
  margin: 0;
  line-height: 1.2;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.tools {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

button,
input,
select {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 84%, #000);
  color: var(--text);
  border-radius: 999px;
  min-height: 36px;
  padding: 8px 12px;
  font: inherit;
}

button {
  cursor: pointer;
  white-space: nowrap;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:hover,
input:focus,
select:focus {
  border-color: var(--primary);
  outline: none;
}

button.primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #06111f;
  border-color: transparent;
  font-weight: 800;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--primary) 22%, transparent);
}

.search {
  width: min(320px, 42vw);
}

.filter {
  width: 168px;
}

.hidden {
  display: none !important;
}

.status {
  min-height: 0;
  margin: 0 0 8px;
  padding: 0 4px;
}

.status:empty {
  display: none;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  overflow: hidden;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .26);
  backdrop-filter: blur(14px);
}

.scroll {
  overflow: auto;
  max-height: calc(100vh - 122px);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 780px;
}

th,
td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: var(--cell-padding);
  text-align: var(--body-align);
  vertical-align: middle;
  white-space: nowrap;
  line-height: 1.45;
  min-height: var(--row-height);
}

th:first-child,
td:first-child {
  border-left: 0;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--header);
  color: color-mix(in srgb, var(--text) 92%, white);
  font-size: calc(var(--font-size) - 1px);
  font-weight: 800;
  text-align: var(--header-align);
  box-shadow: 0 1px 0 var(--line);
}

tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--panel) 62%, transparent);
}

tbody tr:hover td {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}

td.editable {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  cursor: text;
}

td.editable:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--primary) 18%, transparent);
}

td.dirty {
  box-shadow: inset 3px 0 0 var(--accent);
}


.action-col,
.row-actions {
  width: 92px;
  text-align: center;
}

button.danger.small {
  border: 1px solid rgba(248, 113, 113, 0.42);
  background: rgba(127, 29, 29, 0.72);
  color: #fee2e2;
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

button.danger.small:hover {
  background: rgba(185, 28, 28, 0.86);
}

.empty,
.error {
  padding: 14px 16px;
  color: var(--muted);
}

.error {
  color: #ffb5c0;
}

@media (max-width: 760px) {
  .wrap {
    width: min(var(--table-max-width), calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    padding: 12px 0;
  }

  .top {
    display: block;
    padding: 14px;
  }

  .tools {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .search,
  .filter,
  button {
    width: 100%;
  }

  h1 {
    font-size: 20px;
  }

  .scroll {
    max-height: calc(100vh - 178px);
  }
}
