:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface2: #eef1f6;
  --border: #d8dee8;
  --text: #1a2332;
  --muted: #5c6b7f;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #15803d;
  --warning: #b45309;
  --radius: 8px;
  --font: "Segoe UI", system-ui, sans-serif;
  --shadow: 0 1px 3px rgba(26, 35, 50, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[v-cloak] {
  display: none;
}

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

.header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.header-user .username {
  font-size: 0.875rem;
  color: var(--muted);
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.tagline {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 0.15rem;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 72px);
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 1rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.search-input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.project-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.project-list li {
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 0.25rem;
  border: 1px solid transparent;
}

.project-list li:hover {
  background: var(--surface2);
}

.project-list li.active {
  background: #e8effe;
  border-color: var(--accent);
}

.project-number {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
}

.project-subject {
  display: block;
  font-size: 0.82rem;
  color: var(--text);
  margin-top: 0.15rem;
  line-height: 1.35;
}

.main {
  padding: 1.5rem;
  overflow-y: auto;
}

.empty-main {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 72px);
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.auth-hint,
.auth-message {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.auth-form label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.auth-form input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.auth-error {
  color: var(--danger);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.auth-switch {
  margin-top: 1rem;
  text-align: center;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--accent-hover);
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.project-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.4;
}

.subject-preview {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.35rem;
  font-family: ui-monospace, monospace;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  box-shadow: var(--shadow);
}

.btn:hover {
  background: var(--surface2);
  border-color: #c5ced9;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: none;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  border-color: #fecaca;
  color: var(--danger);
  background: #fef2f2;
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.panel-head h3 {
  font-size: 1rem;
  font-weight: 600;
}

.quote-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
  background: var(--surface);
}

.quote-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  background: var(--surface2);
}

.quote-head:hover {
  background: #e4e9f0;
}

.quote-name {
  flex: 1;
  font-weight: 500;
}

.quote-total {
  font-weight: 600;
  color: var(--success);
}

.chevron {
  color: var(--muted);
  font-size: 0.75rem;
}

.quote-body {
  padding: 1rem;
}

.quote-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.variation-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--bg);
}

.variation-card.collapsed .variation-head {
  margin-bottom: 0;
  cursor: pointer;
}

.variation-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.desc-input {
  flex: 1;
  min-width: 180px;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}

.desc-input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.status-select {
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.status-pending {
  border-color: var(--warning);
  background: #fffbeb;
}

.status-approved {
  border-color: var(--success);
  background: #f0fdf4;
}

.status-declined {
  border-color: var(--danger);
  background: #fef2f2;
  opacity: 0.85;
}

.variation-total {
  font-weight: 600;
  margin-left: auto;
}

.line-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.line-table th,
.line-table td {
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.line-table th {
  color: var(--muted);
  font-weight: 500;
  background: var(--surface2);
}

.line-table th.col-desc,
.line-table td.col-desc {
  width: 40%;
  min-width: 20rem;
}

.cell-input {
  width: 100%;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
}

.cell-input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.cell-input.desc {
  min-width: 20rem;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pricing-breakdown {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.5rem 0;
}

.pricing-breakdown .final {
  color: var(--success);
  font-weight: 600;
}

.empty,
.empty-panel {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  max-width: 440px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(26, 35, 50, 0.15);
}

.modal::backdrop {
  background: rgba(26, 35, 50, 0.35);
}

.modal form {
  padding: 1.25rem;
}

.modal h3 {
  margin-bottom: 1rem;
}

.modal label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.modal input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.fieldset legend {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0 0.25rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(26, 35, 50, 0.12);
  z-index: 100;
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 40vh;
  }

  .field-row {
    grid-template-columns: 1fr;
  }
}
