:root {
  --crm-sidebar-width: 17.5rem;
  --radius-sm: 0.6rem;
  --radius-md: 0.85rem;
  --radius-lg: 1.25rem;

  --bg: #fafafa;
  --surface: #ffffff;
  --surface-muted: #f4f5f7;
  --surface-strong: #ebeef2;
  --border: #e2e4e9;
  --text-main: #09090b;
  --text-muted: #64748b;
  --accent: #10b981;
  /* Vibrant Emerald */
  --accent-contrast: #ffffff;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --brand-soft: #f1f5f9;
  --brand-500: #64748b;
  --brand-700: #0f172a;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.06);
}

.dark {
  --bg: #09090b;
  --surface: rgba(24, 24, 27, 0.6);
  --surface-muted: #18181b;
  --surface-strong: #27272a;
  --border: #27272a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #10b981;
  /* Emerald */
  --accent-contrast: #ffffff;
  --slate-500: #64748b;
  --slate-600: #94a3b8;
  --slate-700: #cbd5e1;
  --slate-800: #f1f5f9;
  --brand-soft: #1e293b;
  --brand-500: #64748b;
  --brand-700: #f8fafc;

  --shadow-sm: none;
  --shadow-md: 0 16px 40px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-main);
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(40, 40, 40, 0.08) 0, transparent 42%),
    radial-gradient(circle at 88% 4%, rgba(120, 120, 120, 0.09) 0, transparent 38%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 26%);
}

.dark body {
  background-image:
    radial-gradient(circle at 10% 6%, rgba(255, 255, 255, 0.08) 0, transparent 36%),
    radial-gradient(circle at 92% 4%, rgba(148, 148, 148, 0.12) 0, transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 24%);
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

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

input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: #1f1f1f;
}

.dark input[type="checkbox"] {
  accent-color: #e8e8e8;
}

.toggle-line {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.86rem;
  font-weight: 600;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--crm-sidebar-width) minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
  overflow: hidden;
}

.app-sidebar {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  box-shadow: var(--shadow-sm);
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.brand {
  padding: 1.05rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-logo-wrap {
  width: 2rem;
  height: 2rem;
  border-radius: 0.55rem;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #1b1b1b;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-logo-fallback {
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.brand-text {
  min-width: 0;
}

.brand h1,
.brand-text h1 {
  margin: 0;
  font-family: "Outfit", "Inter", -apple-system, sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand p,
.brand-text p {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.app-nav {
  padding: 0.8rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
}

.app-nav a {
  display: flex;
  align-items: center;
  gap: 0.62rem;
  text-decoration: none;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.58rem 0.66rem;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-nav a:hover {
  color: var(--text-main);
  background: var(--surface-muted);
  border-color: var(--border);
  transform: translateX(4px);
}

.app-nav a.active {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
}

.nav-icon {
  width: 1rem;
  text-align: center;
  font-size: 0.84rem;
  flex-shrink: 0;
}

.nav-label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-divider {
  height: 1px;
  margin: 0.32rem 0.5rem;
  background: var(--border);
}

.sidebar-footer {
  margin-top: auto;
  padding: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.user-email {
  font-size: 0.76rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.user-meta-row .user-email {
  flex: 1;
  min-width: 0;
}

.account-shortcut {
  width: 1.95rem;
  height: 1.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.account-shortcut:hover {
  background: var(--surface-strong);
  color: var(--text-main);
}

.theme-toggle,
.command-palette-trigger,
.sign-out {
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-main);
  padding: 0.54rem 0.7rem;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover,
.command-palette-trigger:hover,
.sign-out:hover {
  background: var(--surface-strong);
}

.theme-toggle-icon,
.command-palette-trigger-icon,
.signout-icon {
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.84rem;
}

.command-palette-trigger {
  justify-content: space-between;
  gap: 0.45rem;
}

.command-palette-trigger-main {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.command-palette-trigger-main span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-palette-trigger-hint {
  border: 1px solid var(--border);
  border-radius: 0.38rem;
  padding: 0.1rem 0.34rem;
  font-size: 0.66rem;
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface);
}

.app-main {
  height: 100%;
  padding: 1.75rem 2rem;
  background: color-mix(in srgb, var(--surface) 65%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  box-shadow: var(--shadow-sm);
  overflow-y: auto;
  overflow-x: hidden;
}

.app-main>.page-alert,
.app-main>.page-header,
.app-main>section {
  width: min(1280px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.app-main>.page-header {
  margin-bottom: 1rem;
}

.app-main>section {
  margin-bottom: 1rem;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}

.page-title {
  margin: 0;
  font-family: "Outfit", "Inter", -apple-system, sans-serif;
  font-size: 1.85rem;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.page-subtitle {
  margin: 0.38rem 0 0;
  font-size: 0.91rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.grid {
  display: grid;
  gap: 0.92rem;
}

.grid.cols-2,
.grid.cols-3 {
  grid-template-columns: 1fr;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  padding: 2rem;
  /* Increased from 1.25rem for more breathing room */
  position: relative;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.4), transparent 40%);
}

.dark .card::before {
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.04), transparent 36%);
}

.card h2,
.card h3,
.card h4 {
  margin: 0 0 0.75rem;
  font-family: "Outfit", "Inter", -apple-system, sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

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

.kpi {
  margin-top: 0.35rem;
  font-family: "Outfit", "Inter", -apple-system, sans-serif;
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(to right, var(--text-main), var(--text-muted));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.form-grid {
  display: grid;
  gap: 0.78rem;
}

.form-grid.cols-2 {
  grid-template-columns: 1fr;
}

.label {
  margin-bottom: 0.34rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--text-muted);
}

.input,
.select,
.textarea {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  font-size: 0.89rem;
  line-height: 1.42;
  padding: 0.58rem 0.7rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.input::placeholder,
.textarea::placeholder {
  color: #8b8b8b;
}

.dark .input::placeholder,
.dark .textarea::placeholder {
  color: #86868c;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

.dark .input,
.dark .select,
.dark .textarea {
  background: var(--surface-muted);
}

.dark .input:focus,
.dark .select:focus,
.dark .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.25);
}

/* Force grayscale controls even if older theme CSS is still loaded. */
.app-main .input,
.app-main .select,
.app-main .textarea,
.login-card .input,
.login-card .select,
.login-card .textarea {
  background: var(--surface-muted) !important;
  border-color: var(--border) !important;
  color: var(--text-main) !important;
}

.dark .app-main .input,
.dark .app-main .select,
.dark .app-main .textarea,
.dark .login-card .input,
.dark .login-card .select,
.dark .login-card .textarea {
  background: var(--surface-muted) !important;
  border-color: var(--border) !important;
  color: var(--text-main) !important;
}

.app-main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not(.input),
.app-main select:not(.select),
.app-main textarea:not(.textarea) {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-main);
  font-size: 0.89rem;
  line-height: 1.42;
  padding: 0.58rem 0.7rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.app-main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not(.input):focus,
.app-main select:not(.select):focus,
.app-main textarea:not(.textarea):focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

.dark .app-main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not(.input):focus,
.dark .app-main select:not(.select):focus,
.dark .app-main textarea:not(.textarea):focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.25);
}

.app-main .input:focus,
.app-main .select:focus,
.app-main .textarea:focus,
.login-card .input:focus,
.login-card .select:focus,
.login-card .textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15) !important;
  background: var(--surface) !important;
}

.dark .app-main .input:focus,
.dark .app-main .select:focus,
.dark .app-main .textarea:focus,
.dark .login-card .input:focus,
.dark .login-card .select:focus,
.dark .login-card .textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.25) !important;
}

.app-main input:-webkit-autofill,
.app-main input:-webkit-autofill:hover,
.app-main input:-webkit-autofill:focus,
.app-main textarea:-webkit-autofill,
.app-main textarea:-webkit-autofill:hover,
.app-main textarea:-webkit-autofill:focus,
.login-card input:-webkit-autofill,
.login-card input:-webkit-autofill:hover,
.login-card input:-webkit-autofill:focus,
.login-card textarea:-webkit-autofill,
.login-card textarea:-webkit-autofill:hover,
.login-card textarea:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-main) !important;
  box-shadow: 0 0 0 1000px var(--surface-muted) inset !important;
  transition: background-color 99999s ease-out 0s !important;
}

.textarea {
  min-height: 120px;
  resize: vertical;
}

.input[type="file"] {
  padding: 0.35rem 0.45rem;
}

.app-main input[type="file"]:not(.input) {
  padding: 0.35rem 0.45rem;
}

.input[type="file"]::file-selector-button {
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--surface-muted);
  color: var(--text-main);
  padding: 0.35rem 0.6rem;
  margin-right: 0.5rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}

.app-main input[type="file"]:not(.input)::file-selector-button {
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--surface-muted);
  color: var(--text-main);
  padding: 0.35rem 0.6rem;
  margin-right: 0.5rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}

.button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-contrast);
  font-family: "Inter", -apple-system, sans-serif;
  font-size: 0.88rem;
  line-height: 1.25;
  font-weight: 600;
  padding: 0.6rem 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
  /* matches emerald accent */
}

.button:visited {
  text-decoration: none;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  filter: brightness(1.05);
}

.button:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(16, 185, 129, 0.2);
}

.button.alt {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.button.alt:hover {
  background: var(--surface-muted);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.button.warn {
  border-color: #8c8c8c;
  background: #d7d7d7;
  color: #161616;
}

.button.warn:hover {
  background: #cfcfcf;
}

.button.danger {
  border-color: #636363;
  background: #bdbdbd;
  color: #111111;
}

.button.danger:hover {
  background: #b2b2b2;
}

.dark .button.warn,
.dark .button.danger {
  color: #121212;
}

.button:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.64rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.row.wrap {
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0.23rem 0.52rem;
  font-size: 0.72rem;
  line-height: 1.2;
  font-weight: 700;
}

.badge.ok {
  color: var(--text-main);
  background: var(--surface-muted);
}

.badge.pending {
  color: var(--text-main);
  background: var(--surface-strong);
}

.badge.no {
  color: var(--text-main);
  background: transparent;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.58rem;
  max-height: 500px;
  overflow: auto;
  padding-right: 0.1rem;
}

.item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  padding: 0.72rem;
  box-shadow: var(--shadow-sm);
}

.item h4 {
  margin: 0 0 0.4rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.table th,
.table td {
  padding: 0.63rem 0.56rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.table tbody tr:hover {
  background: var(--surface-muted);
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-weight: 700;
}

.actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.58rem;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.77rem;
  font-weight: 600;
  padding: 0.38rem 0.56rem;
  transition: background-color 0.15s ease;
}

.action-link:hover {
  background: var(--surface-strong);
}

.inline-note {
  margin-top: 0.45rem;
  font-size: 0.79rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.page-alert {
  margin-bottom: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  padding: 0.62rem 0.74rem;
  font-size: 0.86rem;
}

.page-alert.info {
  background: var(--surface-muted);
}

.page-alert.error {
  background: var(--surface-strong);
}

.command-palette {
  position: fixed;
  inset: 0;
  z-index: 10500;
}

.command-palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.56);
}

.command-palette-panel {
  position: relative;
  width: min(740px, calc(100vw - 2rem));
  max-height: min(78vh, 640px);
  margin: max(18px, 8vh) auto 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.command-palette-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-bottom: 1px solid var(--border);
  padding: 0.78rem 0.88rem;
}

.command-palette-title {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.command-palette-search-icon {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.command-palette-input {
  border: 0;
  background: transparent;
  color: var(--text-main);
  font-size: 0.95rem;
  line-height: 1.3;
  width: 100%;
}

.command-palette-input:focus {
  outline: none;
}

.command-palette-close-hint {
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 0.7rem;
  line-height: 1;
  font-weight: 600;
  padding: 0.28rem 0.42rem;
}

.command-palette-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.55rem 0.88rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.command-palette-hint,
.command-palette-count {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.command-palette-list {
  overflow: auto;
  padding: 0.36rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.command-palette-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.56rem 0.64rem;
  text-align: left;
  cursor: pointer;
}

.command-palette-item:hover {
  background: var(--surface-muted);
  border-color: var(--border);
}

.command-palette-item.active {
  background: var(--surface-strong);
  border-color: var(--border);
}

.command-palette-item-main {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.58rem;
}

.command-palette-item-icon {
  width: 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.command-palette-item-label {
  min-width: 0;
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-palette-item-group {
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.18rem 0.46rem;
  font-size: 0.67rem;
  color: var(--text-muted);
  background: var(--surface);
}

.command-palette-empty {
  margin: 0.34rem;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 1rem 0.82rem;
  text-align: center;
}

pre {
  margin: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-main);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.81rem;
  line-height: 1.45;
  padding: 0.72rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

details summary {
  user-select: none;
}

.toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.56rem 0.72rem;
  font-size: 0.82rem;
  box-shadow: var(--shadow-md);
}

.toast.success,
.toast.error {
  border-color: var(--border);
}

.record-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
}

.ai-settings-modal {
  position: fixed;
  inset: 0;
  z-index: 10020;
}

.ai-settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  animation: aiSettingsFade 180ms ease-out;
}

.ai-settings-panel {
  position: relative;
  width: min(760px, calc(100vw - 2rem));
  max-height: calc(100vh - 2.4rem);
  margin: 1.2rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: aiSettingsSlide 220ms ease-out;
}

.ai-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.85rem 0.95rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.ai-settings-body {
  padding: 0.85rem 0.95rem 1rem;
  overflow: auto;
  display: grid;
  gap: 0.86rem;
}

.ai-settings-body .toggle-line {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  padding: 0.5rem 0.6rem;
}

.ai-settings-body .select,
.ai-settings-body .input,
.ai-settings-body .textarea {
  background: var(--surface-muted);
}

.ai-settings-body .textarea {
  min-height: 110px;
}

.integration-form {
  gap: 0.72rem;
}

.integration-field {
  display: grid;
  gap: 0.34rem;
}

.integration-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0.64rem;
}

.ai-message-body {
  color: var(--text-main);
  font-size: 0.86rem;
  line-height: 1.58;
  word-break: break-word;
}

.ai-message-body .ai-heading {
  margin: 0.2rem 0 0.5rem;
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
  font-size: 0.95rem;
  line-height: 1.28;
  letter-spacing: 0.01em;
}

.ai-message-body .ai-paragraph {
  margin: 0 0 0.58rem;
  white-space: pre-wrap;
}

.ai-message-body .ai-paragraph:last-child {
  margin-bottom: 0;
}

.ai-message-body .ai-list {
  margin: 0 0 0.58rem 1rem;
  padding: 0;
  display: grid;
  gap: 0.24rem;
}

.ai-message-body .ai-code {
  margin: 0.16rem 0 0.58rem;
  overflow-x: auto;
  background: var(--surface);
}

.ai-message-body .ai-quote {
  margin: 0 0 0.58rem;
  border-left: 2px solid var(--border);
  padding: 0.12rem 0 0.12rem 0.64rem;
  color: var(--text-muted);
}

.ai-message-body a {
  color: var(--brand-500);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-message-body code {
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  background: var(--surface-muted);
  padding: 0.08rem 0.32rem;
  font-size: 0.76rem;
}

.ai-message-body pre code {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 0.8rem;
}

.greg-dashboard-shell {
  display: grid;
  gap: 0.72rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.greg-dashboard-shell .toggle-line {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  padding: 0.44rem 0.56rem;
}

.greg-dashboard-shell textarea {
  min-height: 94px;
}

.ai-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
}

.ai-typing-indicator span {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--text-muted);
  animation: aiTypingPulse 1s infinite ease-in-out;
}

.ai-typing-indicator span:nth-child(2) {
  animation-delay: 0.14s;
}

.ai-typing-indicator span:nth-child(3) {
  animation-delay: 0.28s;
}

.ai-typing-indicato.grid>.card:nth-child(5) {
  animation-delay: 0.3s;
}

.grid>.card:nth-child(6) {
  animation-delay: 0.35s;
}

/* Custom scrollbars for the Island layout modules */
.app-sidebar::-webkit-scrollbar,
.app-main::-webkit-scrollbar {
  width: 8px;
}

.app-sidebar::-webkit-scrollbar-track,
.app-main::-webkit-scrollbar-track {
  background: transparent;
  margin: 1rem 0;
}

.app-sidebar::-webkit-scrollbar-thumb,
.app-main::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.app-sidebar::-webkit-scrollbar-thumb:hover,
.app-main::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Phase 3: Layout Decluttering */
.nav-header {
  margin: 1rem 0.5rem 0.15rem;
  font-family: "Outfit", "Inter", -apple-system, sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  opacity: 0.7;
}

.ask-greg-collapsed {
  display: flex !important;
  align-items: center !important;
  gap: 1rem !important;
  padding: 0.75rem 1rem !important;
  cursor: pointer;
}

.ask-greg-collapsed #dashboardGregMessages,
.ask-greg-collapsed #dashboardGregPrompts,
.ask-greg-collapsed .row.wrap,
.ask-greg-collapsed .actions,
.ask-greg-collapsed .muted {
  display: none !important;
}

.ask-greg-collapsed textarea {
  flex: 1;
  min-height: 0 !important;
  height: 2.5rem !important;
  resize: none;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0.5rem 0 !important;
  line-height: 1.5;
}

.ask-greg-collapsed:hover textarea {
  border: none !important;
  box-shadow: none !important;
}

.ask-greg-collapsed::before {
  content: "✨";
  font-size: 1.25rem;
  opacity: 0.8;
}

@keyframes aiTypingPulse {

  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes aiSettingsFade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes aiSettingsSlide {
  from {
    transform: translateY(10px) scale(0.985);
    opacity: 0;
  }

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

.record-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
}

.record-modal-panel {
  position: relative;
  width: min(680px, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  margin: 1.5rem auto;
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.record-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
}

.record-modal-title {
  margin: 0;
  font-family: "Space Grotesk", "Plus Jakarta Sans", "Segoe UI", sans-serif;
  font-size: 1.08rem;
  line-height: 1.2;
}

.record-modal-body {
  overflow: auto;
  padding: 0.75rem 1rem 1rem;
  display: grid;
  gap: 0.45rem;
}

.record-field {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  padding: 0.58rem 0.64rem;
}

.record-field-label {
  font-size: 0.69rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.22rem;
}

.record-field-value {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: #b0b0b0;
  border-radius: 99px;
}

.dark ::-webkit-scrollbar-thumb {
  background: #4f4f54;
}

@media (min-width: 900px) {
  .form-grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 980px) {
  .grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 1200px) {
  .app-main {
    padding: 1.2rem;
  }

  .page-title {
    font-size: 1.56rem;
  }
}

@media (max-width: 1024px) {
  .app-shell {
    display: block;
  }

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

  .app-nav {
    flex-direction: row;
    flex-wrap: wrap;
    overflow: visible;
  }

  .app-nav a {
    flex: 1 1 calc(50% - 0.35rem);
    min-width: 12rem;
  }

  .app-main {
    padding: 1rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .brand {
    padding: 0.9rem 0.8rem;
  }

  .sidebar-footer {
    padding: 0.78rem;
  }

  .app-nav a {
    flex-basis: 100%;
    min-width: 0;
  }

  .card {
    padding: 0.82rem;
  }

  .page-title {
    font-size: 1.4rem;
  }

  .page-subtitle {
    font-size: 0.86rem;
  }

  .toasts {
    left: 0.8rem;
    right: 0.8rem;
    bottom: 0.8rem;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }

  .record-modal-panel {
    width: calc(100vw - 1rem);
    margin: 0.5rem auto;
    max-height: calc(100vh - 1rem);
  }

  .ai-settings-panel {
    width: calc(100vw - 1rem);
    margin: 0.5rem auto;
    max-height: calc(100vh - 1rem);
  }

  .command-palette-panel {
    width: calc(100vw - 1rem);
    margin-top: 0.5rem;
    max-height: calc(100vh - 1rem);
  }

  .command-palette-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.36rem;
  }

  .command-palette-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.34rem;
  }
}