/* LOOM Market Insights - site styles (LOOM brand: docs/BRAND.md). */
:root {
  --bg: #f8fafc; --card: #ffffff; --line: #e2e8f0; --ink: #1e293b; --label: #334155; --muted: #64748b;
  --blue: #1d4ed8; --blue-h: #1e40af; --red: #f05960; --err: #dc2626; --ok: #15803d; --warn: #b45309;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --radius: 10px; --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

/* ---- header + top menu ---------------------------------------------------------------------------- */
.topbar { position: sticky; top: 0; z-index: 50; background: #000; color: #e2e8f0; border-bottom: 3px solid var(--red); }
.topbar-in { display: flex; align-items: center; gap: 18px; padding: 0 20px; min-height: 60px; max-width: 1600px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #e2e8f0; white-space: nowrap; }
.brand img { height: 34px; display: block; }
.brand span { font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #cbd5e1; text-decoration: none; padding: 19px 12px 17px; border-bottom: 3px solid transparent; margin-bottom: -3px;
         white-space: nowrap; font-weight: 500; }
.nav a:hover { color: #fff; }
.nav a.on { color: #fff; border-bottom-color: #fff; }
.nav a.admin { margin-left: auto; }
.userbox { position: relative; }
.userbtn { background: #1e293b; color: #e2e8f0; border: 0; border-radius: 999px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.usermenu { position: absolute; right: 0; top: 42px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
            box-shadow: var(--shadow); min-width: 220px; padding: 6px; }
.usermenu .who { padding: 8px 10px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.usermenu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.usermenu button:hover { background: var(--bg); }
.menu-toggle { display: none; background: none; border: 1px solid #334155; color: #e2e8f0; border-radius: 6px; padding: 6px 10px; }

/* ---- page layout -------------------------------------------------------------------------------- */
main { max-width: 1600px; margin: 0 auto; padding: 22px 20px 60px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 820px; }
.asof { color: var(--muted); font-size: 12px; text-align: right; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card { margin-top: 0; }
.card h2 { margin: 0 0 12px; font-size: 17px; }
.grid { display: grid; gap: 14px; }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
        text-decoration: none; color: var(--ink); display: block; }
a.tile:hover { border-color: var(--blue); }
.tile .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.tile .val { font-size: 26px; font-weight: 700; margin: 4px 0 2px; }
.tile .foot { color: var(--muted); font-size: 12px; text-align: left; padding: 0; }
.tile .so { margin-top: 8px; font-size: 13px; color: var(--label); }
.takeaways { margin: 0; padding-left: 18px; }
.takeaways li { margin: 6px 0; }
.note { color: var(--muted); font-size: 12px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #eef2ff; color: #3730a3; }
.pill.ok { background: #dcfce7; color: #166534; } .pill.bad { background: #fee2e2; color: #991b1b; }
.pill.warn { background: #fef3c7; color: #92400e; } .pill.grey { background: #f1f5f9; color: #475569; }

/* section tabs inside a dashboard */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 0 10px; background: var(--bg); }
.subnav a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--label); text-decoration: none; font-size: 13px; }
.subnav a:hover { border-color: var(--blue); color: var(--blue); }

/* ---- forms, buttons, tables -------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--blue); color: #fff; border: 0; border-radius: 8px;
       padding: 9px 16px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--blue-h); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: #fff; color: var(--label); border: 1px solid var(--line); }
.btn.secondary:hover { border-color: var(--blue); color: var(--blue); }
.btn.danger { background: #fff; color: var(--err); border: 1px solid #fecaca; }
.btn.small { padding: 5px 10px; font-size: 13px; font-weight: 500; }
label { display: block; font-weight: 600; color: var(--label); margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--blue); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 6px 0; color: var(--ink); }
.check input { width: 16px; height: 16px; }
.msg { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.msg.err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.msg.ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; background: #f8fafc; }
.tbl tr:hover td { background: #fafcff; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- sign-in pages ----------------------------------------------------------------------------- */
.auth-wrap { min-height: calc(100vh - 63px); display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth { width: 100%; max-width: 400px; }
.auth h1 { font-size: 22px; margin: 0 0 4px; }
.auth .sub { color: var(--muted); margin: 0 0 8px; }
.auth .btn { width: 100%; justify-content: center; margin-top: 18px; padding: 11px; }
.auth .links { margin-top: 14px; text-align: center; font-size: 13px; }
.linkbtn { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; text-decoration: underline; }
.foot { text-align: center; color: var(--muted); font-size: 11px; padding: 18px 12px; }

/* ---- dialogs ----------------------------------------------------------------------------------- */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog .dlg-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; }
dialog .dlg-body { padding: 4px 20px 16px; max-height: 70vh; overflow: auto; }
dialog .dlg-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.menus-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ---- dashboard frames -------------------------------------------------------------------------- */
.dash-frame { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); display: block; background: #f3f0ee; }
main.dash { padding-bottom: 0; }
.loading { color: var(--muted); padding: 40px; text-align: center; }

@media (max-width: 900px) {
  .brand span { display: none; }
  .menu-toggle { display: inline-block; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 63px; background: #000; flex-direction: column; padding: 6px 12px 12px; }
  .nav.open { display: flex; }
  .nav a { padding: 10px 6px; border-bottom: 1px solid #1e293b; margin: 0; }
  .nav a.admin { margin-left: 0; }
  .topbar-in { position: relative; justify-content: space-between; }
  main { padding: 16px 12px 40px; }
  .menus-grid { grid-template-columns: 1fr; }
}
