:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --border: #d9dde3;
  --bg: #f5f6f8;
  --text: #1f2430;
  --muted: #6b7280;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.topbar[hidden] {
  display: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 1.25rem;
  margin: 0;
}

.topbar nav a {
  margin-left: 16px;
  text-decoration: none;
  color: var(--primary);
  font-weight: 500;
}

.topbar nav a.active {
  color: var(--primary-dark);
  text-decoration: underline;
}

main#app {
  max-width: 960px;
  margin: 24px auto;
  padding: 0 16px;
}

.panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.panel-header {
  margin-bottom: 16px;
}

.panel-header input[type="search"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.data-table, .items-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th, .data-table td,
.items-table th, .items-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.92rem;
}

.data-table tbody tr:hover {
  background: #fafbfc;
}

.row-actions a, .row-actions button {
  margin-right: 8px;
  font-size: 0.85rem;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 24px 0;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 16px 0;
  padding: 14px;
}

legend {
  font-weight: 600;
  padding: 0 6px;
}

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

.form-grid .span-2 {
  grid-column: span 2;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 10px;
}

input, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
}

input[readonly] {
  background: #f0f1f3;
}

.items-table input {
  width: 100%;
  padding: 5px 7px;
}

.items-table .item-qty, .items-table .item-rate {
  width: 90px;
}

.items-table .item-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.remove-item-btn {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 1.1rem;
  cursor: pointer;
}

.totals {
  text-align: right;
  margin-top: 10px;
  font-size: 1rem;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn-primary, .btn-secondary {
  padding: 9px 18px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.92rem;
  text-decoration: none;
  display: inline-block;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

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

.hint {
  color: var(--muted);
  font-size: 0.88rem;
}

.hint code {
  background: #eef0f3;
  padding: 1px 5px;
  border-radius: 4px;
}

.location-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.location-list li {
  background: #eef0f3;
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 0.9rem;
}

.logo-preview {
  max-width: 120px;
  max-height: 120px;
  margin-top: 10px;
  display: block;
}

.logo-preview[hidden] {
  display: none;
}

.login-panel {
  max-width: 360px;
  margin: 60px auto;
}

.login-error {
  color: #b91c1c;
  font-size: 0.88rem;
  margin: 4px 0 0;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #1f2430;
  color: white;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #b91c1c;
}

.row-cancelled td {
  opacity: 0.55;
  text-decoration: line-through;
}

.row-cancelled .row-actions a,
.row-cancelled .status-badge {
  text-decoration: none;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-active {
  background: #dcfce7;
  color: #166534;
}

.badge-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.btn-cancel {
  color: #b91c1c;
  border-color: #fca5a5;
}

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

.btn-danger {
  padding: 9px 18px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.92rem;
  background: #dc2626;
  color: white;
}

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

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: white;
  border-radius: 10px;
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.modal-desc {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 16px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
