:root {
  --bg: #eef2f4;
  --card: #ffffff;
  --ink: #1c2a32;
  --muted: #5b6b75;
  --line: #d5dee4;
  --brand: #0f4c5c;
  --brand-2: #1b6b7a;
  --accent: #c36f3c;
  --ok: #1f7a4c;
  --warn: #8a5a00;
  --danger: #9b2c2c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(27, 107, 122, 0.12), transparent 40%),
    linear-gradient(180deg, #e8eef1 0%, var(--bg) 100%);
  color: var(--ink);
  min-height: 100vh;
}

.topbar {
  background: linear-gradient(120deg, var(--brand), #163a45 55%, var(--brand-2));
  color: #fff;
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.02em;
}

.brand-sub {
  display: block;
  font-size: 12px;
  opacity: 0.85;
}

.topbar nav a {
  color: #fff;
  text-decoration: none;
  margin-right: 12px;
  font-size: 14px;
}

.topbar nav a:hover { text-decoration: underline; }

.userbox {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.profile-link {
  color: #fff;
  text-decoration: none;
  font-size: 13px;
}
.profile-link:hover { text-decoration: underline; }


.container {
  max-width: 1100px;
  margin: 20px auto;
  padding: 0 14px 40px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(20, 40, 50, 0.04);
}

.narrow { max-width: 520px; }

/* Login: keep Sign In card centered with a readable minimum size */
body.is-login {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.is-login .container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 24px 16px;
  overflow-x: auto;
}

.login-card {
  width: 100%;
  max-width: 420px;
  min-width: 300px;
  margin: 0;
}

.login-card .form-grid {
  grid-template-columns: 1fr;
}

.login-card .form-grid button {
  width: 100%;
}

.login-card input {
  min-width: 0;
  font-size: 16px;
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.forgot-link {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.forgot-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 14px;
}

.forgot-tab {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #c5d0db;
  background: #f4f7fa;
  color: #334155;
  border-radius: 8px;
  font-weight: 600;
}

.forgot-tab.active {
  background: #1f4e79;
  border-color: #1f4e79;
  color: #fff;
}

#forgot-panel .btn-secondary {
  width: 100%;
  margin-top: 10px;
}

.list-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.list-header h2, .card h2, .card h3 {
  margin: 0 0 8px;
}

.muted { color: var(--muted); font-size: 14px; }
.empty { color: var(--muted); padding: 18px 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

/* Ensure display:grid on .form-grid does not override the hidden attribute */
[hidden] {
  display: none !important;
}

.form-grid label,
.inline-form label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 4px;
  row-gap: 6px;
  font-size: 14px;
}

.form-grid label > input,
.form-grid label > select,
.form-grid label > textarea,
.inline-form label > input,
.inline-form label > select,
.inline-form label > textarea {
  flex: 1 1 100%;
  width: 100%;
}

.form-grid label > .tip,
.inline-form label > .tip {
  flex: 0 0 auto;
}

.form-grid label.check,
.inline-form label.check {
  flex-wrap: nowrap;
}

.form-grid label.check > input[type="checkbox"],
.inline-form label.check > input[type="checkbox"] {
  flex: 0 0 auto;
  width: auto;
}

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

input, select, textarea, button {
  padding: 9px 10px;
  border: 1px solid #b7c4cc;
  border-radius: 6px;
  font: inherit;
}

button, .button-link {
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn-secondary {
  background: #5b6b75;
}

.btn-danger {
  background: var(--danger);
}

.button-link:hover { opacity: 0.92; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 14px;
}

th, td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 10px 8px;
  vertical-align: top;
}

table.compact th, table.compact td {
  padding: 7px 6px;
  font-size: 13px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
  align-items: center;
}

.filters input[type="search"] {
  min-width: 240px;
  flex: 1;
}

.check {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #e7eef1;
  color: var(--brand);
  font-weight: 700;
}

.badge.type-improvement { background: #eef6e8; color: #3d6b2e; }
.badge.type-oar { background: #e7eef1; color: var(--brand); }
.badge.status { background: #f3ebe3; color: #7a4a22; }

.flash {
  margin: 12px auto;
  max-width: 1100px;
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.flash.success { background: #e5f6ec; color: var(--ok); }
.flash.error { background: #fdecec; color: var(--danger); }
.flash.info { background: #eaf3f8; color: var(--brand); }
.flash-close {
  background: transparent;
  color: inherit;
  border: none;
  font-size: 18px;
  padding: 0 6px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
  margin: 0;
}

.detail-grid .full { grid-column: 1 / -1; }
.detail-grid dt {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}
.detail-grid dd { margin: 0; }

.actions, .inline-form, .sign-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.actions .tip {
  margin-left: -2px;
}

.sign-box {
  flex: 1;
  min-width: 220px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
}

.ok { color: var(--ok); }
.notice {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff7e8;
  color: var(--warn);
}
.mt { margin-top: 14px; }
hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

.comment-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.comment-list li {
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.comment-list p { margin: 6px 0 0; }

.whys { margin: 0; padding-left: 18px; }
.supplier-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbfc;
}
.admin-actions {
  border: 1px solid #e2cfcf;
  border-radius: 8px;
  padding: 12px;
  background: #fffafa;
}

.users-table th a {
  color: inherit;
  text-decoration: none;
}
.users-table th a:hover { text-decoration: underline; }

.roles-fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px 12px;
  margin: 0;
}

.roles-fieldset legend {
  padding: 0 6px;
  font-size: 14px;
}

.role-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

/* Compact help tips — hover/focus; JS keeps bubble fully on-screen */
.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  border-radius: 50%;
  border: 1px solid #9aa8b2;
  color: #5b6b75;
  background: #f4f7f8;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
  flex-shrink: 0;
}

.tip:hover,
.tip:focus,
.tip.is-open {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
  outline: none;
}

.tip-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: max-content;
  max-width: min(280px, calc(100vw - 20px));
  padding: 8px 10px;
  border-radius: 6px;
  background: #1c2a32;
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  white-space: pre-line;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 1000;
}

.tip-wide .tip-bubble {
  max-width: min(360px, calc(100vw - 20px));
}

.topbar nav .tip {
  margin-left: 8px;
  vertical-align: middle;
}

.tip-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1c2a32;
}

.tip.is-open .tip-bubble,
.tip:hover .tip-bubble,
.tip:focus .tip-bubble {
  opacity: 1;
  visibility: visible;
}

.tip.tip-below .tip-bubble {
  bottom: auto;
  top: calc(100% + 8px);
}

.tip.tip-below .tip-bubble::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #1c2a32;
}

.tip.tip-align-start .tip-bubble {
  left: 0;
  right: auto;
  transform: none;
}

.tip.tip-align-start .tip-bubble::after {
  left: 10px;
  transform: none;
}

.tip.tip-align-end .tip-bubble {
  left: auto;
  right: 0;
  transform: none;
}

.tip.tip-align-end .tip-bubble::after {
  left: auto;
  right: 10px;
  transform: none;
}

label .tip,
h2 .tip,
h3 .tip,
.badge .tip,
.topbar .tip {
  margin-top: -1px;
}

.topbar .tip {
  border-color: rgba(255, 255, 255, 0.45);
  color: rgba(255, 255, 255, 0.9);
  background: transparent;
}

.topbar .tip:hover,
.topbar .tip:focus,
.topbar .tip.is-open {
  background: #fff;
  color: var(--brand);
  border-color: #fff;
}

@media (max-width: 700px) {
  .topbar { align-items: flex-start; }
  .filters input[type="search"] { min-width: 100%; }
}

