/* ========================================
   DB ARCHITECT — RUNDONE BRUTALIST STYLE
   ======================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/inter-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ========================================
   TOKENS (matching RunDone main.css)
   ======================================== */
:root {
  color-scheme: dark;
  accent-color: var(--primary);

  --primary: #14b8a6;
  --primary-btn: #0f766e;
  --primary-hover: #115e59;
  --primary-20: rgba(20, 184, 166, 0.2);
  --primary-10: rgba(20, 184, 166, 0.1);

  --neon: #00ff41;
  --neon-20: rgba(0, 255, 65, 0.2);
  --neon-10: rgba(0, 255, 65, 0.1);

  --danger: #ef4444;
  --danger-hover: #dc2626;

  --bg: #000000;
  --surface: #191919;
  --surface2: #242424;
  --border: #333333;
  --border-strong: #7f7f7f;

  --text: #ffffff;
  --text2: #a3a3a3;
  --text-muted: #737373;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --glow: 0 0 20px rgba(20, 184, 166, 0.3);
  --glow-neon: 0 0 10px rgba(0, 255, 65, 0.3);
}

/* ========================================
   RESET
   ======================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
::-webkit-scrollbar-corner { background: var(--bg); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) var(--bg); }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: var(--font-mono);
  font-weight: 400;
  line-height: 1.2;
}

.screen { min-height: 100vh; }

/* ========================================
   AUTH BACKGROUND GRID
   ======================================== */
#auth-screen {
  position: relative;
  overflow: hidden;
  background-image:
    linear-gradient(rgba(0, 255, 65, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 65, 0.07) 1px, transparent 1px);
  background-size: 24px 24px;
}
#auth-screen::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(0, 255, 65, 0.12);
  animation: scanline 8s linear infinite;
  pointer-events: none;
}
@keyframes scanline {
  from { top: 0; }
  to { top: 100%; }
}
.auth-box {
  position: relative;
  z-index: 1;
  animation: authAppear 0.5s ease-out both;
}
#auth-screen.auth-leaving .auth-box {
  animation: authLeave 0.3s ease-out forwards;
}
@keyframes authAppear {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}
@keyframes authLeave {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ========================================
   GLITCH ANIMATION
   ======================================== */
@keyframes glitch {
  0% { transform: translate(0); filter: none; }
  20% { transform: translate(-2px, 1px); filter: hue-rotate(90deg); }
  40% { transform: translate(2px, -1px); filter: hue-rotate(180deg); }
  60% { transform: translate(-1px, -1px); filter: hue-rotate(270deg); }
  80% { transform: translate(1px, 1px); filter: hue-rotate(360deg); }
  100% { transform: translate(0); filter: none; }
}

/* ========================================
   CORNER FRAME (brutalist card decoration)
   ======================================== */
.corner-frame {
  position: relative;
}
.corner-frame::before,
.corner-frame::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: var(--primary);
  border-style: solid;
  pointer-events: none;
  z-index: 10;
}
.corner-frame::before {
  top: -1px;
  left: -1px;
  border-width: 2px 0 0 2px;
}
.corner-frame::after {
  bottom: -1px;
  right: -1px;
  border-width: 0 2px 2px 0;
}

/* ========================================
   AUTH SCREEN
   ======================================== */
.auth-box {
  max-width: 400px;
  margin: 0 auto;
  padding-top: 20vh;
  text-align: center;
}
.auth-box h1 {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 400;
  color: var(--neon);
  text-shadow: var(--glow-neon);
  margin-bottom: 0.5rem;
}
.auth-sub {
  font-family: var(--font-mono);
  color: var(--text2);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 3rem;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-form input {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 0;
  padding: 14px 16px;
  color: var(--text);
  font-family: var(--font-mono);
  /* iOS Safari: font-size >= 16px prevents auto-zoom on focus */
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.auth-form input:focus {
  border-color: var(--primary);
  box-shadow: var(--glow);
}
.auth-form input::placeholder {
  color: var(--text-muted);
}
.auth-buttons {
  display: flex;
  gap: 8px;
}
.auth-buttons .btn { flex: 1; }
.error-msg {
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ========================================
   BUTTONS (brutalist)
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 24px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-decoration: none;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}
.btn-primary {
  background: var(--primary-btn);
  color: #fff;
  border-color: var(--primary-btn);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: var(--glow);
  transform: translateY(-1px);
}
.btn-primary:active {
  animation: glitch 0.1s ease-in-out;
}
.btn-secondary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-secondary:hover {
  background: var(--primary-10);
  box-shadow: var(--glow);
}
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border-color: transparent;
  min-height: 36px;
  padding: 6px 12px;
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--border);
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}
.btn-small {
  min-height: 32px;
  padding: 4px 12px;
  font-size: 11px;
}

/* ========================================
   HEADER
   ======================================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 64px;
  background: var(--surface);
  border-bottom: 2px solid var(--border-strong);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.dba-logo {
  display: flex;
  align-items: center;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.dba-logo:hover {
  opacity: 1;
}
.dba-logo-auth {
  justify-content: center;
  opacity: 1;
  margin-bottom: 16px;
}
.dba-logo-auth svg {
  overflow: visible;
}
.dba-logo-auth .logo-stroke {
  stroke-dasharray: 733;
  stroke-dashoffset: 733;
  animation: logoDrawIn 1.5s ease-out forwards, logoGlow 3s ease-in-out 1.5s infinite;
}
@keyframes logoDrawIn {
  to { stroke-dashoffset: 0; }
}
@keyframes logoGlow {
  0%, 100% {
    opacity: 0.8;
  }
  50% {
    opacity: 1;
  }
}
.header-left h1 {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 400;
  color: var(--primary);
}
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--primary);
  background: var(--primary-10);
  padding: 4px 12px;
  border: 1px solid var(--primary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ========================================
   LAYOUT
   ======================================== */
.app-body {
  display: flex;
  height: calc(100vh - 64px);
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--surface);
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  border-bottom: 1px solid var(--border);
}
.table-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}
.table-list li {
  padding: 12px 20px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}
.table-list li:hover {
  background: var(--surface2);
  border-left-color: var(--border-strong);
}
.table-list li.active {
  background: var(--surface2);
  border-left-color: var(--primary);
  color: var(--primary);
}
.table-list .row-count {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.table-list li.sub-table-item {
  padding-left: 32px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.table-list li.sub-table-item:hover { color: var(--text); }
.table-list li.sub-table-item.active { color: var(--primary); }

/* Connection section in sidebar */
.sidebar-section {
  border-top: 2px solid var(--border);
}
.conn-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--border);
  color: var(--text);
  border-radius: 2px;
  margin-right: 6px;
  flex-shrink: 0;
}
.conn-agent-badge {
  font-size: 11px;
  color: var(--accent);
  margin-left: auto;
  margin-right: 4px;
  opacity: 0.7;
}
.conn-group-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 10px 12px 4px;
  display: flex;
  justify-content: space-between;
  cursor: default;
}
.conn-group-header:first-child { padding-top: 4px; }
.conn-group-item { padding-left: 12px; }
.btn-offline-dl {
  margin-left: auto;
  font-size: 16px;
  padding: 2px 6px;
}
.offline-dirty-dot {
  color: var(--warning, #f59e0b);
  font-size: 10px;
  margin-left: 4px;
}
.blob-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.blob-link:hover { text-decoration: underline; }
.blob-icon { opacity: 0.6; flex-shrink: 0; }
.excel-preview-wrap { max-height: 70vh; overflow: auto; border: 1px solid var(--border); border-radius: 4px; background: #fff; color: #111; }
.excel-preview-wrap table { border-collapse: collapse; width: 100%; font-size: 12px; color: #111; }
.excel-preview-wrap td, .excel-preview-wrap th { border: 1px solid #ddd; padding: 3px 6px; text-align: left; color: #111; }
.excel-preview-wrap tr:nth-child(even) { background: #f8f8f8; }

/* Context menu */
.ctx-menu {
  position: fixed;
  z-index: 500;
  background: var(--surface);
  border: 2px solid var(--primary);
  min-width: 180px;
  max-width: 320px;
  font-size: 13px;
  font-family: var(--font-mono);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.ctx-menu-item {
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.ctx-menu-item:hover { background: var(--primary); color: var(--bg); }
.ctx-menu-sep { height: 1px; background: var(--border); margin: 2px 0; }
.ctx-menu-config { color: var(--text-muted); font-size: 11px; }
.ctx-icon { width: 16px; text-align: center; flex-shrink: 0; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; }
.ctx-icon svg { width: 16px; height: 16px; stroke: currentColor; }

/* Icon picker */
.icon-picker-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
}
.icon-picker {
  background: var(--surface); border: 2px solid var(--primary);
  width: 420px; max-height: 480px; display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.icon-picker-search {
  margin: 12px; padding: 8px 12px; background: var(--bg);
  border: 1px solid var(--border); color: var(--text);
  font-family: var(--font-mono); font-size: 13px;
}
.icon-picker-grid {
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 2px; padding: 0 12px 12px; overflow-y: auto; max-height: 380px;
}
.icon-picker-btn {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid transparent; color: var(--text);
  cursor: pointer; transition: border-color 0.15s;
}
.icon-picker-btn:hover { border-color: var(--primary); }
.icon-picker-btn.active { border-color: var(--primary); background: var(--primary-btn); }
.icon-picker-btn svg { width: 20px; height: 20px; stroke: currentColor; }

/* Action toast */
.action-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  padding: 10px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  z-index: 300;
  animation: toast-in 0.3s ease-out;
}
.action-toast-ok { border-color: var(--primary); color: var(--primary); }

/* Action config modal */
.action-config-section { margin-bottom: 16px; }
.action-config-section h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin: 0 0 8px; color: var(--text-muted); }
.action-config-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.action-config-search { margin-bottom: 8px; }
.action-registry-list { max-height: 300px; overflow-y: auto; }
.action-registry-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.badge-method {
  font-size: 9px;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 2px;
  text-transform: uppercase;
}
.badge-get { background: #22c55e20; color: #22c55e; }
.badge-post { background: #3b82f620; color: #3b82f6; }
.badge-put { background: #f59e0b20; color: #f59e0b; }
.badge-delete { background: #ef444420; color: #ef4444; }
.btn-conn-edit {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.table-list li:hover .btn-conn-edit { opacity: 0.7; }
.btn-conn-edit:hover { opacity: 1 !important; color: var(--text); }

/* Remote drill-down back bar */
.remote-back-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text);
}
.remote-back-bar .btn { flex-shrink: 0; }
.remote-back-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.loading-item {
  padding: 12px 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  list-style: none;
}

/* Trigger list */
.trigger-list { display: flex; flex-direction: column; gap: 2px; }
.trigger-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 4px;
  background: var(--bg);
  font-size: 12px;
  font-family: var(--font-mono);
}
.trigger-item:hover { background: var(--border); }
.trigger-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.trigger-name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trigger-table { font-size: 10px; color: var(--text-muted); }
.trigger-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* File links in remote tables */
.file-link {
  color: var(--primary);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 11px;
}
.file-link:hover { text-decoration: underline; }

/* ========================================
   CONTENT
   ======================================== */
.content {
  flex: 1;
  overflow: auto;
  padding: 32px;
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60%;
  gap: 16px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.empty-state svg {
  opacity: 0.2;
  stroke: var(--primary);
}

/* ========================================
   TABLE TOOLBAR — Müller-Brockmann:
   Weight shifts with context.
   Default: Title (heavy) — [+ Record] [🔍] [⋯]
   Search:  Title (light) — [===search===] [+ Record] [⋯]
   ======================================== */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  min-height: 36px;
}
.table-toolbar h2 {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 400;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  transition: flex 0.3s ease, opacity 0.3s ease;
  flex: 1 1 auto;
}
.table-title-editable {
  cursor: pointer;
  border-bottom: 1px dashed var(--primary-20);
  transition: border-color 0.2s;
}
.table-title-editable:hover {
  border-color: var(--primary);
}

/* Period filter */
.toolbar-period {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
}
.period-input {
  font-family: var(--font-mono);
  /* iOS Safari: font-size >= 16px prevents auto-zoom on focus */
  font-size: 1rem;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  width: 120px;
}
.period-sep {
  color: var(--text-muted);
  font-size: 11px;
}

/* Search area — grows when active, hidden when not */
.toolbar-search {
  display: flex;
  gap: 8px;
  flex: 0 0 0;
  min-width: 0;
  overflow: hidden;
  transition: flex 0.3s ease;
}
.toolbar-search.active {
  flex: 1 1 320px;
}

/* Primary actions — always visible, compact */
.toolbar-primary {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.btn-icon {
  padding: 4px 6px !important;
  line-height: 1;
}
.btn-search-active {
  color: var(--primary) !important;
  border-color: var(--primary) !important;
}

/* Overflow menu (⋯) */
.toolbar-more-wrap {
  position: relative;
}
.toolbar-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  z-index: 100;
  padding: 4px 0;
}
.toolbar-menu.open {
  display: block;
}
.toolbar-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 14px;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.menu-icon {
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.toolbar-menu-item:hover .menu-icon {
  opacity: 1;
}
.toolbar-menu-item:hover {
  background: var(--primary-10);
  color: var(--primary);
}
.toolbar-menu-danger {
  color: var(--danger);
}
.toolbar-menu-danger:hover {
  background: rgba(255,64,64,0.1);
  color: var(--danger);
}
.toolbar-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.toolbar-menu-item.menu-active {
  color: var(--primary);
}
.toolbar-menu-item.menu-active::after {
  content: '✓';
  margin-left: auto;
}

/* ========================================
   DATA TABLE
   ======================================== */
.data-table-wrap {
  overflow-x: auto;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 13px;
}
table.data-table th {
  background: var(--surface);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid var(--border-strong);
  white-space: nowrap;
}
table.data-table th small {
  font-weight: 400;
  opacity: 0.5;
}
table.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table.data-table tr:hover td {
  background: var(--surface);
}
table.data-table .col-id {
  width: 60px;
  color: var(--text-muted);
}
table.data-table .col-actions {
  width: 80px;
  text-align: right;
}

/* Inline cell editing (Excel-like) */
.editable-cell { cursor: cell; }
.editable-cell:hover {
  background: var(--surface);
  outline: 1px solid var(--border);
  outline-offset: -1px;
}
.editable-cell.editing {
  padding: 0;
  overflow: visible;
  white-space: normal;
}
.editable-cell.editing input,
.editable-cell.editing textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 16px;
  font: inherit;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--primary);
  outline: none;
  margin: 0;
  resize: none;
}
.editable-cell.saved {
  animation: cell-saved 0.6s ease-out;
}
@keyframes cell-saved {
  0% { background: rgba(20, 184, 166, 0.2); }
  100% { background: transparent; }
}

/* Mapping modal */
.mapping-table-wrap { overflow-x: auto; margin-bottom: 1rem; }
.mapping-table { width: 100%; border-collapse: collapse; font-size: 13px; font-family: var(--font-mono); }
.mapping-table th { padding: 8px 12px; text-align: left; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; border-bottom: 2px solid var(--border-strong); }
.mapping-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.mapping-table .map-src { white-space: nowrap; }
.mapping-table .map-arrow { text-align: center; color: var(--text-muted); width: 30px; }
/* iOS Safari: form controls need font-size >= 16px to prevent auto-zoom on focus */
.mapping-table .map-select { width: 100%; padding: 6px 8px; background: var(--bg); color: var(--text); border: 1px solid var(--border); font: inherit; font-size: 1rem; }
.mapping-table tr.map-high .map-src { color: var(--primary); }
.mapping-table tr.map-med .map-src { color: #eab308; }
.mapping-table tr.map-low .map-src { color: var(--text-muted); }
.mapping-preview { margin-bottom: 1rem; }
.mapping-preview-title { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; font-family: var(--font-mono); }
.mapping-preview-scroll { overflow-x: auto; max-height: 200px; overflow-y: auto; }
.mapping-preview .data-table { font-size: 11px; }
.mapping-preview .data-table td { padding: 4px 8px; max-width: 150px; }
.mapping-preview .data-table th { padding: 4px 8px; font-size: 10px; }
/* Wider modal for mapping */
.modal-box:has(.mapping-table) { max-width: 700px; }

/* Undo toast */
.undo-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 2px solid var(--primary);
  padding: 12px 20px; font-family: var(--font-mono); font-size: 13px;
  color: var(--text); z-index: 300; display: flex; align-items: center; gap: 12px;
  animation: toast-in 0.3s ease-out;
}
.undo-toast button {
  background: none; border: 1px solid var(--primary); color: var(--primary);
  padding: 4px 12px; font: inherit; font-size: 12px; cursor: pointer;
  text-transform: uppercase; letter-spacing: 1px;
}
.undo-toast button:hover { background: var(--primary); color: var(--bg); }
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.file-preview {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-size: 12px;
}
.file-preview img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
}

/* Quick Look popup (hover) */
.ql-popup {
  position: fixed;
  z-index: 20000;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  padding: 4px;
  pointer-events: none;
  max-width: 320px;
  max-height: 320px;
}
.ql-popup img {
  display: block;
  max-width: 100%;
  max-height: 312px;
  object-fit: contain;
}
.ql-popup .ql-name {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  padding: 2px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Quick Look fullscreen (Ctrl+Space) */
.ql-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 30000;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: zoom-out;
  backdrop-filter: blur(8px);
}
.ql-fullscreen img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  box-shadow: 0 0 60px rgba(0,0,0,0.5);
}
.ql-fullscreen .ql-info {
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface);
  padding: 4px 12px;
  border: 1px solid var(--border);
}

/* Styled file input */
.file-input-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.file-input-wrap input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.file-input-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface);
  border: 2px dashed var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s;
}
.file-input-btn:hover,
.file-input-wrap:hover .file-input-btn {
  border-color: var(--primary);
  color: var(--primary);
}
.file-input-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.file-input-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--primary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Inline upload button in table cells */
.cell-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}
.cell-upload-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.cell-upload-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.cell-reupload {
  margin-left: 6px;
  padding: 2px 5px;
  border-style: solid;
  font-size: 0;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 0 4px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.pg-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px;
  height: 28px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pg-btn:hover:not(:disabled) { background: var(--surface2); border-color: var(--primary); }
.pg-btn:disabled { opacity: 0.3; cursor: default; }
.pg-info {
  color: var(--text-muted);
  padding: 0 8px;
  letter-spacing: 0.5px;
}
.pg-size {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 6px;
  margin-left: 8px;
  cursor: pointer;
}
/* Hidden columns bar */
.hidden-cols-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  margin-bottom: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}
.hidden-cols-label {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
}
.hidden-col-tag {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.hidden-col-tag:hover { border-color: var(--primary); color: var(--primary); }
.hidden-col-showall { color: var(--primary); border-color: var(--primary); opacity: 0.7; }
.hidden-col-showall:hover { opacity: 1; }

/* Breadcrumb */
.table-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0 8px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.bc-link {
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
}
.bc-link:hover { text-decoration: underline; }
.bc-sep { color: var(--text-muted); margin: 0 2px; }
.bc-current { color: var(--text-muted); }

/* Sub-table cells */
.col-subtable { position: relative; }
.subtable-icon { opacity: 0.5; }
.col-drill-btn {
  display: none;
  margin-left: 4px;
  cursor: pointer;
  opacity: 0.3;
  font-size: 9px;
  vertical-align: middle;
}
th:hover .col-drill-btn { display: inline; }
.col-drill-btn:hover { opacity: 1; color: var(--primary); }
.cell-subtable { cursor: pointer; }
.cell-subtable:hover { background: var(--surface2); }
.subtable-link {
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
.row-actions button {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  font-size: 14px;
  transition: all 0.15s;
}
.row-actions button:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface2);
}
.row-actions button.del:hover {
  color: var(--danger);
  border-color: var(--danger);
}
.btn-action-inline {
  font-size: 11px !important;
  padding: 2px 6px !important;
  border-radius: 3px;
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}
.btn-action-inline:hover {
  background: var(--accent) !important;
  color: var(--bg) !important;
}
.btn-action-done {
  background: var(--success) !important;
  border-color: var(--success) !important;
  color: var(--bg) !important;
}

/* ========================================
   MODAL
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-box {
  background: var(--surface);
  border: 2px solid var(--border-strong);
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}
.modal-resize-handle {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 44px; height: 44px;
  cursor: nwse-resize;
  z-index: 11;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}
.modal-resize-handle::before,
.modal-resize-handle::after {
  content: "";
  position: absolute;
  border-color: var(--primary);
  border-style: solid;
  pointer-events: none;
}
.modal-resize-handle::before {
  bottom: 4px; right: 4px;
  width: 14px; height: 14px;
  border-width: 0 2px 2px 0;
}
.modal-resize-handle::after {
  bottom: 4px; right: 4px;
  width: 7px; height: 7px;
  border-width: 0 2px 2px 0;
}
/* Corner frame on modal */
.modal-box::before,
.modal-box::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: var(--primary);
  border-style: solid;
  pointer-events: none;
  z-index: 10;
}
.modal-box::before {
  top: -1px;
  left: -1px;
  border-width: 2px 0 0 2px;
}
.modal-box::after {
  bottom: -1px;
  right: -1px;
  border-width: 0 2px 2px 0;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 24px;
}
.modal-body .form-group {
  margin-bottom: 16px;
}
.modal-body label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.modal-body input,
.modal-body select,
.modal-body textarea {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 0;
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font-mono);
  /* iOS Safari: font-size >= 16px prevents auto-zoom on focus */
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--glow);
}
.modal-body input::placeholder,
.modal-body textarea::placeholder {
  color: var(--text-muted);
}
.modal-body select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23737373' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.modal-body select option {
  background: var(--surface);
  color: var(--text);
}
.modal-body textarea {
  resize: vertical;
  min-height: 60px;
}
.modal-body .field-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 8px;
}
.modal-body .field-row .form-group { flex: 1; margin-bottom: 0; }
.modal-body .field-row .btn-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 8px;
  font-size: 18px;
  transition: opacity 0.15s;
}
.modal-body .field-row .btn-remove:hover { opacity: 0.7; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* FK Combobox — parent record selector */
.fk-combo { position: relative; }
.fk-input {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  /* iOS Safari: font-size >= 16px prevents auto-zoom on focus */
  font-size: 1rem;
  box-sizing: border-box;
}
.fk-input:focus { border-color: var(--accent); outline: none; }
.fk-selected {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 2px solid var(--accent);
  background: var(--bg);
}
.fk-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--accent);
  color: var(--bg);
  padding: 3px 8px;
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 24px);
}
.fk-clear {
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1;
  flex-shrink: 0;
}
.fk-clear:hover { color: var(--danger, #e53); }
.fk-dropdown {
  display: none;
  position: absolute;
  left: 0; right: 0;
  top: 100%;
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  border: 2px solid var(--border);
  border-top: none;
  background: var(--bg);
}
.fk-dropdown.open { display: block; }
.fk-item {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-family: var(--font-mono);
}
.fk-item:last-child { border-bottom: none; }
.fk-item:hover, .fk-item.active { background: var(--hover); }
.fk-id {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}
.fk-col {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.fk-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ========================================
   LANGUAGE SWITCHER
   ======================================== */
.lang-switch {
  display: flex;
  gap: 0;
  margin-top: 24px;
  justify-content: center;
}
.lang-switch-header {
  margin-top: 0;
}
.lang-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.lang-btn:first-child {
  border-right: none;
}
.lang-btn.active {
  background: var(--primary-10);
  color: var(--primary);
  border-color: var(--primary);
}
.lang-btn:hover:not(.active) {
  color: var(--text);
  border-color: var(--border-strong);
}

/* ========================================
   SCHEMA TEMPLATES
   ======================================== */
.templates-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.template-card {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 16px;
  transition: border-color 0.15s;
}
.template-card:hover {
  border-color: var(--border-strong);
}
.template-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.template-card-header strong {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--primary);
}
.template-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.template-desc {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 8px;
}
.template-fields-preview {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.6;
  word-break: break-word;
}
.template-card-actions {
  display: flex;
  gap: 8px;
}

/* ========================================
   SIDEBAR ACTIONS
   ======================================== */
.sidebar-actions {
  display: flex;
  gap: 4px;
}

/* ========================================
   SQL PANEL
   ======================================== */
.sql-panel {
  border-top: 2px solid var(--border-strong);
  background: var(--surface);
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
}
.sql-left {
  width: 380px;
  min-width: 250px;
  max-width: 60%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.sql-resize {
  width: 4px;
  cursor: col-resize;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.15s;
}
.sql-resize:hover, .sql-resize.active { background: var(--primary); }
.sql-right {
  flex: 1;
  min-width: 200px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sql-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sql-panel-title {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 2px;
}
.sql-panel-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.sql-panel-footer {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.saved-queries-select {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 2px 6px;
  /* iOS Safari: font-size >= 16px prevents auto-zoom on focus */
  font-size: 1rem;
  max-width: 140px;
  cursor: pointer;
}
.sql-input {
  width: 100%;
  background: var(--bg);
  border: none;
  padding: 10px 12px;
  color: var(--primary);
  font-family: var(--font-mono);
  /* iOS Safari: font-size >= 16px prevents auto-zoom on focus */
  font-size: 1rem;
  resize: none;
  outline: none;
  flex: 1;
  min-height: 48px;
}
.sql-input::placeholder { color: var(--text-muted); }
.sql-suggestion {
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  max-height: 40%;
  overflow-y: auto;
  flex-shrink: 0;
}
.sql-suggestion:empty { display: none; }
.sql-suggestion code { color: var(--primary); display: block; padding: 8px 0; cursor: pointer; }
.sql-suggestion code:hover { background: var(--bg-secondary); }
.sql-suggestion .ai-label { font-size: 10px; color: #cc66ff; text-transform: uppercase; letter-spacing: 1px; padding: 6px 0 2px; }
.sql-results {
  overflow: auto;
  flex: 1;
}
.sql-results .data-table { margin: 0; }
.sql-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.sql-error {
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 12px 16px;
}
.sql-running {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 12px 16px;
}
.btn-sql {
  color: var(--primary) !important;
  border-color: var(--primary) !important;
  font-family: var(--font-mono) !important;
  letter-spacing: 1px;
}

/* ========================================
   SORTABLE COLUMNS & FILTERS
   ======================================== */
th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover {
  color: var(--primary);
}
.sort-arrow {
  font-size: 10px;
  margin-left: 4px;
}
.filter-row td {
  padding: 2px 6px;
}
.filter-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 3px 6px;
  color: var(--text);
  font-family: var(--font-mono);
  /* iOS Safari: font-size >= 16px prevents auto-zoom on focus */
  font-size: 1rem;
  outline: none;
}
.filter-input:focus {
  border-color: var(--primary);
}

/* ========================================
   DYNAMIC SEARCH INPUT (inside toolbar-search)
   ======================================== */
.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--primary);
  padding: 5px 12px;
  color: var(--text);
  font-family: var(--font-mono);
  /* iOS Safari: font-size >= 16px prevents auto-zoom on focus */
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus {
  border-color: var(--primary);
  box-shadow: var(--glow);
}
.search-input::placeholder {
  color: var(--text-muted);
}
.search-input-ai {
  border-color: #cc66ff;
}
.search-input-ai:focus {
  border-color: #cc66ff;
  box-shadow: 0 0 6px rgba(204, 102, 255, 0.15);
}
.search-hint {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 5px 0;
  animation: hintFade 2.5s ease-out forwards;
}
@keyframes hintFade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

/* NL→SQL mode */
.btn-nl-active {
  color: #cc66ff !important;
  border-color: #cc66ff !important;
}
.sql-input.nl-mode {
  border-color: #cc66ff;
  color: #cc99ff;
}
.sql-input.nl-mode::placeholder {
  color: rgba(204, 102, 255, 0.4);
}
.nl-generated-sql {
  padding: 6px 10px;
  background: rgba(204, 102, 255, 0.08);
  border-left: 3px solid #cc66ff;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.nl-generated-sql code {
  color: var(--primary);
  font-family: var(--font-mono);
}
.nl-label {
  color: #cc66ff;
  font-weight: 600;
}

/* ========================================
   UI FOCUS WEIGHT (Brockmann 4D)
   Active panel takes visual weight;
   inactive panels dim automatically.
   body[data-focus] drives state.
   ======================================== */

/* SQL focus: full-screen SQL panel */
body[data-focus="sql"] .content {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body[data-focus="sql"] .sql-panel {
  border-top: none;
}

/* Search focus: title yields space to search input */
body[data-focus="search"] .table-toolbar h2 {
  opacity: 0.4;
  flex: 0 0 auto;
}

/* Panel slide transitions */
.sql-panel {
  transition: border-top-color 0.3s ease;
}
@media (max-width: 768px) {
  .sql-panel { flex-direction: column; height: auto; max-height: 70vh; }
  .sql-left { width: 100% !important; max-width: 100% !important; min-width: 0; border-right: none; border-bottom: 1px solid var(--border); max-height: 40vh; }
  .sql-resize { display: none; }
  .sql-right { min-height: 150px; }
}

/* ========================================
   IMMERSIVE MODE — Apple-style auto-hide
   Chrome (header + sidebar) hides when user
   focuses on data. Mouse at screen edges
   reveals them as floating overlays.
   ======================================== */

body.immersive .app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  transform: translateY(-100%);
}
body.immersive .app-header.peek {
  transform: translateY(0);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
}

body.immersive .sidebar {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 50;
  transform: translateX(-100%);
}
body.immersive .sidebar.peek {
  transform: translateX(0);
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
}

body.immersive .app-body {
  height: 100vh;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
  .app-header { padding: 0 16px; }
  .app-body { flex-direction: column; }
  .sidebar {
    width: 100%;
    min-width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 2px solid var(--border);
  }
  .content { padding: 16px; }
  .table-toolbar {
    flex-wrap: wrap;
  }
  .table-toolbar h2 {
    font-size: 16px;
  }
  .toolbar-search.active {
    flex-basis: 100%;
    order: 3;
  }
  /* Disable immersive on mobile */
  body.immersive .app-header,
  body.immersive .sidebar {
    position: static;
    transform: none;
    box-shadow: none;
  }
  body.immersive .app-body {
    height: auto;
  }
}

/* ============================================
   Card Editor (Brockmann Grid)
   ============================================ */

.card-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ce-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}


.ce-title {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  flex: 1;
}

.ce-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ce-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.ce-main {
  flex: 1;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
}

/* The grid canvas — size set via JS inline style */
.ce-grid {
  display: grid;
  gap: 1px;
  width: max-content;
  background: var(--surface);
  border: 2px solid var(--border);
  position: relative;
}

.ce-cell {
  background: var(--surface2);
  border: 1px solid var(--border);
  min-height: 0;
  transition: background 0.1s;
}

.ce-cell:hover {
  background: rgba(20, 184, 166, 0.05);
}

/* Placed widgets on the grid */
.ce-widget {
  background: var(--primary-10);
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: grab;
  z-index: 1;
  user-select: none;
  transition: border-color 0.1s;
}

.ce-widget:hover {
  border-color: var(--text);
}

.ce-widget.selected {
  border-color: #fff;
  box-shadow: 0 0 20px rgba(20, 184, 166, 0.4);
}

.ce-widget-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ce-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: se-resize;
  background: var(--primary);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

/* Right sidebar — palette */
.ce-palette {
  width: 220px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  background: var(--surface);
}

.ce-palette-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}

.ce-palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  margin-bottom: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  cursor: grab;
  transition: border-color 0.15s;
}

.ce-palette-item:hover {
  border-color: var(--primary);
}

.ce-palette-item.placed {
  opacity: 0.35;
  cursor: default;
}

.ce-palette-name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.ce-palette-type {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Widget type picker */
.ce-widget-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ce-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 4px 0;
}

.ce-radio input[type="radio"] {
  accent-color: var(--primary);
}

.ce-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* Preview area */
.ce-preview {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 16px;
  background: var(--surface);
}

.ce-preview-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.ce-preview-search {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 10px;
  width: 200px;
  outline: none;
}

.ce-preview-search:focus {
  border-color: var(--primary);
}

.ce-preview-counter {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  min-width: 60px;
  text-align: center;
}

.ce-preview-card {
  max-width: 600px;
  margin: 0 auto;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 12px;
}

/* Preview widget styles */
.ce-preview-widget {
  overflow: visible;
  display: flex;
  align-items: flex-start;
  padding: 4px 8px;
  word-break: break-word;
}

.ce-pw-image { padding: 0; }
.ce-pw-image img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ce-pw-heading {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  align-items: center;
}

.ce-pw-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-right: 4px;
}

.ce-grid-size-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.ce-grid-size-input {
  width: 44px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  /* iOS Safari: font-size >= 16px prevents auto-zoom on focus */
  font-size: 1rem;
  padding: 3px 6px;
  text-align: center;
}

/* Canvas preset selector */
.ce-preset-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  /* iOS Safari: font-size >= 16px prevents auto-zoom on focus */
  font-size: 1rem;
  padding: 3px 6px;
  cursor: pointer;
}

/* Standalone widget palette items */
.ce-palette-standalone {
  border-style: dashed;
  opacity: 0.85;
}
.ce-palette-standalone:hover { opacity: 1; }

/* Style panel */
.ce-style-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ce-color-input {
  width: 100%;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  padding: 2px;
}

/* Public widget: button */
.cw-button { display: flex; align-items: center; justify-content: center; }
.cw-btn-link, .cw-btn-text {
  display: inline-block;
  padding: 8px 16px;
  background: var(--primary, #14b8a6);
  color: var(--surface, #191919);
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  border-radius: var(--card-radius, 0);
  cursor: pointer;
  width: 100%;
}
.cw-btn-link:hover { opacity: 0.85; }

/* Public widget: divider */
.cw-divider { display: flex; align-items: center; }

/* Public widget: static_text */
.cw-static_text { font-family: var(--font-sans, sans-serif); font-size: 13px; }

/* Editor preview: button */
.ce-pw-button { display: flex; align-items: center; justify-content: center; background: var(--primary, #14b8a6); color: var(--bg); font-weight: 600; }
.ce-pw-divider { display: flex; align-items: center; }
.ce-pw-static_text { font-size: 12px; color: var(--text-muted); }

.ce-picker-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.ce-picker-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.ce-z-input {
  width: 50px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  /* iOS Safari: font-size >= 16px prevents auto-zoom on focus */
  font-size: 1rem;
  padding: 4px 6px;
}

.ce-pw-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.ce-pw-price {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
  align-items: center;
}

.ce-pw-badge {
  align-self: flex-start;
  padding: 2px 8px;
  background: var(--primary-10);
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
}

.ce-pw-button {
  padding: 4px 6px;
  align-items: center;
  justify-content: center;
}

.ce-pw-button span {
  display: inline-block;
  padding: 4px 12px;
  background: var(--primary);
  color: #000;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

/* ============================================
   Connection status badge (PWA offline)
   ============================================ */

/* Autocomplete dropdown */
.ac-dropdown {
  position: fixed;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.ac-item {
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}
.ac-item:hover { background: var(--surface2); color: var(--primary); }

.btn-install {
  background: var(--primary) !important;
  color: #000 !important;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.conn-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.conn-badge[data-state="offline"] .conn-dot { background: #ef4444; }
.conn-badge[data-state="offline"] .conn-text { color: #ef4444; }

.conn-badge[data-state="syncing"] .conn-dot {
  background: #f59e0b;
  animation: conn-pulse 1s infinite;
}
.conn-badge[data-state="syncing"] .conn-text { color: #f59e0b; }

.conn-badge[data-state="synced"] .conn-dot { background: #22c55e; }
.conn-badge[data-state="synced"] .conn-text { color: #22c55e; }

@keyframes conn-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── JSON/XML Form Renderer ── */
.xr { display: flex; flex-direction: column; gap: 2px; font-size: 13px; line-height: 1.5; }
.xg { display: grid; gap: 1px; }
.xg-1 { grid-template-columns: 1fr; }
.xg-2 { grid-template-columns: repeat(2, 1fr); }
.xg-3 { grid-template-columns: repeat(3, 1fr); }
.xf { display: flex; flex-direction: column; gap: 1px; padding: 5px 10px; border-radius: 4px; transition: background .15s; min-width: 0; }
.xf:hover { background: rgba(20, 184, 166, 0.08); }
.xf-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.3px; line-height: 1.3; user-select: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xf-value { color: var(--text); word-break: break-word; }
.xs { margin-top: 4px; }
.xs:first-child { margin-top: 0; }
.xs-header { font-size: 11px; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: 0.8px; padding: 6px 10px 3px; border-bottom: 1px dashed rgba(20, 184, 166, 0.3); margin-bottom: 2px; }
.xs-body { display: flex; flex-direction: column; gap: 2px; }
.xs-d1 { padding-left: 8px; }
.xs-d2 { padding-left: 16px; }
.xs-d1 > .xs-header { opacity: 0.8; font-size: 10px; }
.xs-d2 > .xs-header { opacity: 0.6; font-size: 10px; }
.xv-money .xf-value { font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; color: #34d399; }
.xv-int .xf-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.xv-date .xf-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: #94a3b8; }
.xv-code .xf-value { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.5px; color: #22d3ee; }
.xv-status .xf-value { font-weight: 600; color: var(--primary); }
.xv-name .xf-value { font-weight: 500; color: #f8fafc; }
.xv-email .xf-value { font-family: var(--font-mono); font-size: 12px; }
.xv-url .xf-value { font-size: 12px; word-break: break-all; }
.xv-link { color: #3b82f6; text-decoration: none; border-bottom: 1px dotted rgba(59, 130, 246, 0.4); transition: all .15s; }
.xv-link:hover { color: var(--primary); border-bottom-color: var(--primary); }
.xv-bool-true { display: inline-block; padding: 1px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.25); }
.xv-bool-false { display: inline-block; padding: 1px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; background: rgba(239, 68, 68, 0.1); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.2); }
.xv-long .xf-value { font-size: 12px; line-height: 1.6; color: #94a3b8; }
@media (max-width: 500px) { .xg-2, .xg-3 { grid-template-columns: 1fr; } }

/* ── Flow split modal ── */
.flow-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; height: 70vh; background: var(--border); }
.flow-panel { background: var(--bg); overflow: auto; min-height: 200px; }
.flow-loading { padding: 2rem; text-align: center; color: var(--text-muted); }
@media (max-width: 768px) { .flow-split { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; } }

/* Flow config */
.flow-builder { background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; padding: 12px; }
.flow-steps { min-height: 32px; margin-bottom: 8px; }
.flow-step-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; margin-bottom: 4px; font-size: 12px; }
.flow-step-num { width: 18px; height: 18px; border-radius: 50%; background: var(--primary-20); color: var(--primary); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.flow-add-step { display: flex; flex-wrap: wrap; gap: 4px; }
.flow-add-step .btn { font-size: 10px; padding: 2px 8px; }
/* iOS Safari: form controls need font-size >= 16px to prevent auto-zoom on focus */
.flow-col-select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 3px; font-size: 1rem; padding: 1px 4px; }
.ctx-menu-flow { font-weight: 600; color: var(--primary); }

/* Flow action bar inside form */
.flow-action-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 10px; border-top: 1px solid var(--border); margin-top: 8px; position: sticky; bottom: 0; background: var(--bg); }
.flow-action-btn { font-size: 11px; }
.flow-action-done { color: var(--primary); border-color: var(--primary); }

/* AI CLI panel */
.ai-cli { border-top: 1px solid var(--border); margin-top: 8px; padding: 8px 0 0; }
.ai-cli-messages { max-height: 200px; overflow-y: auto; padding: 0 10px 6px; font-size: 12px; line-height: 1.5; }
.ai-msg { padding: 4px 8px; margin: 3px 0; border-radius: 4px; max-width: 90%; word-break: break-word; }
.ai-msg-user { background: var(--primary-20); color: var(--text); margin-left: auto; text-align: right; }
.ai-msg-assistant { background: var(--bg-secondary, var(--bg)); color: var(--text-secondary, var(--text)); }
.ai-msg-assistant code { background: rgba(255,255,255,.08); padding: 1px 4px; border-radius: 2px; font-family: var(--mono); font-size: 11px; }
.ai-msg-assistant .ai-code { background: rgba(255,255,255,.06); padding: 6px 8px; border-radius: 3px; font-family: var(--mono); font-size: 11px; margin: 4px 0; white-space: pre-wrap; }
.ai-cli-input-row { display: flex; gap: 4px; padding: 6px 10px; }
/* iOS Safari: form controls need font-size >= 16px to prevent auto-zoom on focus */
.ai-cli-input { flex: 1; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 6px 10px; font-size: 1rem; font-family: var(--mono); outline: none; }
.ai-cli-input:focus { border-color: var(--primary); }
.ai-cli-send { padding: 6px 12px; font-size: 13px; font-weight: 700; }
.ai-action-btn { margin: 4px 2px; }

/* Hook config */
.hook-config { font-size: 12px; }
.hook-item { border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; margin: 6px 0; }
.hook-item.hook-disabled { opacity: 0.5; }
.hook-item-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hook-event { background: var(--primary-20); color: var(--primary); font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 3px; text-transform: uppercase; }
.hook-desc { flex: 1; font-weight: 500; }
.hook-item-actions { display: flex; gap: 4px; }
.hook-condition { font-size: 11px; color: var(--text-secondary); margin-top: 4px; font-family: var(--mono); }
.hook-action { font-size: 11px; font-family: var(--mono); margin-top: 2px; }
.hook-writeback { font-size: 10px; color: var(--primary); margin-top: 2px; font-family: var(--mono); }
.hook-ai-area { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 8px; }
.hook-form { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.hook-form label { font-weight: 600; margin-top: 6px; font-size: 11px; }
/* iOS Safari: form controls need font-size >= 16px to prevent auto-zoom on focus */
.hook-form input, .hook-form select, .hook-form textarea { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 3px; padding: 5px 8px; font-size: 1rem; font-family: var(--mono); }
.hook-log { font-size: 12px; }
.hook-log-entry { border: 1px solid var(--border); border-radius: 3px; padding: 6px 8px; margin: 4px 0; }
/* ── Invoice widgets (card view) ── */
.cw-invoice_header { display:flex; align-items:center; justify-content:center; }
.cw-party_block { display:flex; }
.cw-items_table { overflow-x:auto; }
.cw-items_table table { border-spacing:0; }
.cw-items_table th { font-family:var(--font-mono,monospace); }
.cw-totals { display:flex; align-items:flex-end; justify-content:flex-end; }
.cw-label_value { display:flex; align-items:center; gap:4px; font-size:13px; }

/* ── Invoice widgets (editor preview) ── */
.ce-pw-invoice_header { display:flex; align-items:center; justify-content:center; }
.ce-pw-party_block { display:flex; font-size:12px; }
.ce-pw-items_table { overflow:hidden; font-size:11px; }
.ce-pw-totals { display:flex; align-items:flex-end; justify-content:flex-end; font-size:12px; }
.ce-pw-label_value { display:flex; align-items:center; gap:4px; font-size:12px; }

/* ── Action buttons on card/catalog ── */
.cw-action-bar { display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
.cw-action-btn {
  display:inline-flex; align-items:center; gap:4px;
  padding:6px 14px; border:1px solid var(--border,#333);
  background:var(--surface,#1a1a1a); color:var(--text,#eee);
  font-family:var(--font-mono,monospace); font-size:12px; font-weight:600;
  text-transform:uppercase; letter-spacing:1px; cursor:pointer;
}
.cw-action-btn:hover { background:var(--primary,#14b8a6); color:#000; }
.cw-action-btn:disabled { opacity:0.5; cursor:wait; }
.cw-action-btn.done { border-color:var(--primary); }

/* Server-rendered config dialogs */
.config-dialog { font-family: var(--mono); }
.config-dialog h3 { font-size: 14px; margin-bottom: 12px; }
.config-dialog h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin: 12px 0 6px; display: flex; align-items: center; gap: 8px; }
.config-section { margin-bottom: 16px; }
.config-empty { font-size: 11px; color: var(--text-muted); padding: 8px 0; }
.config-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 11px; }
.config-name { font-weight: 600; }
.config-url { font-size: 10px; color: var(--text-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.config-del { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 14px; padding: 2px 6px; margin-left: auto; }
.config-del:hover { background: rgba(255,61,90,0.1); }
.config-search { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); font: 11px var(--mono); padding: 6px 8px; margin-bottom: 8px; }
.config-registry { max-height: 250px; overflow-y: auto; }
.config-reg-item { display: flex; align-items: center; gap: 6px; padding: 4px 0; font-size: 10px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.config-method { font-size: 9px; font-weight: 600; padding: 1px 4px; min-width: 36px; text-align: center; }
.config-method-get { color: #4caf50; } .config-method-post { color: #ff9800; }
.config-method-put { color: #2196f3; } .config-method-delete { color: #f44336; }
.config-service { color: var(--text-muted); }
.config-add { background: var(--primary); color: #000; border: none; font: 10px var(--mono); font-weight: 600; padding: 2px 8px; cursor: pointer; margin-left: auto; }
.config-add-btn { background: none; border: 1px dashed var(--border); color: var(--text-muted); font: 11px var(--mono); padding: 6px 12px; cursor: pointer; width: 100%; margin-top: 8px; }
.config-add-btn:hover { border-color: var(--primary); color: var(--primary); }
.config-rescan { background: none; border: 1px solid var(--border); color: var(--text-muted); font: 9px var(--mono); padding: 2px 6px; cursor: pointer; }
.config-event { font-size: 9px; font-weight: 600; padding: 1px 6px; background: var(--surface2); text-transform: uppercase; }

.hook-log-entry.hook-log-ok { border-left: 3px solid var(--primary); }
.hook-log-entry.hook-log-error { border-left: 3px solid var(--danger); }
.hook-log-header { display: flex; gap: 12px; font-size: 11px; font-family: var(--mono); }
.hook-log-error-msg { color: var(--danger); font-size: 11px; margin-top: 2px; }
.hook-log-resp { font-size: 10px; color: var(--text-secondary); font-family: var(--mono); margin-top: 2px; word-break: break-all; }

/* Data List Component */
.dl-wrap { width: 100%; }
.dl-placeholder { padding: 20px; text-align: center; color: var(--text-muted); border: 2px dashed var(--border); border-radius: 3px; font-size: 12px; }
.dl-error { padding: 12px; color: var(--danger); font-size: 12px; font-family: var(--font-mono); }
.dl-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }
.dl-tabs { display: flex; gap: 2px; padding: 4px 4px 0; border-bottom: 1px solid var(--border); background: var(--surface); }
.dl-tab { background: none; border: none; padding: 6px 12px; font-size: 11px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; text-transform: uppercase; letter-spacing: 0.3px; }
.dl-tab:hover { color: var(--text); }
.dl-tab-active, .dl-tab.htmx-request { color: var(--primary); border-bottom-color: var(--primary); }
.dl-items { overflow-y: auto; }
.dl-item { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s; }
.dl-item:hover { background: var(--surface-hover, rgba(255,255,255,0.03)); }
.dl-item.dl-active { background: var(--primary-bg, rgba(var(--primary-rgb, 59,130,246), 0.1)); border-left: 3px solid var(--primary); }
.dl-group-header { padding: 8px 12px 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1; }
.dl-field { font-size: 13px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-label { color: var(--text-muted); font-size: 11px; margin-right: 4px; }
.dl-raw { white-space: normal; overflow: visible; }
.dl-raw iframe { width: 100%; border: 0; min-height: 200px; background: #fff; border-radius: 2px; }

/* Explorer component — works in both light and dark themes */
.expl-panel { overflow-y: auto; color: var(--text-primary, var(--text, #1c1917)); }
.expl-error { padding: 12px; color: var(--danger); font-size: 12px; font-family: var(--font-mono); }
.expl-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }
.expl-placeholder { padding: 20px; text-align: center; color: var(--text-muted); border: 2px dashed var(--border); font-size: 12px; }
.expl-row { padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s; }
.expl-row:hover { background: var(--surface-hover, rgba(255,255,255,0.03)); }
.expl-row.htmx-request { opacity: 0.6; }
.expl-row-cols { display: flex; gap: 8px; align-items: baseline; overflow: hidden; }
.expl-cell { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expl-cell:first-child { font-weight: 600; flex: 1; }
.expl-row-line1 { display: flex; align-items: baseline; gap: 6px; }
.expl-row-line2 { font-size: 12px; color: var(--text-secondary, var(--text-muted, #78716c)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.expl-primary { font-size: 13px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; }
.expl-date { color: var(--text-secondary, var(--text-muted, #78716c)); font-family: var(--font-mono, monospace); font-size: 11px; flex-shrink: 0; }
.expl-badge { font-size: 10px; background: var(--primary); color: #fff; padding: 1px 6px; border-radius: 8px; flex-shrink: 0; }
.expl-detail-item { padding: 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.expl-detail-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.expl-detail-from { font-weight: 600; font-size: 13px; color: inherit; }
.expl-detail-date { color: var(--text-secondary, #78716c); font-family: var(--font-mono, monospace); font-size: 11px; }
.expl-detail-subject { font-size: 12px; color: var(--text-secondary, #78716c); margin-bottom: 8px; }
.expl-detail-body { width: 100%; border: 0; height: 400px; max-height: 50vh; background: #fff; border-radius: 2px; color: #1a1a1a; }
.expl-detail-text { font-size: 13px; white-space: pre-wrap; color: var(--text); background: var(--surface); padding: 12px; border-radius: 2px; }
.expl-detail-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.expl-detail-att { font-size: 11px; padding: 3px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 2px; color: var(--text-muted); }
.expl-search { padding: 6px 8px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 2; }
/* iOS Safari: form controls need font-size >= 16px to prevent auto-zoom on focus */
.expl-search-input { width: 100%; padding: 5px 8px; font-size: 1rem; border: 1px solid var(--border); border-radius: 2px; background: var(--surface); color: var(--text); outline: none; font-family: var(--font-mono); }
.expl-search-input:focus { border-color: var(--primary); }

/* Inbox layout */
.pub-content:has(.inbox-layout) { max-width: none !important; padding: 0 !important; }
.inbox-layout { display: grid; grid-template-columns: 280px 1fr; height: 100vh; overflow: hidden; }
.inbox-sidebar, .inbox-detail { overflow-y: auto; min-height: 0; max-height: 100vh; }
.inbox-sidebar { border-right: 1px solid var(--border-default, var(--border, #e7e5e4)); background: var(--bg-base, var(--bg, #fafaf9)); }
.inbox-detail { background: var(--bg-elevated, var(--surface, #fff)); }
.dl-dialog-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.dl-dialog-name { font-size: 12px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-dialog-subject { font-size: 12px; color: var(--text-muted); width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-dialog-badge { font-size: 10px; background: var(--primary); color: #fff; padding: 1px 5px; border-radius: 8px; min-width: 16px; text-align: center; }
.dl-dialog-badge:empty { display: none; }
.dl-msg-item { padding: 16px; border-bottom: 1px solid var(--border); }
.dl-msg-header { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 12px; }
.dl-msg-from { font-weight: 600; }
.dl-msg-date { color: var(--text-muted); font-family: var(--font-mono); font-size: 11px; }
.dl-msg-body { font-size: 13px; line-height: 1.5; overflow: hidden; }
