:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #111827;
  --accent: #2563eb;
  --danger: #b91c1c;
  --success: #0a7a2a;
  --ring: rgba(37, 99, 235, .35);
}

/* Reset / base */
* {
  box-sizing: border-box;
}

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

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

a:hover {
  text-decoration: underline;
}

/* Layout container */
.container {
  width: min(95vw, 1600px);
  margin: 28px auto;
  padding: 0 16px;
}

/* App bar / header */
header.appbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 18px 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  /*background: var(--card); /* same as cards */
  border: 1px solid #e5e7eb; /* subtle border like table rows */
  border-radius: 12px; /* your card radius */
  padding: 10px 14px; /* comfortable hit area */
  box-shadow: 0 8px 24px rgba(0, 0, 0, .06); /* same card shadow */
  backdrop-filter: saturate(180%) blur(6px); /* gentle polish */
  margin-top: 0; /* avoid odd stick jump */
}

.appbar .nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.appbar .brand {
  font-weight: 700;
  font-size: 20px;
}

.appbar .nav a {
  margin-left: 0;
}

.appbar a {
  text-decoration: none;
  margin-left: 12px;
}

.appbar a:hover {
  color: #9a00fa;
  text-decoration: underline;
}

/* Badges */
.badge-admin {
  font-size: 12px;
  background: #e0f2fe;
  color: #075985;
  padding: 4px 8px;
  border-radius: 999px;
  margin-left: 8px;
}

.current-user-label {
  display: inline-flex;
  align-items: center;
  margin-left: 0;
  padding: 0;
  background: transparent;
  color: #000;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
}

.pending-badge {
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 6px;
  margin-left: 2px;
  vertical-align: middle;
  display: inline-block;
  min-width: 16px;
  text-align: center;
  line-height: 1.2;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .06);
  padding: 16px;
  margin: 12px 0;
}

/* Grid / rows */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 960px) {
  .grid {
    grid-template-columns: 3fr 2fr;
  }
}

@media (min-width: 960px) {
  .po-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

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

/* Form controls */
label {
  display: block;
  font-size: 13px;
  margin: 8px 0 4px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: var(--text);
  outline: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

/* Buttons */
button {
  cursor: pointer;
  border: 0;
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
}

button.secondary {
  background: #4b5563;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid #e5e7eb;
}

button.danger {
  background: var(--danger);
  color: var(--text);
}

button.success {
  background: #065f46;
}

/* Inline helpers */
.inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
}

th,
td {
  padding: 6px 10px;
  text-align: left;
  font-size: 14px;
}

thead th {
  color: var(--muted);
  font-weight: 600;
}

tbody tr {
  background: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .03);
}

tbody tr td:first-child {
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
}

tbody tr td:last-child {
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
}

/* Editable / mono cells */
td.editable {
  cursor: pointer;
  position: relative;
}

td.editable:hover {
  background: #fafcff;
}

td.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

/* Misc */
.small {
  font-size: 12px;
  color: var(--muted);
}

.badge {
  background: #eef2ff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  color: #3730a3;
}

.notice {
  color: var(--muted);
  font-size: 13px;
}

.alert.warning {
  background: #fff8e1;
  border-left: 5px solid #f59e0b;
  padding: 12px;
  margin: 12px 0;
  color: #5f4b00;
  border-radius: 8px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .45);
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal-box {
  background: #fff;
  border-radius: 14px;
  max-width: 420px;
  width: 92%;
  padding: 22px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .25);
  text-align: center;
  animation: fadeIn .22s ease;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Login */
.login-wrap {
  display: grid;
  place-items: center;
  min-height: 70vh;
}

.login-card {
  max-width: 380px;
  width: 100%;
}

/* Select placeholder styling (grey when showing placeholder) */
.select-placeholder {
  color: #9ca3af !important; /* override select's base color */
  -webkit-text-fill-color: #9ca3af; /* Safari/WebKit */
}

/* Options stay normal in the dropdown list */
select option {
  color: initial;
}

/* If the placeholder option ever shows in the list, keep it grey */
select option[disabled] {
  color: #9ca3af;
}

/* Invalid inputs */
input:invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(185, 28, 28, .15);
}

/* Pill buttons */
.btn-pill {
  padding: 8px 14px;
  border-radius: 9999px;
  font-weight: 600;
  border: none;
  line-height: 1;
}

.btn-approve {
  background: #136f3a; /* green */
  color: #fff;
}

.btn-approve:hover {
  background: #0f5d31;
}

.btn-reject {
  background: #b91c1c; /* red */
  color: #fff;
}

.btn-reject:hover {
  background: #991b1b;
}

.flash-highlight {
  animation: flashHighlight 1.4s ease-out;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .35);
}

@keyframes flashHighlight {
  from {
    background-color: #e0f2fe;
  }
  to {
    background-color: inherit;
    box-shadow: none;
  }
}

.stage-card .stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.stage-card .stage-header h2 {
  margin: 0;
}

.stage-card .toggle-stage {
  padding: 6px 10px;
  font-size: 13px;
}

.stage-card.collapsed .stage-body {
  display: none;
}
/* Sticky table header support */
:root {
  --sticky-top: 0px;
}
.table-sticky thead th {
  position: sticky;
  top: var(--sticky-top);
  background: var(--card);
  z-index: 500;
}
