/* Quoting app UI — dark is the default theme. */

:root,
[data-theme="dark"] {
  --color-bg: #12161c;
  --color-surface: #1b222c;
  --color-text: #e8ecf1;
  --color-muted: #9aa5b5;
  --color-border: #2e3846;
  --color-brand: #7eb6f0;
  --color-brand-strong: #4d93d9;
  --color-input-bg: #0f1318;
  --color-flash: #243044;
  --color-flash-error-bg: #3a1d1d;
  --color-flash-error-text: #f5b4b0;
  --color-flash-success-bg: #1a3324;
  --color-flash-success-text: #a8dfb5;
  --color-flash-warning-bg: #3a2e14;
  --color-flash-warning-text: #f0d48a;
  --color-badge-admin-bg: #243044;
  --color-badge-admin-text: #9ec5f0;
  --color-badge-staff-bg: #1e3228;
  --color-badge-staff-text: #9fd0b0;
  --color-btn-primary-bg: #3d7ab8;
  --color-btn-primary-text: #ffffff;
  --color-btn-secondary-bg: #2a3340;
  --color-btn-secondary-text: #e8ecf1;
  --space: 1rem;
  --max-width: 60rem;
  color-scheme: dark;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

[data-theme="light"] {
  --color-bg: #f6f7f9;
  --color-surface: #ffffff;
  --color-text: #1a1a1a;
  --color-muted: #5c6570;
  --color-border: #d8dde3;
  --color-brand: #1f4b7a;
  --color-brand-strong: #16385c;
  --color-input-bg: #ffffff;
  --color-flash: #e8eef5;
  --color-flash-error-bg: #fdecea;
  --color-flash-error-text: #7a1f1a;
  --color-flash-success-bg: #e6f4ea;
  --color-flash-success-text: #1e4620;
  --color-flash-warning-bg: #fff4e5;
  --color-flash-warning-text: #663c00;
  --color-badge-admin-bg: #e8eef5;
  --color-badge-admin-text: #1f4b7a;
  --color-badge-staff-bg: #eef2f0;
  --color-badge-staff-text: #2d5a3d;
  --color-btn-primary-bg: #1f4b7a;
  --color-btn-primary-text: #ffffff;
  --color-btn-secondary-bg: #eef1f5;
  --color-btn-secondary-text: #1a1a1a;
  color-scheme: light;
  color: var(--color-text);
  background: var(--color-bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: min(100% - 2 * var(--space), var(--max-width));
  margin-inline: auto;
}

.share-link-box {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  background: var(--color-surface);
}

.share-link-box .input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
}

.attachments-section h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.attachments-table .mono-cell .input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  min-width: 12rem;
  width: 100%;
}

.attachments-table .actions-cell {
  white-space: nowrap;
  text-align: right;
}

.upload-form {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.upload-form .field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.85rem;
}

.input-sm {
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
}

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0.5rem 0;
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem var(--space);
  flex-wrap: nowrap;
}

.brand {
  color: var(--color-brand);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  max-width: 12rem;
}

.brand-logo {
  display: block;
  max-height: 2.25rem;
  max-width: 11rem;
  width: auto;
  height: auto;
  object-fit: contain;
}

.brand-text {
  font-size: 1.05rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 11rem;
}

main.container {
  flex: 1;
  padding-block: 1.5rem;
}

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 0.65rem 0;
  color: var(--color-muted);
}

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.25rem;
}

.footer-user {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.footer-user-prefs {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}

.footer-toggles {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.footer-toggle-form {
  display: inline;
  margin: 0;
}

.footer-toggle-btn {
  appearance: none;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  cursor: pointer;
}

.footer-toggle-btn:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.footer-meta {
  opacity: 0.85;
}

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

.page-title {
  margin-bottom: 0.25rem;
}

.flash-messages {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space);
}

.flash {
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  background: var(--color-flash);
  margin-bottom: 0.5rem;
}

.flash-error {
  background: var(--color-flash-error-bg);
  color: var(--color-flash-error-text);
}

.flash-success {
  background: var(--color-flash-success-bg);
  color: var(--color-flash-success-text);
}

.flash-warning {
  background: var(--color-flash-warning-bg);
  color: var(--color-flash-warning-text);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.65rem 0.85rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.site-nav a {
  color: var(--color-brand);
  text-decoration: none;
}

.site-nav a:hover {
  text-decoration: underline;
}

.nav-form {
  display: inline;
  margin: 0;
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-brand);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: none;
}

.btn-link:hover {
  text-decoration: underline;
}

.nav-sep {
  width: 1px;
  height: 1.1rem;
  background: var(--color-border);
  margin: 0 0.1rem;
  flex-shrink: 0;
}

.role-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  vertical-align: middle;
  line-height: 1.3;
}

.role-badge-admin {
  background: var(--color-badge-admin-bg);
  color: var(--color-badge-admin-text);
}

.role-badge-staff {
  background: var(--color-badge-staff-bg);
  color: var(--color-badge-staff-text);
}

.form-card {
  max-width: 28rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  padding: 1.25rem;
}

.form-card-wide {
  max-width: 36rem;
}

.logo-preview {
  margin-bottom: 0.5rem;
}

.logo-thumb {
  max-width: 12rem;
  max-height: 6rem;
  object-fit: contain;
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  background: var(--color-input-bg);
  padding: 0.25rem;
}

.form-field {
  margin-bottom: 1rem;
}

.form-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.form-field-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-field-inline label {
  display: inline;
  font-weight: 500;
  margin: 0;
}

.input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  font: inherit;
  background: var(--color-input-bg);
  color: var(--color-text);
}

.field-error {
  color: var(--color-flash-error-text);
  font-size: 0.875rem;
  margin: 0.25rem 0 0;
}

.hint {
  color: var(--color-muted);
  font-size: 0.875rem;
  margin: 0.25rem 0 0;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 0.25rem;
  border: 1px solid transparent;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--color-btn-primary-bg);
  color: var(--color-btn-primary-text);
}

.btn-secondary {
  background: var(--color-btn-secondary-bg);
  border-color: var(--color-border);
  color: var(--color-btn-secondary-text);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
}

.data-table th,
.data-table td {
  border: 1px solid var(--color-border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.data-table th {
  background: var(--color-btn-secondary-bg);
}

.notice {
  padding: 0.75rem 1rem;
  border-radius: 0.25rem;
  margin-bottom: 1rem;
}

.notice-warning {
  background: var(--color-flash-warning-bg);
  border: 1px solid var(--color-border);
  color: var(--color-flash-warning-text);
}

.form-card-wide {
  max-width: 40rem;
}

.form-section {
  border: none;
  margin: 0 0 1rem;
  padding: 0;
}

.form-section legend {
  font-weight: 700;
  margin-bottom: 0.5rem;
  padding: 0;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.form-row .form-field {
  flex: 1 1 8rem;
}

.locations-section {
  margin-top: 2rem;
}

.address-cell {
  white-space: pre-line;
  font-size: 0.9rem;
}

.actions-cell {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.inline-form {
  display: inline;
  margin: 0;
}


.void-panel {
  display: inline-block;
  vertical-align: middle;
}

.void-panel summary {
  list-style: none;
  cursor: pointer;
}

.void-form {
  margin-top: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  max-width: 20rem;
  background: var(--color-surface);
}

.badge-void {
  color: var(--color-flash-error-text);
  font-weight: 700;
  margin-left: 0.25rem;
}

.search-bar .form-actions {
  margin-top: 0;
}

/* Documents / line items */
.container {
  /* widen for line-item editor */
}

main.container {
  width: min(100% - 2 * var(--space), 72rem);
}

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

.center {
  text-align: center;
}

.totals-panel {
  max-width: 22rem;
  margin-left: auto;
  margin-top: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  padding: 0.75rem 1rem;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0;
}

.totals-total {
  font-weight: 700;
  border-top: 1px solid var(--color-border);
  margin-top: 0.35rem;
  padding-top: 0.5rem;
}

.row-optional {
  background: color-mix(in srgb, var(--color-flash-warning-bg) 55%, var(--color-surface));
}

.line-items-toolbar {
  margin-bottom: 0.5rem;
}

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

.line-items-table .input-sm {
  min-width: 4.5rem;
  padding: 0.3rem 0.4rem;
  font-size: 0.9rem;
}

.line-items-table .name-cell {
  min-width: 12rem;
  position: relative;
}

.line-items-table .name-cell .input {
  margin-bottom: 0.25rem;
}

.line-items-table .num-input {
  max-width: 6.5rem;
}

.terms-fields {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 9rem;
}

.terms-fields [data-term] {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.typeahead-results {
  list-style: none;
  margin: 0.15rem 0 0;
  padding: 0;
  position: absolute;
  z-index: 20;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  max-height: 14rem;
  overflow-y: auto;
  min-width: 16rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.typeahead-results li {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.typeahead-results li:hover,
.typeahead-results li:focus {
  background: var(--color-btn-secondary-bg);
  outline: none;
}

.typeahead-name {
  font-weight: 600;
}

.typeahead-meta {
  font-size: 0.8rem;
  color: var(--color-muted);
}

.typeahead-empty {
  color: var(--color-muted);
  cursor: default;
}

#customer_search {
  position: relative;
}

.form-field {
  position: relative;
}

.snapshot-preview {
  white-space: pre-line;
  margin-top: 0.5rem;
}

.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}

.doc-meta pre {
  margin: 0.25rem 0 0.75rem;
}

/* Dashboard / home workflows */
.lede {
  margin-top: 0;
}

.dashboard-section {
  margin: 1.5rem 0;
}

.dashboard-heading {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
  color: var(--color-muted);
  font-weight: 600;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.75rem;
}

.dashboard-card {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  padding: 1rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.dashboard-card:hover {
  border-color: var(--color-brand);
  box-shadow: 0 2px 8px rgba(31, 75, 122, 0.08);
}

.dashboard-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--color-brand);
}

.dashboard-card p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-muted);
}

.dashboard-card-admin {
  border-style: dashed;
}

.workflow-hint {
  margin-top: 1.5rem;
}

/* Empty list states */
.empty-state {
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: 0.375rem;
  padding: 1.5rem 1.25rem;
  text-align: center;
  color: var(--color-muted);
}

.empty-state-title {
  margin: 0 0 0.35rem;
  font-weight: 700;
  color: var(--color-text);
  font-size: 1.05rem;
}

.empty-state p {
  margin: 0.35rem 0;
}

.empty-state .form-actions {
  justify-content: center;
  margin-top: 1rem;
}
