:root {
  --ink: #10243f;
  --muted: #65748b;
  --blue: #315be8;
  --blue-soft: #eaf0ff;
  --green: #18a96b;
  --red: #e64a5f;
  --amber: #d99418;
  --line: #dce4f2;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --shadow: 0 16px 40px rgba(16, 36, 63, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 360px;
  gap: 16px;
  padding: 18px;
  transition: grid-template-columns .18s ease;
}

.app-shell.chat-collapsed {
  grid-template-columns: 230px minmax(0, 1fr) 76px;
}

.sidebar,
.assistant-panel,
.panel,
.kpi,
.finance-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  padding: 16px;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  border-radius: 8px;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

.menu {
  display: grid;
  align-content: start;
  gap: 8px;
  margin-top: 18px;
}

.menu-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  border-radius: 8px;
  padding: 12px;
  font-weight: 850;
}

.menu-item.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.sidebar-note {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.sidebar-note strong {
  color: var(--ink);
}

.workspace {
  display: grid;
  gap: 16px;
  align-content: start;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: .75rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.9rem;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.24rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search {
  width: min(460px, 36vw);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 13px;
  font-weight: 900;
}

.btn.primary {
  background: var(--blue);
  color: #fff;
}

.btn.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.danger {
  background: var(--red);
  color: #fff;
}

.kpi-grid,
.finance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi,
.finance-card {
  padding: 15px;
}

.kpi span,
.finance-card span {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  font-size: .76rem;
  font-weight: 900;
}

.kpi strong,
.finance-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
}

.kpi.good strong { color: var(--green); }
.kpi.warning strong { color: var(--amber); }
.kpi.danger strong { color: var(--red); }

.view {
  display: none;
}

.view.active {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.panel {
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 650px;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: .75rem;
  text-transform: uppercase;
}

td input,
td select,
.expense-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fff;
}

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

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: .76rem;
  font-weight: 900;
}

.pill.ok {
  background: #dcfce7;
  color: #166534;
}

.pill.warn {
  background: #fff2cc;
  color: #875600;
}

.pill.bad {
  background: #ffe4e6;
  color: #9f1239;
}

.expense-form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}

.expense-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 850;
}

.assistant-panel {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  padding: 0;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 0;
  transition: padding .18s ease;
  overflow: hidden;
}

.assistant-panel.collapsed {
  padding: 12px;
  grid-template-rows: auto;
  align-content: start;
}

.assistant-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px;
  background: linear-gradient(135deg, #ffffff 0%, #eef4ff 100%);
  border-bottom: 1px solid var(--line);
}

.assistant-head p {
  color: var(--muted);
  margin-bottom: 0;
  line-height: 1.35;
  font-size: .9rem;
}

.assistant-head h2 {
  margin-bottom: 3px;
}

.assistant-badge {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: .7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.collapse-button {
  min-width: 82px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  padding: 0 10px;
  font-size: .82rem;
  font-weight: 900;
}

.assistant-panel.collapsed .assistant-head {
  display: grid;
  justify-items: center;
}

.assistant-panel.collapsed .assistant-head div,
.assistant-panel.collapsed .chat-messages,
.assistant-panel.collapsed .quick-actions,
.assistant-panel.collapsed .chat-compose {
  display: none;
}

.assistant-panel.collapsed .collapse-button {
  min-width: 50px;
  width: 50px;
  height: 50px;
  padding: 0 6px;
  background: var(--blue);
  color: #fff;
  line-height: 1.1;
}

.chat-messages {
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(49, 91, 232, .08), transparent 28%),
    #f8fbff;
  padding: 14px;
  overflow: auto;
}

.message {
  max-width: 92%;
  padding: 11px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  white-space: pre-wrap;
  line-height: 1.4;
  box-shadow: 0 8px 20px rgba(16, 36, 63, .05);
}

.message.bot {
  background: #fff;
  border: 1px solid var(--line);
}

.message.user {
  background: var(--blue);
  color: #fff;
  margin-left: auto;
}

.chat-compose {
  display: grid;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.quick-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 6px;
  font-weight: 850;
  font-size: .76rem;
}

.quick-actions button:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.auto-check {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: .86rem;
}

.composer {
  position: relative;
}

.composer textarea {
  width: 100%;
  min-height: 82px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 50px 12px 12px;
  background: #f8fbff;
  outline: none;
}

.composer textarea:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(49, 91, 232, .12);
}

.camera-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  display: grid;
  place-items: center;
  transition: transform .15s ease, background .15s ease;
}

.camera-button:hover {
  transform: translateY(-1px);
  background: #dce7ff;
}

.camera-button.hidden {
  display: none;
}

.camera-button svg {
  width: 20px;
  height: 20px;
}

.file-input {
  display: none;
}

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

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

  .sidebar,
  .assistant-panel {
    position: static;
    height: auto;
  }

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

  .dashboard-grid,
  .kpi-grid,
  .finance-grid,
  .expense-form {
    grid-template-columns: 1fr;
  }

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

  .search {
    width: 100%;
  }

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