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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f6fa;
  color: #2d3436;
  line-height: 1.5;
}

.navbar {
  background: #2d3436;
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
}

.nav-links a {
  color: #b2bec3;
  text-decoration: none;
  margin-left: 20px;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  color: #fff;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.alert {
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid #dfe6e9;
  border-radius: 6px;
  background: #fff;
  color: #2d3436;
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.btn:hover {
  background: #f1f2f6;
}

.btn-primary {
  background: #0984e3;
  color: #fff;
  border-color: #0984e3;
}

.btn-primary:hover {
  background: #0770c2;
}

.btn-success {
  background: #00b894;
  color: #fff;
  border-color: #00b894;
}

.btn-success:hover {
  background: #00a381;
}

.btn-danger {
  background: #d63031;
  color: #fff;
  border-color: #d63031;
}

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

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}

.data-table th {
  background: #f8f9fa;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #636e72;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.actions {
  white-space: nowrap;
}

.actions .btn,
.actions form {
  margin-right: 4px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.empty-state p {
  color: #636e72;
  margin-bottom: 16px;
}

.form-card {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

fieldset {
  border: none;
  margin-bottom: 24px;
}

legend {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 12px;
  color: #2d3436;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: #636e72;
  margin-bottom: 4px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dfe6e9;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #0984e3;
}

.form-hint {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #636e72;
}

.signature-preview {
  margin-bottom: 8px;
  padding: 8px;
  background: #fff;
  border: 1px solid #dfe6e9;
  border-radius: 6px;
  display: inline-block;
}

.signature-preview img {
  max-height: 60px;
  max-width: 200px;
  display: block;
}

.form-actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.items-table th {
  background: #f8f9fa;
  padding: 8px 6px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #636e72;
  border-bottom: 2px solid #dfe6e9;
}

.items-table td {
  padding: 4px 4px;
  vertical-align: middle;
}

.items-table input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #dfe6e9;
  border-radius: 4px;
  font-size: 0.85rem;
}

.items-table input:focus {
  outline: none;
  border-color: #0984e3;
}

.item-gst-display,
.item-total-display,
.item-taxable-display {
  text-align: right;
  font-size: 0.85rem;
  white-space: nowrap;
  padding-right: 8px !important;
  color: #636e72;
}

.totals-panel {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.9rem;
}

.totals-row.total-highlight {
  font-size: 1.1rem;
  border-top: 2px solid #dfe6e9;
  padding-top: 8px;
  margin-top: 4px;
}

.totals-row.words {
  font-size: 0.85rem;
  color: #636e72;
  margin-top: 8px;
  flex-direction: column;
  gap: 2px;
}

.nav-user {
  color: #b2bec3;
  margin-left: 20px;
  font-size: 0.85rem;
}

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: #f5f6fa;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 10px;
  padding: 28px 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.auth-brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: #2d3436;
  margin-bottom: 8px;
}

.auth-card h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.auth-form .form-group {
  margin-bottom: 14px;
}

.auth-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"],
.auth-form input[type="tel"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #dfe6e9;
  border-radius: 6px;
  font-size: 0.95rem;
}

.auth-sub {
  margin: -4px 0 16px;
  font-size: 0.9rem;
  color: #636e72;
  line-height: 1.4;
}

.auth-method-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.auth-method-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid #dfe6e9;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}

.auth-method-tab:has(input:checked) {
  border-color: #0984e3;
  background: #f0f7ff;
  color: #0984e3;
}

.auth-method-tab input {
  margin: 0;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: #b2bec3;
  font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #dfe6e9;
}

.btn-google {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  background: #fff;
  color: #2d3436;
  border: 1px solid #dfe6e9;
  padding: 9px 12px;
  border-radius: 6px;
  font-weight: 500;
}

.btn-google:hover {
  background: #f8f9fa;
  border-color: #b2bec3;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.inline-form select {
  padding: 4px 6px;
  border: 1px solid #dfe6e9;
  border-radius: 4px;
  font-size: 0.85rem;
}

.badge-ok {
  background: #dfe6e9;
  color: #00b894;
}

.badge-warn {
  background: #ffeaa7;
  color: #d63031;
}

.form-check label {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-block {
  width: 100%;
  margin-top: 8px;
}

.auth-footer {
  margin-top: 18px;
  font-size: 0.9rem;
  text-align: center;
  color: #636e72;
}

.auth-hint {
  margin-top: 16px;
  padding: 10px 12px;
  background: #f8f9fa;
  border: 1px solid #dfe6e9;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #636e72;
  line-height: 1.45;
  text-align: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.stat-label {
  font-size: 0.8rem;
  color: #636e72;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 600;
  color: #2d3436;
}

.stat-hint {
  font-size: 0.75rem;
  color: #b2bec3;
  margin-top: 2px;
}

.stats-grid-secondary {
  margin-top: -8px;
}

.stat-card-sm .stat-value-sm {
  font-size: 1.1rem;
  font-weight: 600;
  color: #2d3436;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  margin-top: 8px;
  align-items: start;
}

.dash-panel {
  background: #fff;
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.sales-tree,
.sales-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sales-tree ul {
  margin-left: 14px;
  border-left: 2px solid #eceff1;
  padding-left: 12px;
  margin-top: 6px;
}

.tree-node {
  margin: 4px 0;
}

.tree-node > details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 6px;
  list-style: none;
}

.tree-node > details > summary::-webkit-details-marker {
  display: none;
}

.tree-node > details > summary::before {
  content: "▸";
  color: #636e72;
  margin-right: 6px;
  font-size: 0.8rem;
}

.tree-node > details[open] > summary::before {
  content: "▾";
}

.tree-year > details > summary {
  background: #f5f6fa;
  font-weight: 600;
}

.tree-month > details > summary {
  background: #fafbfc;
}

.tree-day > details > summary:hover,
.tree-month > details > summary:hover,
.tree-year > details > summary:hover {
  background: #eef2f5;
}

.tree-label {
  flex: 1;
}

.tree-meta {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 0.85rem;
  color: #636e72;
  white-space: nowrap;
}

.tree-meta strong {
  color: #2d3436;
}

.tree-metrics {
  font-size: 0.78rem;
  color: #636e72;
  padding: 2px 10px 8px 28px;
}

.tree-invoice-table {
  margin: 4px 0 10px 10px;
  box-shadow: none;
}

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

.stat-card {
  background: #fff;
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.stat-label {
  font-size: 0.8rem;
  color: #636e72;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 600;
  color: #2d3436;
}

.stat-hint {
  font-size: 0.75rem;
  color: #b2bec3;
  margin-top: 2px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
}

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

.data-table-compact th,
.data-table-compact td {
  font-size: 0.85rem;
  padding: 10px 12px;
  vertical-align: top;
}

.data-table .num {
  text-align: right;
  white-space: nowrap;
}

.cell-primary {
  font-weight: 600;
}

.cell-muted {
  font-size: 0.78rem;
  color: #636e72;
  margin-top: 2px;
}

.badge {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 6px;
  font-size: 0.7rem;
  border-radius: 4px;
  background: #dfe6e9;
  color: #2d3436;
}

.badge-converted {
  background: #d4edda;
  color: #155724;
}

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

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}

.form-group-payment .received-wrap {
  margin-top: 10px;
}

.form-group-payment .received-wrap.is-hidden {
  display: none;
}

.form-group-payment .received-wrap label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.field-hint {
  font-size: 0.85rem;
  color: #636e72;
  margin-bottom: 10px;
}

.items-table .item-amount {
  width: 110px;
  text-align: right;
}

.item-name-wrap {
  position: relative;
  min-width: 140px;
}

.item-name-wrap .item-name-input {
  width: 100%;
}

.item-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  z-index: 20;
  background: #fff;
  border: 1px solid #dfe6e9;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 220px;
  overflow-y: auto;
}

.item-suggest-option {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid #f1f2f6;
}

.item-suggest-option:hover,
.item-suggest-option:focus {
  background: #f5f6fa;
}

.suggest-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: #2d3436;
}

.suggest-meta {
  display: block;
  font-size: 0.75rem;
  color: #636e72;
  margin-top: 2px;
}

.empty-state {
  color: #636e72;
  padding: 24px 0;
}

.auth-footer a {
  color: #0984e3;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.hp-field {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

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

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .items-table {
    display: block;
    overflow-x: auto;
  }
}
