/* MZWN Tenders — hand-written ERPNext-style stylesheet. No framework. */

:root {
  --bg: #f7f7f8;
  --surface: #fff;
  --border: #e2e4e9;
  --text: #1f272e;
  --muted: #6b7785;
  --accent: #2490ef;
  --blue: #2490ef;
  --green: #28a745;
  --orange: #f0a52d;
  --red: #e24c4b;
  --grey: #9ba3ab;
  --radius: 6px;
  --gap: 12px;
  --sidebar-w: 220px;
  --topbar-h: 48px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* —— shell —— */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.topbar-brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.topbar-search {
  flex: 1;
  max-width: 360px;
  margin: 0;
}
.topbar-search input {
  width: 100%;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.topbar-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.topbar-logout { margin: 0; }

.shell {
  display: flex;
  min-height: 100vh;
  padding-top: var(--topbar-h);
}

.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  overflow-y: auto;
  z-index: 10;
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar a {
  display: block;
  padding: 8px 20px;
  color: var(--text);
  text-decoration: none;
}
.sidebar a:hover { background: var(--bg); color: var(--accent); }

.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 24px;
  max-width: 1200px;
}

/* —— typography & page —— */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gap);
  margin-bottom: 20px;
}
.page-head h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 650;
}
.page-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.row-title { font-weight: 400; color: var(--muted); }

.flashes { margin-bottom: 16px; }
.flash {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.flash-success { border-color: #b7e0c2; background: #edf8f0; color: #1e6b34; }
.flash-error { border-color: #f0b6b5; background: #fdf0f0; color: #8f2a29; }
.flash-info { border-color: #b7d4f5; background: #eef5fc; }

.empty {
  color: var(--muted);
  padding: 16px 0;
}

.muted { color: var(--muted); }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* —— buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover { filter: brightness(0.95); color: #fff; }
.btn--quiet {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  height: 28px;
}
.btn--quiet:hover { color: var(--text); background: var(--bg); }

.next-action { white-space: nowrap; }
.next-action--plain {
  margin: 0;
  font-weight: 600;
  color: var(--muted);
}

/* —— forms —— */
.form-card, .auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.form-card h2, .auth-card h1 {
  margin: 0 0 16px;
  font-size: 16px;
}
.auth-card {
  max-width: 380px;
  margin: 40px auto;
}

.field { margin-bottom: 14px; }
.field-label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input[type="text"],
.field input[type="password"],
.field input[type="search"],
.field input[type="date"],
.field input[type="number"],
.field input[type="email"],
.field input[type="file"],
.field select,
.field textarea,
.inline-form input[type="text"],
.inline-form select,
.status-form select,
.status-form input {
  width: 100%;
  max-width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  font: inherit;
  color: var(--text);
}
.field textarea {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
}
.field-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
}
.inline-form {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 0;
}
.inline-form input,
.inline-form select { width: auto; min-width: 120px; }

.status-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.status-form .field { margin: 0; min-width: 160px; }

.detail-list {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 6px 16px;
  margin: 0 0 12px;
}
.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.detail-list dd { margin: 0; }

/* —— tables —— */
.table-scroll {
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.list-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.list-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.list-table tbody tr:hover { background: #fafbfc; }
.list-table tbody tr:last-child td { border-bottom: none; }
.list-table tbody tr.row-selected { background: #f2faf4; }
.list-table tbody tr.row-selected:hover { background: #eaf7ed; }
.list-table tbody tr.row-selected td:first-child { box-shadow: inset 3px 0 0 var(--green); }

.list-table input[type="text"],
.list-table input[type="number"],
.list-table select {
  width: 100%;
  min-width: 72px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}

.row-actions {
  white-space: nowrap;
}
.assignee-list {
  margin: 0 0 12px;
  padding-left: 18px;
}

/* —— indicators —— */
.indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f0f2f5;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}
.indicator::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--grey);
}
.indicator--blue::before { background: var(--blue); }
.indicator--green::before { background: var(--green); }
.indicator--orange::before { background: var(--orange); }
.indicator--red::before { background: var(--red); }
.indicator--grey::before { background: var(--grey); }

/* —— project workspace —— */
.timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}
.timeline-step {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.timeline-step--current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.timeline-meta, .timeline-note {
  font-size: 11px;
  color: var(--muted);
}
.timeline-note { font-style: italic; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 20px 0 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 10px 14px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  font-size: 13px;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-panel {
  padding-top: 16px;
}

.error-page {
  max-width: 520px;
  margin: 40px auto;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.error-status {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 8px;
}
.error-message { margin: 0; }

.field--check {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* —— comparison —— */
.comparison-sticky {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
  min-width: 180px;
  box-shadow: 1px 0 0 var(--border);
}
.comparison-table thead .comparison-sticky { background: #fafbfc; }
.cell-lowest {
  background: #edf8f0;
  font-weight: 600;
  color: #1e6b34;
}

/* Cost figures are omitted server-side for users without cost.view.
   Never hide a cost with CSS: view-source would still show it. */
.cost-figure {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.costing-table td,
.costing-table th { font-size: 12px; }
.costing-table [data-total-cost],
.costing-table [data-selling-price],
.costing-table [data-gross-profit],
.costing-table [data-markup-pct],
.costing-table [data-margin-pct] {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.quotation-print h1 { font-size: 20px; }

/* —— filters / dashboard bits —— */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: flex-end;
}
.filters .field { margin: 0; min-width: 140px; }

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--gap);
  margin-bottom: 20px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 22px; font-weight: 650; margin-top: 4px; }

/* —— responsive —— */
@media (max-width: 860px) {
  .sidebar {
    position: static;
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .shell { flex-direction: column; padding-top: var(--topbar-h); }
  .content { margin-left: 0; padding: 16px; }
  .sidebar ul { display: flex; flex-wrap: wrap; }
  .page-head { flex-direction: column; }
}

@media print {
  .topbar, .sidebar, .tabs, .btn, .form-actions, .status-form, .flashes {
    display: none !important;
  }
  .shell { padding: 0; }
  .content { margin: 0; max-width: none; padding: 0; }
  .table-scroll { border: none; overflow: visible; }
  body { background: #fff; }
}
