:root {
  --bg: #0d0d0d;
  --panel: #1f1f1f;
  --panel-2: #252525;
  --panel-3: #171717;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.42);
  --muted-strong: rgba(255, 255, 255, 0.62);
  --accent: #ff9700;
  --surface: var(--panel);
  --surface-soft: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --green: #44c36f;
  --red: #ff6b6b;
  --font-ui: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.02), transparent 22%),
    radial-gradient(circle at 16% 18%, rgba(255, 255, 255, 0.015), transparent 16%),
    linear-gradient(180deg, #111 0%, #090909 100%);
  font-family: var(--font-ui);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  width: 100%;
  margin: 0;
  padding: 0 0 20px;
}

.db-header,
.config-panel,
.meeting-sheet,
.target-box,
.target-card,
.history-card,
.rule-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: none;
}

.db-header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 14px 0 10px;
  border: 0;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(25, 25, 25, 0.96), rgba(25, 25, 25, 0.88) 82%, rgba(25, 25, 25, 0));
}

.db-toolbar-primary {
  width: min(1660px, calc(100vw - 24px));
  margin: 0 auto;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) auto minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.toolbar-stats,
.toolbar-detail,
.toolbar-actions,
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar-stats,
.toolbar-detail {
  min-width: 0;
}

.toolbar-stats span,
.toolbar-detail span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.toolbar-detail {
  overflow: hidden;
}

.toolbar-detail span {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar-stats strong {
  color: var(--text);
  font-weight: 500;
}

.tab,
.db-toolbar-action,
.icon-button,
.primary,
.secondary,
.note-action {
  min-height: 31px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-strong);
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.tab,
.db-toolbar-action,
.primary,
.secondary {
  padding: 6px 10px;
  font-size: 12px;
}

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

.tab.is-active,
.db-toolbar-action.is-active,
.icon-button.is-active {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.db-toolbar-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.icon-button {
  width: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.tab:hover,
.db-toolbar-action:hover,
.icon-button:hover,
.secondary:hover,
.note-action:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.primary {
  min-height: 32px;
  padding: 0 12px;
  border-color: var(--accent);
  background: var(--accent);
  color: #141414;
  font-weight: 650;
}

.secondary {
  border-color: var(--line);
}

.approval-workspace {
  width: min(1180px, calc(100vw - 24px));
  margin: 14px auto 0;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.deploy-grid,
.config-grid {
  display: grid;
  gap: 12px;
  align-items: start;
}

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

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

.config-panel,
.meeting-sheet {
  padding: 16px;
}

.section-head,
.sheet-head {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.section-head.compact {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.eyebrow,
.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

h1 {
  font-size: 16px;
  line-height: 1.25;
  font-weight: 600;
}

h2 {
  font-size: 15px;
  line-height: 1.25;
  font-weight: 600;
}

.field,
.rule-list,
.target-list,
.history-list {
  display: grid;
  gap: 10px;
}

.field-row,
.actions-row {
  display: grid;
  gap: 10px;
}

.field-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.actions-row {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  margin-top: 10px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  padding: 9px 10px;
  font-size: 14px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.055);
}

textarea {
  min-height: 132px;
}

.target-box {
  margin-top: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.018);
}

.target-card,
.history-card,
.rule-card {
  padding: 11px;
  background: rgba(255, 255, 255, 0.025);
}

.target-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.target-card strong,
.history-card strong,
.rule-card strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
  font-weight: 600;
}

.target-card small,
.history-card small,
.rule-card p,
.save-state,
.auth-warning {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.target-card.is-ready {
  border-color: rgba(68, 195, 111, 0.28);
}

.target-card.is-unready {
  border-color: rgba(255, 107, 107, 0.24);
}

.target-status {
  color: var(--muted);
  font-size: 12px;
}

.target-status.is-ready {
  color: var(--green);
}

.target-status.is-unready {
  color: #ffb4a8;
}

.history-card {
  display: grid;
  gap: 9px;
}

.history-meta,
.history-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.pill.is-success {
  color: var(--green);
}

.rules-disclosure {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.rules-disclosure summary {
  min-height: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--muted-strong);
  font-size: 12px;
  list-style: none;
  cursor: pointer;
}

.rules-disclosure summary::-webkit-details-marker {
  display: none;
}

.rules-disclosure summary i {
  color: var(--muted);
  font-size: 10px;
  transition: transform 160ms ease;
}

.rules-disclosure[open] summary i {
  transform: rotate(180deg);
}

.hidden {
  display: none;
}

.mobile-header,
.mobile-bottom-dock {
  display: none;
}

.mobile-header {
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 52px;
  padding: 6px 12px 8px;
}

.mobile-view-title {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-header-icons {
  display: flex;
  gap: 2px;
}

.mobile-icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  display: inline-grid;
  place-items: center;
}

.mobile-icon-btn:active {
  background: var(--surface-hover);
}

.mobile-bottom-dock {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  align-items: center;
  justify-content: space-around;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: rgba(12, 12, 12, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.dock-btn {
  flex: 1;
  min-height: 50px;
  border: 0;
  background: transparent;
  color: var(--muted-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.dock-btn i {
  font-size: 19px;
  line-height: 1;
}

.dock-btn span {
  font-size: 10px;
  line-height: 1;
}

.dock-btn.is-active,
.dock-btn:active {
  color: var(--text);
}

@media (max-width: 1180px) {
  .db-toolbar-primary {
    grid-template-columns: 1fr;
  }

  .toolbar-detail span {
    max-width: 100%;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .db-header {
    padding: 0;
  }

  .db-toolbar-primary {
    display: none;
  }

  .mobile-header,
  .mobile-bottom-dock {
    display: flex;
  }

  .approval-workspace {
    width: 100%;
    margin-top: 0;
    padding: 0 10px;
  }

  .config-panel,
  .meeting-sheet {
    padding: 14px;
    border-radius: 10px;
  }

  .config-grid,
  .field-row,
  .actions-row,
  .target-card {
    grid-template-columns: 1fr;
  }

  .target-card,
  .db-toolbar-action,
  .icon-button,
  .primary,
  .secondary {
    min-height: 44px;
  }
}
