:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-soft: #eef2ed;
  --surface-tint: #f9faf7;
  --border: #d8ded5;
  --border-strong: #bbc7bd;
  --text: #18201b;
  --muted: #637065;
  --dim: #8a958c;
  --accent: #0d7863;
  --accent-strong: #075f4e;
  --accent-soft: #dff1eb;
  --amber: #b86e09;
  --amber-soft: #fff2d7;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --shadow: 0 18px 50px rgba(24, 32, 27, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hidden {
  display: none !important;
}

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

.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  align-items: stretch;
}

.auth-panel {
  display: grid;
  align-content: center;
  gap: 20px;
  padding: 38px clamp(24px, 5vw, 72px);
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 760;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-block;
  border: 1px solid #173f37;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 44%, #173f37 44% 56%, transparent 56%),
    linear-gradient(#173f37, #173f37);
}

.auth-panel h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(36px, 4.4vw, 58px);
  line-height: 1.04;
  font-weight: 760;
  letter-spacing: 0;
}

.auth-panel p {
  max-width: 650px;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.auth-form {
  width: min(460px, 100%);
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  padding: 0 12px;
  font-size: 14px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-error {
  margin: 0;
  color: var(--danger) !important;
  font-size: 13px !important;
}

.auth-aside {
  display: grid;
  place-items: center;
  padding: clamp(28px, 5vw, 72px);
  background:
    linear-gradient(135deg, rgba(13, 120, 99, 0.08), transparent 36%),
    linear-gradient(315deg, rgba(184, 110, 9, 0.08), transparent 42%),
    #f1f4ef;
}

.preview-shell {
  width: min(760px, 92%);
  aspect-ratio: 1.25;
  display: grid;
  grid-template-columns: 190px 1fr;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.preview-sidebar {
  border-right: 1px solid var(--border);
  background:
    linear-gradient(#dce8e2 0 0) 24px 30px / 118px 12px no-repeat,
    linear-gradient(#eff3ef 0 0) 24px 68px / 130px 34px no-repeat,
    linear-gradient(#eff3ef 0 0) 24px 114px / 128px 34px no-repeat,
    linear-gradient(#eff3ef 0 0) 24px 160px / 116px 34px no-repeat,
    #f8faf7;
}

.preview-main {
  padding: 42px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.preview-main span {
  display: block;
  height: 58px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-soft), var(--surface));
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 282px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-right: 1px solid var(--border);
  background: #fbfcfa;
}

.sidebar-head {
  padding: 22px 22px 18px;
}

.sidebar-section {
  min-height: 0;
  padding: 0 14px 18px;
  overflow: auto;
}

.sidebar-label {
  padding: 0 8px 10px;
  color: var(--dim);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.provider-list {
  display: grid;
  gap: 6px;
}

.provider-item {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 10px 9px;
  color: var(--text);
  text-align: left;
}

.provider-item:hover {
  background: var(--surface-soft);
}

.provider-item.active {
  border-color: #a9d8c8;
  background: var(--accent-soft);
}

.provider-item.disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.provider-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #22332f;
  color: #f4fbf7;
  font-size: 12px;
  font-weight: 800;
}

.muted-icon {
  background: #e5ebe6;
  color: #536057;
}

.provider-item strong,
.provider-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-item strong {
  font-size: 14px;
}

.provider-item small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding: 14px;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(247, 248, 245, 0.92);
  padding: 18px 24px;
  backdrop-filter: blur(14px);
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 25px;
  line-height: 1.12;
  letter-spacing: 0;
}

.runtime-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #f1cd9b;
  background: var(--amber-soft);
  color: #68420c;
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 760;
}

.runtime-banner svg {
  flex: 0 0 auto;
  color: var(--amber);
}

.breadcrumbs {
  min-height: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.crumb {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px 0;
  font-size: 13px;
  font-weight: 650;
}

.crumb:hover,
.crumb.active {
  color: var(--accent-strong);
}

.crumb-separator {
  color: var(--dim);
}

.account-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 7px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-tint);
  padding: 13px 24px;
}

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

.button,
.icon-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 0 13px;
  font-size: 13px;
  font-weight: 750;
}

.button:hover,
.icon-button:hover {
  border-color: var(--border-strong);
  background: #f4f7f2;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.button.primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.button.ghost {
  background: transparent;
}

.button.danger,
.icon-button.danger {
  color: var(--danger);
}

.full {
  width: 100%;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.search {
  width: min(360px, 34vw);
  position: relative;
  display: block;
}

.search span {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--dim);
}

.search input {
  padding-left: 38px;
  background: var(--surface);
}

.content-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 316px;
}

.object-panel {
  min-width: 0;
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  font-size: 14px;
}

.table-head div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.table-head .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-text {
  color: var(--dim);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.table-wrap {
  min-height: 0;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  height: 48px;
  border-bottom: 1px solid #eef1ec;
  padding: 0 14px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbfcfa;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

th:nth-child(2),
td:nth-child(2) {
  width: 44%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 15%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 23%;
}

.select-col {
  width: 42px;
  padding-left: 18px;
  padding-right: 0;
}

tbody tr {
  background: var(--surface);
}

tbody tr:hover {
  background: #f7faf5;
}

tbody tr.selected {
  background: #eef8f4;
}

.name-cell-inner {
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}

.row-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.row-name {
  min-width: 0;
  max-width: 100%;
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  display: inline-block;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 680;
}

.empty-state {
  position: absolute;
  inset: 118px 24px auto;
  display: grid;
  justify-items: center;
  gap: 8px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: #fbfcfa;
  padding: 40px 20px;
  text-align: center;
}

.empty-state span {
  color: var(--accent);
}

.empty-state h2 {
  margin: 0;
  font-size: 18px;
}

.empty-state p {
  max-width: 340px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.details-panel {
  min-width: 0;
  background: #fbfcfa;
}

.details-head {
  height: 54px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
}

.details-body {
  padding: 18px;
}

.details-body h2 {
  margin: 3px 0 16px;
  overflow-wrap: anywhere;
  font-size: 20px;
  line-height: 1.25;
}

.detail-kicker {
  color: var(--amber);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

dl {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  margin: 0;
  font-size: 13px;
}

dt {
  color: var(--dim);
  font-weight: 760;
}

dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

code {
  color: #24342f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.dialog {
  width: min(430px, calc(100vw - 28px));
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 0;
}

.dialog::backdrop {
  background: rgba(24, 32, 27, 0.32);
}

.dialog form,
.dialog-layout {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.dialog h2 {
  margin: 0;
  font-size: 20px;
}

.dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 4px 0 0;
  padding: 0;
}

.wide-dialog {
  width: min(980px, calc(100vw - 28px));
}

.dialog-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-title p {
  margin: 5px 0 0;
  font-size: 14px;
}

.user-form {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-tint);
  padding: 14px;
}

.api-key-form {
  grid-template-columns: minmax(220px, 1fr) auto;
}

.api-key-row .api-key-value {
  margin-top: 10px;
}

.api-key-row input[readonly] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.users-list {
  display: grid;
  gap: 8px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(0, auto);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px;
}

.user-row strong,
.user-row span {
  display: block;
}

.user-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.share-target {
  margin: -6px 0 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.share-section {
  display: grid;
  gap: 12px;
}

.share-section + .share-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.share-create {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-tint);
  padding: 14px;
}

.share-url-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
}

.inline-label {
  padding: 0 0 8px;
}

.share-links {
  display: grid;
  gap: 8px;
}

.share-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px;
}

.share-row strong,
.share-row span {
  display: block;
}

.share-row span {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-actions {
  display: flex;
  gap: 8px;
}

.share-note {
  border: 1px solid #a9d8c8;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 750;
}

.compact-input {
  width: 170px;
}

.empty-inline {
  border: 1px dashed var(--border-strong);
  border-radius: 9px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  border: 1px solid #a9d8c8;
  border-radius: 10px;
  background: #102c26;
  color: #fff;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
}

.is-busy .toolbar,
.is-busy .table-wrap {
  cursor: progress;
}

@media (max-width: 1040px) {
  .app {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .details-panel {
    display: none;
  }

  .search {
    width: 280px;
  }
}

@media (max-width: 760px) {
  .auth-screen {
    grid-template-columns: 1fr;
  }

  .auth-aside {
    display: none;
  }

  .auth-panel {
    border-right: 0;
  }

  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-section {
    padding-bottom: 10px;
  }

  .provider-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 1fr);
    overflow-x: auto;
  }

  .sidebar-footer {
    grid-template-columns: 1fr 1fr;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .account-area,
  .toolbar-actions {
    width: 100%;
  }

  .search {
    width: 100%;
  }

  .content-grid {
    width: 100vw;
    max-width: 100vw;
    min-height: 560px;
  }

  .object-panel,
  .table-head,
  .table-wrap,
  table {
    width: 100vw;
    max-width: 100vw;
  }

  th,
  td {
    padding-left: 10px;
    padding-right: 10px;
  }

  .select-col {
    width: 40px;
    padding-left: 16px;
    padding-right: 0;
  }

  th:nth-child(3),
  td:nth-child(3) {
    width: 76px;
    padding-left: 8px;
    padding-right: 12px;
  }

  .name-cell-inner {
    gap: 8px;
  }

  .row-icon {
    width: 24px;
    height: 24px;
  }

  th:nth-child(4),
  td:nth-child(4),
  th:nth-child(5),
  td:nth-child(5) {
    display: none;
  }

  th:nth-child(2),
  td:nth-child(2) {
    width: auto;
  }

  .user-form,
  .user-row,
  .share-create,
  .share-row {
    grid-template-columns: 1fr;
  }

  .user-actions,
  .share-actions {
    justify-content: flex-start;
  }

  .compact-input {
    width: 100%;
  }
}
