html {
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at top, rgba(13, 74, 168, 0.08), transparent 26%),
    linear-gradient(180deg, #f8f4ee 0%, #eef3f8 38%, #f6f7fa 100%);
  margin: 0;
  color: #122033;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(94px + env(safe-area-inset-bottom));
}

.app-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.demo-banner {
  background: linear-gradient(135deg, rgba(13, 74, 168, 0.09), rgba(191, 155, 60, 0.08));
  border: 1px solid rgba(13, 74, 168, 0.2);
  color: #0d4aa8;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 18px rgba(13, 74, 168, 0.06);
}

section[id], div[id] {
  scroll-margin-top: 84px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
  backdrop-filter: blur(10px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 14px;
  flex-shrink: 0;
  filter: drop-shadow(0 6px 12px rgba(13, 74, 168, 0.12));
}

.byline {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted, #55657d);
}

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
  color: #0d4aa8;
}

header h1 {
  margin: 0;
  font-size: clamp(1.45rem, 3.7vw, 2.2rem);
  line-height: 1.1;
  letter-spacing: -0.06em;
  color: #10233d;
  font-family: Georgia, "Times New Roman", serif;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ebf6ef, #dfeee6);
  color: #234c36;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 7px 10px;
  border: 1px solid rgba(18, 90, 60, 0.18);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mobile-nav {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 7px 4px 9px;
  scrollbar-width: none;
  background: rgba(238, 244, 255, 0.86);
  backdrop-filter: blur(12px);
  border-radius: 16px;
}

.mobile-nav::-webkit-scrollbar {
  display: none;
}

.nav-pill {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #334155;
  font-weight: 700;
  padding: 9px 14px;
  border-radius: 999px;
  min-width: auto;
  width: auto;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: all 0.18s ease;
  font-size: 13px;
}

.nav-pill.active {
  background: linear-gradient(135deg, #0d4aa8, #123d8e);
  color: white;
  border-color: transparent;
  box-shadow: 0 12px 22px rgba(13, 74, 168, 0.24);
}

.fab {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f172a, #1d4ed8);
  color: white;
  font-weight: 700;
  padding: 16px 20px;
  box-shadow: 0 18px 34px rgba(37, 99, 235, 0.32);
}

.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 0;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}
.summary-panel {
  border-left: 4px solid #16a34a;
  background: linear-gradient(135deg, #f0fdf4, #ffffff);
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.summary-card {
  background: white;
  border: 1px solid #dcfce7;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.05);
}
.summary-card .label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4b5563;
  margin-bottom: 8px;
}
.summary-card strong {
  font-size: 28px;
  color: #14532d;
}
.estimate-box {
  margin-top: 16px;
  background: linear-gradient(135deg, #fff7ed, #fffaf3);
  border: 1px solid #fed7aa;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 18px rgba(234, 88, 12, 0.04);
}
.rate-editor {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.rate-editor label {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7c2d12;
  font-weight: 700;
  margin: 0;
}
.rate-editor input {
  width: 150px;
  margin: 0;
}
.estimate-label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9a5b08;
}
.estimate-box strong {
  display: block;
  font-size: 30px;
  color: #9a5b08;
  margin: 8px 0 4px;
}
.estimate-box small {
  color: #7c2d12;
}
.voice-panel {
  border-left: 4px solid #2563eb;
}
.voice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
input, select, textarea, button {
  font-size: 16px;
  padding: 12px 14px;
  margin: 8px 0;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  appearance: none;
}

#time-entry-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#time-entry-section select,
#time-entry-section input,
#time-entry-section textarea {
  width: 100%;
  box-sizing: border-box;
  display: block;
}

#time-entry-section select,
#time-entry-section input#entry-duration {
  min-height: 46px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.inline-form > * {
  flex: 1 1 140px;
}

.date-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.date-field label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #2563eb;
  margin: 0;
}

.date-field input {
  margin: 0;
}

button, .button-link {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  width: auto;
  padding: 10px 14px;
  min-height: 40px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.14);
  letter-spacing: 0.01em;
}

#review-billing,
#save-invoice-from-review,
#billing-export-link {
  flex: 1 1 160px;
  width: auto;
  min-width: 160px;
  max-width: none;
  padding: 10px 14px;
  font-size: 15px;
  min-height: 44px;
  white-space: nowrap;
  line-height: 1.2;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.14);
}

.config-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.config-item {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px;
}
.config-item strong {
  display: block;
  margin-bottom: 6px;
}
.config-meta {
  color: #475569;
  font-size: 14px;
  margin-bottom: 8px;
}
.config-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
button.secondary {
  background: #475569;
}
button.success {
  background: #16a34a;
}
button.row-action {
  display: inline-block;
  width: auto;
  margin: 4px 4px 0 0;
  padding: 8px 12px;
}
button:active {
  transform: translateY(1px);
  opacity: 0.96;
}
button.row-action.delete-entry {
  background: #dc2626;
}
button.delete-client,
button.delete-matter,
button.delete-user {
  background: #dc2626;
}
.settings-form {
  display: grid;
  gap: 4px;
  max-width: 440px;
}
.settings-form label {
  font-size: 13px;
  font-weight: 700;
}
.settings-form input {
  width: 100%;
  box-sizing: border-box;
}
.notice {
  padding: 10px 12px;
  border-radius: 10px;
  margin: 0 0 12px;
  font-weight: 600;
}
.notice.success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #14532d;
}
.notice.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
button.tiny {
  padding: 8px 12px;
  font-size: 14px;
  width: auto;
  margin: 0;
}
button.hidden {
  display: none;
}
textarea {
  min-height: 90px;
}
.status-box, .suggestions-box {
  margin-top: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 10px 12px;
  color: #1e3a8a;
}
.suggestions-box {
  display: none;
}
.suggestions-box.visible {
  display: block;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden {
  display: none;
}
.modal-content {
  width: min(520px, 90vw);
  background: white;
  border-radius: 12px;
  padding: 22px;
}
.review-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.review-summary > div {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
}
.review-summary strong {
  display: block;
  font-size: 22px;
  margin-bottom: 4px;
}
.review-summary span {
  color: #475569;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}
label {
  display: block;
  margin-top: 10px;
  font-weight: 600;
}
label input, label select, label textarea {
  margin-top: 6px;
}
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
}

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 12px;
}
th, td {
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  padding: 10px 8px;
  vertical-align: top;
  white-space: normal;
}

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

.invoice-card {
  background: #f8fafc;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 12px;
}

.invoice-card strong {
  display: block;
  margin-bottom: 8px;
}

.invoice-card button {
  margin-top: 12px;
}

.invoice-detail {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px;
  max-width: 900px;
  margin: 24px auto;
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.invoice-metadata {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.invoice-total {
  font-size: 28px;
  font-weight: 700;
  color: #14532d;
}

@media (max-width: 767px) {
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    padding: 12px 12px 10px;
    border-radius: 16px;
  }

  .summary-grid,
  .review-summary,
  .invoice-metadata,
  .config-list,
  .invoice-list {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
    border-radius: 16px;
  }

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

  .voice-actions,
  .modal-actions {
    flex-direction: column;
  }

  .modal-content {
    padding: 18px 16px;
    width: min(92vw, 520px);
  }

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

  th, td {
    font-size: 12px;
    padding: 7px 5px;
  }

  .button-link,
  button {
    width: auto;
    max-width: 100%;
    white-space: nowrap;
    justify-content: center;
  }

  .inline-form .button-link,
  .inline-form button {
    width: 100%;
  }

  .row-action {
    width: auto;
    min-width: 0;
  }
}

@media print {
  body {
    background: white;
  }
  .container {
    max-width: none;
    padding: 0;
  }
  .button-link, button, .secondary, .success {
    display: none !important;
  }
  .panel {
    box-shadow: none;
    border: 1px solid #d1d5db;
    margin-bottom: 12px;
    padding: 16px;
  }
}

.admin-message {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ecfdf5;
  color: #065f46;
}

.trial-banner {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #1e1b4b;
}
.trial-banner a {
  margin-left: 6px;
  font-weight: 600;
}

.feedback-add {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
}
.feedback-add textarea { grid-column: 1 / -1; }
.feedback-add button { grid-column: 1 / -1; justify-self: start; }
.feedback-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.filter-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  text-decoration: none;
  color: inherit;
  font-size: 13px;
}
.filter-pill.active {
  background: #0d4aa8;
  border-color: #0d4aa8;
  color: #ffffff;
}
.filter-divider { width: 12px; }
.feedback-item {
  border-top: 1px solid #e2e8f0;
  padding: 12px 0;
}
.feedback-item.is-done { opacity: 0.6; }
.feedback-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.feedback-message {
  margin: 8px 0;
  white-space: pre-wrap;
}
.feedback-update {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.feedback-update input[type="text"] { flex: 1 1 220px; }
.kind-tag {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}
.kind-bug { background: #fee2e2; color: #991b1b; }
.kind-request { background: #e0e7ff; color: #3730a3; }
.kind-praise { background: #dcfce7; color: #166534; }
.kind-other { background: #f1f5f9; color: #334155; }
@media (max-width: 600px) {
  .feedback-add { grid-template-columns: 1fr; }
}

.help-page h3 {
  margin: 16px 0 6px;
  font-size: 16px;
}
.help-page p { line-height: 1.55; }
.help-lead { font-size: 16px; margin: 0; }
.help-list { padding-left: 20px; line-height: 1.6; }
.help-list li { margin-bottom: 6px; }
.help-contact { background: #eef2ff; border: 1px solid #c7d2fe; }
