/* BriefDesk Procurement: enterprise UI. Colours taken from the official Procurement logo. */
:root {
  --navy-900: #0b1f3a; --navy-800: #102a4c; --navy-700: #16365f; --navy-100: #e8eef6;
  --teal-600: #0e8f8f; --teal-500: #14a3a3; --teal-100: #e0f4f4;
  --ink: #1b2533; --ink-2: #4a5566; --ink-3: #6b7686; --line: #dfe4ea; --line-2: #eef1f4;
  --bg: #f5f7fa; --surface: #ffffff;
  --ok: #1f7a4d; --ok-bg: #e6f4ec; --warn: #9a6200; --warn-bg: #fff4dd; --bad: #b3261e; --bad-bg: #fdecea;
  --info: #1d5fa8; --info-bg: #e7f0fb; --neutral-bg: #eef1f4;
  --radius: 8px; --shadow: 0 1px 2px rgba(16, 42, 76, .06), 0 1px 3px rgba(16, 42, 76, .08);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--teal-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--navy-900); margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.muted { color: var(--ink-3); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy-900); color: #c9d5e6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { width: 38px; height: 38px; border-radius: 6px; background: #fff; padding: 2px; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-sub { color: var(--teal-500); font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; }
.nav { padding: 10px 10px 24px; }
.nav-section { margin: 14px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: #7f93b0; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: #c9d5e6; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(20,163,163,.16); color: #fff; box-shadow: inset 3px 0 0 var(--teal-500); }
.nav svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 12px; color: #7f93b0; border-top: 1px solid rgba(255,255,255,.08); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 5; }
.crumbs { display: flex; gap: 6px; align-items: center; color: var(--ink-3); font-size: 13px; flex-wrap: wrap; }
.crumbs a { color: var(--ink-2); }
.crumbs .sep { color: #b3bcc8; }
.who { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.who .org { padding: 3px 10px; border-radius: 999px; background: var(--navy-100); color: var(--navy-800); font-weight: 600; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--teal-600); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.menu-toggle { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--navy-800); }
.content { padding: 24px 28px 48px; max-width: 1400px; width: 100%; }

/* Page header */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Cards / panels */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card, .grid + .card, .card + .grid { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-2); gap: 12px; flex-wrap: wrap; }
.card-body { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--ink-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.kpi .value { font-size: 24px; font-weight: 700; color: var(--navy-900); margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.kpi.kpi-alert .value { color: var(--bad); }

/* Definition lists */
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--ink-3); font-size: 13px; }
.dl dd { margin: 0; word-break: break-word; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .4px; padding: 10px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table tbody tr:hover { background: #fafcfd; }
.table tfoot td { font-weight: 650; background: #fafbfc; }
.table input, .table select { min-width: 90px; }

/* Filters */
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--line-2); align-items: flex-end; }
.filters .field { margin: 0; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 12px; color: var(--ink-3); }
.req::after { content: " *"; color: var(--bad); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=email], input[type=search], input[type=file], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #cdd5df; border-radius: 6px; padding: 8px 10px; width: 100%; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(20,163,163,.35); border-color: var(--teal-500); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--line-2); background: #fafbfc; border-radius: 0 0 var(--radius) var(--radius); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; line-height: 1.2; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-accent { background: var(--teal-600); color: #fff; }
.btn-accent:hover { background: #0c7f7f; }
.btn-secondary { background: #fff; color: var(--navy-800); border-color: #cdd5df; }
.btn-secondary:hover { background: #f4f6f9; }
.btn-danger { background: #fff; color: var(--bad); border-color: #f0c3bf; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--ink-2); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.teal { background: var(--teal-100); color: var(--teal-600); }

/* Alerts */
.alert { padding: 12px 14px; border-radius: 6px; margin-bottom: 16px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert-success { background: var(--ok-bg); border-color: #bfe3cf; color: #145a37; }
.alert-error { background: var(--bad-bg); border-color: #f3c7c3; color: #7f1d17; }
.alert-info { background: var(--info-bg); border-color: #c6dbf3; color: #164a82; }
.alert-warn { background: var(--warn-bg); border-color: #f1d9a6; color: #6d4600; }

/* Empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty svg { width: 40px; height: 40px; color: #b3bcc8; }
.empty h3 { margin-top: 10px; color: var(--ink-2); }

/* Pagination */
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; font-size: 13px; color: var(--ink-3); gap: 12px; flex-wrap: wrap; }
.pager .pages { display: flex; gap: 4px; }
.pager a, .pager span.cur { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); color: var(--ink-2); }
.pager span.cur { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }

/* Steps / timeline */
.steps { display: flex; gap: 0; margin: 0 0 16px; padding: 0; list-style: none; overflow-x: auto; }
.steps li { flex: 1; min-width: 110px; text-align: center; font-size: 12px; color: var(--ink-3); position: relative; padding-top: 22px; }
.steps li::before { content: ""; position: absolute; top: 6px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: #cdd5df; z-index: 1; }
.steps li::after { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: #dfe4ea; }
.steps li:first-child::after { display: none; }
.steps li.done { color: var(--ink-2); }
.steps li.done::before { background: var(--teal-500); }
.steps li.done::after { background: var(--teal-500); }
.steps li.now { color: var(--navy-900); font-weight: 650; }
.steps li.now::before { background: var(--navy-800); box-shadow: 0 0 0 4px rgba(16,42,76,.12); }

/* Dialog */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(11,31,58,.25); }
dialog::backdrop { background: rgba(11,31,58,.45); }
dialog .card-head { border-bottom: 1px solid var(--line-2); }

/* Error page */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.error-card { max-width: 520px; width: 100%; text-align: center; padding: 32px 28px; }
.error-card img { max-width: 260px; width: 100%; margin-bottom: 12px; }
.error-card .code { font-size: 42px; font-weight: 750; color: var(--navy-900); }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; transform: translateX(-100%); transition: transform .2s ease; z-index: 20; }
  body.nav-open .sidebar { transform: none; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px 40px; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
  .who .name { display: none; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
}
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr; } }
.mt { margin-top: 10px; }
.mt-lg { margin-top: 16px; }
.mb { margin-bottom: 12px; }
.w-sm { max-width: 120px; }
.w-md { max-width: 220px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.inline-fields { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.center { justify-content: center; }
.grid > *, .main, .content { min-width: 0; }
.grid > .card, .kpis > .card { margin-top: 0; }
.menu-toggle svg { width: 22px; height: 22px; }

/* Standalone edition: user menu, notifications, sign-in */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nav .count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--teal-500); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.sidebar-foot .mode { color: var(--teal-500); font-weight: 600; }
.bell { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--navy-800); }
.bell:hover { background: var(--line-2); text-decoration: none; }
.bell svg { width: 19px; height: 19px; }
.bell .dot { position: absolute; top: 1px; right: -2px; min-width: 17px; padding: 0 4px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; line-height: 17px; text-align: center; }
.org-switch select { padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--navy-100); color: var(--navy-800); font-weight: 600; font-size: 13px; max-width: 220px; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 2px; border-radius: 999px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:focus-visible { outline: 2px solid var(--teal-500); outline-offset: 2px; }
.user-menu-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16, 42, 76, .14); padding: 6px; z-index: 20; }
.user-menu-panel .um-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; font-size: 13px; }
.user-menu-panel a, .user-menu-panel button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; }
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--line-2); text-decoration: none; }
.notif-list .unread td:first-child { font-weight: 650; }
.notif-list .unread td:first-child::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--teal-500); margin-right: 8px; vertical-align: middle; }
.approval-card { border-left: 3px solid var(--teal-500); }
.link-box { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.link-box input { flex: 1 1 320px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.role-option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.role-option:hover { border-color: var(--teal-500); }
.role-option input { margin-top: 3px; }
.role-option small { display: block; color: var(--ink-3); }
.audit-ctx { min-width: 220px; max-width: 420px; overflow-wrap: anywhere; font-size: 12px; }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: var(--surface); }
.auth-brand { background: linear-gradient(160deg, var(--navy-900) 0%, var(--navy-700) 70%, #11506a 100%); color: #d8e3f1; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-brand .logo-plate { background: #fff; border-radius: 12px; padding: 18px 22px; display: inline-block; max-width: 360px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.auth-brand .logo-plate img { display: block; width: 100%; height: auto; }
.auth-brand .tagline { font-size: 26px; line-height: 1.3; font-weight: 650; color: #fff; margin: 32px 0 10px; max-width: 460px; }
.auth-brand .tagline span { color: var(--teal-500); }
.auth-brand p { max-width: 440px; margin: 0; color: #b4c4d9; }
.auth-brand .foot { font-size: 12px; color: #8ea3bf; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .card-body { padding: 28px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .field { margin-top: 14px; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 20px; }
.auth-card .mobile-logo { display: none; max-width: 220px; margin: 0 auto 18px; }
.pw-rules { margin: 10px 0 0; padding-left: 18px; color: var(--ink-3); font-size: 12px; }
.btn[disabled] { opacity: .65; cursor: progress; }
@media (max-width: 860px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-card .mobile-logo { display: block; }
  .org-switch select { max-width: 130px; }
  .who .org { display: none; }
}
