/* Component: UI-1. Datum SQL Manager console: Little Librarian layout, Forest green product colour.
   Implements: FS-021 */
@font-face { font-family: Mulish; src: url("fonts/Mulish-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Mulish; src: url("fonts/Mulish-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: Mulish; src: url("fonts/Mulish-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: Mulish; src: url("fonts/Mulish-ExtraBold.ttf") format("truetype"); font-weight: 800; font-display: swap; }

:root {
  --green: #0F3B2C;        /* product colour: top bar, table headers, primary buttons */
  --heading: #1B5E45;      /* headings, links */
  --fill: #EAF4EE;         /* zebra rows, active nav, info boxes */
  --orange: #E97132;       /* Datum accent: CTA, platform badge */
  --orange-2: #E27939;
  --page: #F6F8F7;
  --surface: #FFFFFF;
  --text: #17221D;
  --muted: #5B6B64;
  --line: #D5DED9;
  --line-strong: #B4C2BB;
  --danger: #B42318;
  --danger-fill: #FDECEA;
  --mono: "DejaVu Sans Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 400 16px/1.5 Mulish, system-ui, sans-serif; color: var(--text); background: var(--page); -webkit-font-smoothing: antialiased; }
a { color: var(--heading); }
code, .mono { font-family: var(--mono); font-size: .86em; }
.icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 17px; height: 17px; }
[hidden], .hidden { display: none !important; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; height: 62px; display: flex; align-items: center; gap: 14px; padding: 0 16px 0 12px; background: var(--green); color: #fff; }
.topbar .logo { display: flex; align-items: center; gap: 14px; color: #fff; text-decoration: none; }
.topbar .logo img { width: 126px; height: auto; display: block; }
.topbar .product { padding-left: 14px; border-left: 1px solid rgba(255,255,255,.35); font-weight: 700; font-size: 16.5px; letter-spacing: .005em; }
.topbar .spacer { flex: 1; }
.badge-platform { background: var(--orange); color: var(--green); font-weight: 800; font-size: 12.5px; padding: 3px 10px; border-radius: 7px; }
.org-switch { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; color: #fff; font: 700 14px Mulish, sans-serif; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.35); border-radius: 7px; cursor: pointer; }
.org-switch .role { font-weight: 600; opacity: .9; }
.account-btn { display: grid; place-items: center; width: 36px; height: 36px; color: #fff; background: none; border: 0; border-radius: 50%; cursor: pointer; }
.account-btn:hover, .org-switch:hover { background: rgba(255,255,255,.14); }

/* Layout */
.layout { display: grid; grid-template-columns: 276px minmax(0, 1fr); min-height: calc(100vh - 62px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 22px 12px; }
.nav-group { margin: 0 0 18px; }
.nav-title { margin: 8px 12px 8px; font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link { display: flex; align-items: center; gap: 14px; padding: 11px 14px; margin: 2px 0; border-radius: 24px; color: var(--text); text-decoration: none; font-size: 16px; }
.nav-link:hover { background: #F1F6F3; }
.nav-link.active { background: var(--fill); font-weight: 700; color: var(--green); }
.nav-link .state { margin-left: auto; }
.main { padding: 26px 40px 56px; max-width: 1240px; }
.eyebrow { margin: 0 0 2px; font-size: 13px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
h1 { margin: 0 0 22px; font-size: 29px; font-weight: 800; line-height: 1.2; color: var(--heading); }
h1 + .lead { margin-top: -16px; }
.lead { margin: 0 0 22px; color: var(--muted); max-width: 820px; }
h2 { margin: 0 0 14px; font-size: 20px; font-weight: 700; color: var(--heading); }
h3 { margin: 18px 0 10px; font-size: 16px; font-weight: 700; color: var(--heading); }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px 24px; margin: 0 0 20px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card-head .end { margin-left: auto; display: flex; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-2 > .card { margin: 0; }
dl.facts { display: grid; grid-template-columns: 150px 1fr; gap: 6px 16px; margin: 0; font-size: 15px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { background: var(--green); color: #fff; text-align: left; font-weight: 700; padding: 13px 16px; white-space: nowrap; }
td { padding: 13px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:nth-child(even) td { background: var(--fill); }
td .sub { display: block; font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin-top: 1px; }
td .desc { display: block; font-size: 13px; color: var(--muted); }
td a.name { font-weight: 700; }
td.actions { white-space: nowrap; }
table.tight { font-size: 14px; }
table.tight td, table.tight th { white-space: nowrap; padding-left: 12px; padding-right: 12px; }
table.tight td.wrap { white-space: normal; min-width: 120px; }
tbody tr:nth-child(even) td .btn.soft { background: var(--surface); border-color: var(--line); }
td.actions > * + * { margin-left: 8px; }
table.data td, table.data th { font-family: var(--mono); font-size: 13px; padding: 9px 14px; }
table.data th { font-family: Mulish, sans-serif; font-size: 14px; }
td.num, th.num { text-align: right; }

/* Pills and badges */
.pill { display: inline-block; padding: 1px 9px; font-size: 12.5px; font-weight: 700; line-height: 20px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--text); white-space: nowrap; }
.pill.ok { border-color: #8CC5A6; color: #145C3C; }
.pill.warn { border-color: #F0B48F; color: #9A4A1C; background: #FFF6F0; }
.pill.bad { border-color: #F2B8B5; color: var(--danger); background: var(--danger-fill); }
.pill.soft { background: var(--fill); border-color: transparent; color: var(--green); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 15px; font: 700 14px Mulish, sans-serif; color: var(--green); background: var(--surface); border: 1px solid var(--green); border-radius: 999px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #F1F6F3; }
.btn.soft { border-color: transparent; background: var(--fill); }
.btn.soft:hover { background: #DCEDE3; }
.btn.ghost { border-color: transparent; background: none; }
.btn.primary { color: #fff; background: var(--green); border-color: var(--green); }
.btn.primary:hover { background: #164D3A; }
.btn.cta { height: 40px; padding: 0 22px; color: var(--green); background: var(--orange); border-color: var(--orange); font-size: 15px; }
.btn.cta:hover { background: var(--orange-2); }
.btn.danger { color: var(--danger); border-color: #E7A49F; }
.btn.danger:hover { background: var(--danger-fill); }
.btn.block { width: 100%; justify-content: center; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }

/* Forms */
label.field { display: block; margin: 0 0 14px; font-size: 14px; font-weight: 700; }
label.field .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input:not([type]), select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 14px; font: 400 16px Mulish, sans-serif; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(27,94,69,.22); border-color: var(--heading); }
.field-narrow { max-width: 560px; }
textarea.sql { min-height: 196px; font: 14px/1.55 var(--mono); }
td select { display: inline-block; width: auto; margin: 0; padding: 4px 10px; font-size: 14px; }
fieldset { margin: 0 0 14px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; }
legend { padding: 0 6px; font-size: 14px; font-weight: 700; }
label.check { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 15px; }
label.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--green); }

/* Notes, secrets, code */
.note { display: flex; gap: 12px; align-items: flex-start; margin: 16px 0 0; padding: 13px 16px; background: var(--fill); border-left: 4px solid var(--green); border-radius: 6px; font-size: 15.5px; }
.note.warn { background: #FFF6F0; border-left-color: var(--orange); }
.secret { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; background: #F3F6F4; border: 1px solid var(--line); border-radius: 10px; font: 13.5px/1.65 var(--mono); }
.secret pre, .secret code { flex: 1; margin: 0; font: inherit; white-space: pre-wrap; word-break: break-all; }
.secret .btn { height: 30px; font-size: 13.5px; }

/* Sign-in */
.auth-page { min-height: 100vh; display: grid; place-items: center; background: var(--green); padding: 24px; }
.auth-box { width: min(440px, 100%); }
.auth-brand { display: flex; justify-content: center; align-items: center; gap: 12px; margin-bottom: 18px; color: #fff; font-weight: 700; }
.auth-brand img { width: 118px; }
.auth-brand span { padding-left: 12px; border-left: 1px solid rgba(255,255,255,.4); }
.auth-box .card { padding: 26px 28px; }
.auth-box h1 { font-size: 26px; margin-bottom: 6px; }

/* Schema map (database pages) */
.schema-map { display: flex; flex-wrap: wrap; gap: 14px; }
.entity { min-width: 190px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; font-size: 13.5px; background: var(--surface); }
.entity b { display: block; padding: 7px 12px; background: var(--green); color: #fff; font-size: 14px; }
.entity span { display: flex; justify-content: space-between; gap: 18px; padding: 4px 12px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; }
.entity span i { font-style: normal; color: var(--muted); }


/* Menus in the top bar (organization switch, account) */
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; top: 44px; left: 0; z-index: 20; min-width: 260px; padding: 8px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(15,59,44,.18); }
.menu-panel.right { left: auto; right: 0; }
.menu-panel a, .menu-panel button { display: block; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: none; color: var(--text);
  font: 600 15px Mulish, sans-serif; text-align: left; text-decoration: none; cursor: pointer; }
.menu-panel a:hover, .menu-panel button:hover, .menu-panel a.current { background: var(--fill); }
.menu-title { margin: 4px 12px 8px; font-size: 13px; font-weight: 700; color: var(--muted); }

/* Page parts */
.title-row { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.title-row h1 { margin: 0; }
.footer { margin-top: 36px; color: var(--muted); font-size: 13px; }
.notice { margin: 0 0 18px; }
.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.form-row .field { margin-bottom: 0; }
.form-row .grow { flex: 1 1 280px; }
.form-row > .btn { margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
form.inline { display: flex; align-items: center; gap: 8px; }
form.inline select { width: auto; margin: 0; padding: 5px 10px; font-size: 14px; }
pre.code { margin: 12px 0 0; padding: 14px 16px; max-height: 420px; overflow: auto; background: #F3F6F4; border: 1px solid var(--line); border-radius: 10px;
  font: 13px/1.55 var(--mono); white-space: pre-wrap; }
details.draft { margin: 16px 0 0; }
details.draft summary { cursor: pointer; font-weight: 700; color: var(--heading); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 15px; }
.list-row:first-of-type { border-top: 0; }
.table-wrap-js { margin-top: 14px; }
tr.pick { cursor: pointer; }
tr.pick:hover td { background: #DCEDE3; }
.entity small { display: block; padding: 4px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.qr { width: 200px; margin: 6px 0 12px; }
.qr svg { width: 100%; height: auto; display: block; }
.secret pre { min-height: 1.6em; }
#shown-once .secret code { white-space: pre-wrap; }
.btn[disabled] { opacity: .55; cursor: progress; }

/* Spreadsheet drop zone (FS-039) */
.dropzone { display: grid; justify-items: center; gap: 2px; margin: 0 0 12px; padding: 18px 16px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line-strong); border-radius: 12px; background: #FAFCFB; color: var(--heading); }
.dropzone p { margin: 0; }
.dropzone .icon { width: 28px; height: 28px; margin-bottom: 4px; }
.dropzone .link { text-decoration: underline; font-weight: 700; }
.dropzone:hover, .dropzone:focus-visible, .dropzone.over { border-color: var(--heading); background: var(--fill); outline: none; }
.file-list { list-style: none; margin: 0 0 14px; padding: 0; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; margin: 6px 0;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.file-row div { display: grid; min-width: 0; }
.file-row div b, .file-row div span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row.uploading { opacity: .7; }
.file-row.error { border-color: #F2B8B5; background: var(--danger-fill); }
.file-row.error span { color: var(--danger); }

/* Menu drawer on narrow screens (FS-058): hamburger left of the logo, as in Little Librarian */
.nav-toggle, .nav-close { display: none; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px;
  background: none; cursor: pointer; }
.nav-toggle { color: #fff; margin-right: 2px; }
.nav-toggle:hover { background: rgba(255,255,255,.14); }
.nav-close { color: var(--text); margin: -8px 0 8px auto; }
.nav-close:hover { background: #F1F6F3; }
.nav-backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 25; background: rgba(15, 59, 44, .38); }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .main { min-width: 0; max-width: 100vw; }
  .nav-toggle, .nav-close { display: grid; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: min(300px, 86vw); overflow-y: auto;
    border-right: 1px solid var(--line); box-shadow: 0 0 40px rgba(15, 59, 44, .25);
    transform: translateX(-105%); transition: transform .2s ease; visibility: hidden; }
  body.nav-open { overflow: hidden; }
  body.nav-open .sidebar { transform: none; visibility: visible; }
  .main { padding: 20px 16px 40px; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 10px 0 8px; gap: 10px; }
  .topbar .product { display: none; }
  .topbar .logo img { width: 112px; }
  .org-switch .role { display: none; }
  .title-row { flex-wrap: wrap; }
  .form-row > * { flex: 1 1 100%; }
}
@media (max-width: 560px) {
  .badge-platform { display: none; }
  .org-switch { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; line-height: 30px; }
  .org-switch .icon { vertical-align: -4px; margin-right: 6px; }
  .menu-panel { position: fixed; top: 58px; left: 8px; right: 8px; min-width: 0; }
  h1 { font-size: 25px; }
  .card { padding: 18px 16px 20px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
