:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5eb;
  --text: #1c2230;
  --text-muted: #6b7280;
  --accent: #2f5d50;
  --accent-soft: #e6efec;
  --order-color: #2f5d50;
  --draft-color: #9a6b1f;
  --draft-soft: #f5ecd9;
  --radius: 10px;

  --st-pending: #6b7280;
  --st-pending-soft: #eceef1;
  --st-confirmed: #1e7a4c;
  --st-confirmed-soft: #e2f3ea;
  --st-canceled: #b0402e;
  --st-canceled-soft: #fbe8e4;
  --st-noanswer: #9a6b1f;
  --st-noanswer-soft: #f5ecd9;
  --st-callback: #2f5f8a;
  --st-callback-soft: #e5eef6;
  --st-fulfillment: #6a4fa0;
  --st-fulfillment-soft: #ece5f5;
  --st-delivered: #1e7a4c;
  --st-delivered-soft: #e2f3ea;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

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

.topbar h1 {
  font-size: 19px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: 8px;
}

.tab {
  border: none;
  background: transparent;
  padding: 7px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

main {
  padding: 24px 28px;
  max-width: 1280px;
  margin: 0 auto;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 16px;
}

#search {
  flex: 1;
  max-width: 420px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
}

#search:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.stats {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
tbody tr.record-row { cursor: pointer; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge.order { background: var(--accent-soft); color: var(--order-color); }
.badge.draft { background: var(--draft-soft); color: var(--draft-color); }

.products-list { margin: 0; padding: 0; list-style: none; }
.products-list li { font-size: 12.5px; color: var(--text); }
.products-list li + li { margin-top: 2px; }
.qty { color: var(--text-muted); }

.amount { font-variant-numeric: tabular-nums; font-weight: 600; }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.pagination button {
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 700px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
  main { padding: 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  #search { max-width: none; }
}

/* --- Login --- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 {
  font-size: 18px;
  margin: 0;
}

.login-sub {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 13px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}

.login-card input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.login-card button {
  margin-top: 6px;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.login-error {
  color: var(--st-canceled);
  font-size: 13px;
  min-height: 16px;
  margin: 0;
}

/* --- User info / logout --- */
.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.user-bar button {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12.5px;
}

/* --- Status badges & select --- */
.status-select {
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.status-de_confirmat { background: var(--st-pending-soft); color: var(--st-pending); }
.status-confirmat { background: var(--st-confirmed-soft); color: var(--st-confirmed); }
.status-fulfillment { background: var(--st-fulfillment-soft); color: var(--st-fulfillment); }
.status-livrat { background: var(--st-delivered-soft); color: var(--st-delivered); }
.status-anulat { background: var(--st-canceled-soft); color: var(--st-canceled); }
.status-nu_raspunde { background: var(--st-noanswer-soft); color: var(--st-noanswer); }
.status-revin_mai_tarziu { background: var(--st-callback-soft); color: var(--st-callback); }

.sync-error {
  color: var(--st-canceled);
  font-size: 11px;
  margin-top: 4px;
  cursor: help;
}

.history-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  padding: 0;
  margin-top: 4px;
}

/* --- Modal istoric apeluri --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 32, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  width: 420px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 18px;
  margin: 8px 0 4px;
}

.modal h3 {
  font-size: 14px;
  margin: 20px 0 10px;
}

.modal-header {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-phone {
  display: inline-block;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 6px;
}

.modal-phone:hover { text-decoration: underline; }

.modal-address {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.modal-products {
  margin-bottom: 10px;
}

.modal-products li {
  font-size: 14px;
}

.modal-amount {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.modal-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-status-row label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.modal-status-row .status-select {
  font-size: 13px;
  padding: 7px 12px;
}

.modal .modal-sub {
  color: var(--text-muted);
  font-size: 12.5px;
  margin: 0 0 16px;
}

.modal-close {
  float: right;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
}

.history-entry {
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
  font-size: 13px;
}

.history-entry:last-child { border-bottom: none; }

.history-meta {
  color: var(--text-muted);
  font-size: 11.5px;
  margin-top: 2px;
}

.history-note {
  margin-top: 4px;
  color: var(--text);
}

.note-form {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.note-form input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
}

.note-form button {
  padding: 8px 14px;
  border: none;
  background: var(--accent);
  color: white;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}
