:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --accent: #0c7fa9;
  --accent-strong: #055c82;
  --muted: #5c6b7a;
  --text: #2f3a45;
  --border: #cdd7e2;
  --border-strong: #b8c5d3;
  --nav-bg: #e8f2ff;
  --nav-border: #c9d8f0;
  --sidebar: #dceff7;
  --sidebar-border: #b9d7e6;
  --shadow: 0 10px 24px rgba(24, 72, 105, 0.14);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Tahoma', 'Segoe UI', sans-serif;
  background: linear-gradient(180deg, #f9fbfe 0%, #eef3f7 100%);
  color: var(--text);
}

.agent-page {
  font-family: Arial, sans-serif;
  font-size: 12px;
}

.nav--collapsed a:not([data-page="agent"]) {
  display: none;
}

.nav--collapsed .nav__group {
  display: none;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(180deg, #fefefe 0%, #eff3f7 100%);
  border-bottom: 1px solid var(--border-strong);
  box-shadow: 0 2px 6px rgba(21, 60, 90, 0.08);
}

.topbar__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
}

.brand__logo {
  height: 32px;
  width: auto;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(12, 127, 169, 0.15);
}

.brand__text {
  letter-spacing: -0.1px;
}

.brand__tag {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 10px;
  background: #f2f7fb;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.topbar__search {
  flex: 1;
  max-width: 420px;
}

.topbar__search input {
  width: 100%;
  padding: 9px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.tabbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
}

.tabbar__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tabbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #2f5680;
  font-weight: 600;
}

.tabbar__crumb {
  padding: 10px 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav a,
.nav__parent {
  padding: 10px 14px;
  border: none;
  background: #f6f8fb;
  color: #1f2a3d;
  border-radius: 12px;
  text-decoration: none;
  text-transform: none;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.nav a:hover,
.nav__parent:hover {
  background: #e6efff;
  box-shadow: 0 8px 24px rgba(0, 95, 204, 0.08);
}

.nav a.is-active,
.nav__parent.is-active {
  background: linear-gradient(135deg, #2563eb 0%, #5b8def 100%);
  color: #fff;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.25);
}

.nav__group {
  position: relative;
}

.nav__parent {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.submenu {
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  min-width: 180px;
  padding: 10px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.08);
  z-index: 20;
  display: none;
  flex-direction: column;
  gap: 4px;
}

.submenu a {
  display: block;
  border-radius: 10px;
  padding: 9px 12px;
  color: #1f2a3d;
  font-weight: 600;
}

.submenu a:hover,
.submenu a.is-active {
  background: #e6efff;
}

.nav__group:hover .submenu,
.nav__group:focus-within .submenu,
.nav__group.is-open .submenu {
  display: flex;
}

.login-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-form input {
  max-width: 160px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hidden {
  display: none;
}

.unauth .topbar,
.unauth .tabbar {
  display: none;
}

.auth-gate {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
}


.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  cursor: pointer;
}

.shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 18px 36px;
  display: block;
}

.unauth .shell {
  display: none;
}

.unauth .auth-gate {
  display: flex;
}

.unauth.agent-public .shell {
  display: block;
}

.unauth.agent-public .auth-gate {
  display: none;
}

.unauth.agent-public.auth-prompt .shell {
  display: none;
}

.unauth.agent-public.auth-prompt .auth-gate {
  display: flex;
}

.shell__main {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.hero {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px 20px 16px;
  box-shadow: var(--shadow);
}

.hero--compact {
  padding: 14px 18px;
}

.hero__content {
  max-width: 100%;
}

.hero h1 {
  font-size: 1.6rem;
  color: var(--accent-strong);
  letter-spacing: -0.2px;
}

.hero .lede {
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-size: 0.82rem;
  color: #856404;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  margin-right: 8px;
  margin-top: 12px;
  border-radius: 12px;
  background: rgba(12, 127, 169, 0.12);
  color: var(--text);
  border: 1px solid rgba(12, 127, 169, 0.2);
}

.badge--ghost {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--border);
}

.hero--compact {
  display: none;
}

.layout {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 14px;
}

.layout--agent {
  grid-template-columns: minmax(220px, 1fr) minmax(480px, 2.2fr) minmax(240px, 1fr);
  align-items: stretch;
}

.card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.agent-pane {
  background: linear-gradient(180deg, #f4f9ff, #eef5ff);
  border-color: #c5daee;
  position: relative;
}

.agent-pane::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, #7db7e4, #5aa6d6);
  border-radius: 6px 6px 0 0;
}

.agent-pane--center {
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.agent-center-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  flex: 1;
}

.agent-log-box {
  flex: 0 1 50%;
  height: 50%;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #c6d9ef;
  background: #ffffff;
  overflow-y: auto;
}

.agent-log-box .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.agent-log-box .button {
  padding: 7px 10px;
  font-size: 0.9rem;
}

.agent-table .row {
  margin: 0;
  border-radius: 0;
  border: 0;
  padding: 10px 12px;
}

.agent-table .row:nth-child(odd) {
  background: #eaf4ff;
}

.agent-table .row:nth-child(even) {
  background: #ffffff;
}

.agent-table .row + .row {
  border-top: 1px solid #d8e7f6;
}

.agent-prompt {
  margin-top: 0;
}

.agent-prompt-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.agent-prompt-row textarea {
  flex: 1;
  width: 100%;
}

.agent-prompt {
  width: 100%;
}

.agent-go {
  align-self: flex-end;
  height: fit-content;
  min-width: 74px;
}

.agent-filters {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #c5daee;
  border-radius: 6px;
  background: #f7fbff;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
}

.agent-help {
  padding: 10px;
  border-left: 3px solid #7db7e4;
  background: #f7fbff;
  border-radius: 6px;
}

.agent-quick {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid #c5daee;
  border-radius: 6px;
  background: #f7fbff;
  max-height: 420px;
  overflow: auto;
}

.agent-quick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.agent-pane .card__header {
  background: #e1efff;
  border-bottom-color: #c5daee;
}

.card__header {
  margin: -16px -16px 12px;
  padding: 12px 16px;
  background: #e7f1ff;
  border-bottom: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stack {
  display: grid;
}

.stack--gap {
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

input,
textarea,
select {
  padding: 9px 10px;
  border-radius: 4px;
  border: 1px solid #bdc9d6;
  background: #fff;
  color: var(--text);
  font-size: 1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(12, 127, 169, 0.15);
}

.button {
  border: 1px solid #0a6585;
  background: linear-gradient(180deg, #0f8ab3, #0b6f93);
  color: #fff;
  padding: 9px 12px;
  display: inline-block;
  border-radius: 4px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  box-shadow: 0 4px 10px rgba(12, 127, 169, 0.18);
}

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

.button--ghost {
  background: #f5f8fb;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.button--small {
  padding: 7px 10px;
  font-size: 0.9rem;
  box-shadow: none;
}

.button--inline {
  padding: 4px 8px;
  font-size: 0.8rem;
  line-height: 1;
}

.field__label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.agent-suggestions {
  margin-top: 8px;
}

.agent-suggestions__list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.agent-suggestion {
  border: 1px solid var(--border);
  background: #f5f8fb;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}

.agent-suggestion:hover {
  transform: translateY(-1px);
}

.table {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.row:last-child {
  border-bottom: none;
}

.row--clickable {
  cursor: pointer;
}

.row--active {
  background: rgba(12, 127, 169, 0.08);
  border-left: 3px solid var(--accent);
}

.row--item {
  align-items: flex-start;
}

.row__meta {
  display: grid;
  justify-items: end;
  gap: 2px;
  text-align: right;
}

.price,
.total {
  font-weight: 700;
}

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

.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.builder {
  display: grid;
  grid-template-columns: 1.2fr 0.5fr 0.6fr;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f5f8fb;
}

#add-item {
  width: 100%;
  align-self: stretch;
  justify-self: stretch;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-weight: 600;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  margin-top: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #e8f3ff;
}

.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.ai-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f5f8fb;
  color: var(--text);
  white-space: pre-wrap;
}

.ai-box.hidden {
  display: none;
}

.footer {
  text-align: center;
  color: var(--muted);
  padding: 16px;
  font-size: 0.9rem;
  background: #e8f2ff;
  border-top: 1px solid var(--nav-border);
}

@media (max-width: 960px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .layout--agent {
    grid-template-columns: 1fr;
  }

  .agent-pane--center {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .builder {
    grid-template-columns: 1fr;
  }

  .row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .row__meta {
    justify-items: start;
    text-align: left;
  }
}
