/* Nortrac — shared look, ported from the Next.js app's globals.css tokens.
   Palette: deep green-blue teal on a warm white with a brown undertone, white
   cards, taupe borders and brown-grey secondary text. The logo mark
   (Components/Shared/LogoMark.razor) is a facet-built N (beige #e8dcc4 stems,
   cream #fbf7ef diagonal) on the --accent teal; the colours are in Services/Brand.cs. */
:root {
  --bg: #fcfaf7;
  --surface: #ffffff;
  --surface-2: #f5f0ea;
  --border: #e7ddd2;
  --border-2: #d3c4b3;
  --text: #17292b;
  --text-muted: #6a5d51;
  --text-subtle: #9a8b7d;
  --accent: #0e5c63;
  --accent-hover: #0a474d;
  --accent-dim: rgba(14, 92, 99, 0.1);
  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.08);
  --success: #16a34a;
  --success-dim: rgba(22, 163, 74, 0.08);
  --info: #2563eb;
  --info-dim: rgba(37, 99, 235, 0.08);
  --warning: #d97706;
  --warning-dim: rgba(217, 119, 6, 0.08);
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 16px; margin: 0; }
code { font-size: 12px; background: var(--accent-dim); padding: 1px 6px; border-radius: 4px; }
.muted { color: var(--text-muted); font-size: 13px; }
.subtle { color: var(--text-subtle); font-size: 11px; }

/* Shell — a light sidebar like HOMEBASE app/globals.css (.sidebar, .sidebar-logo,
   .sidebar nav a, .nav-section-toggle): white surface, taupe right border, muted
   links that pick up the accent tint and an accent left border on hover / when active. */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); color: var(--text); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; height: 100dvh; z-index: 40;
}
.sidebar-logo {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 22px 16px 18px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 20px; font-weight: 700; color: var(--accent); letter-spacing: -0.5px; line-height: 1.2;
}
.sidebar-logo p { font-size: 11px; color: var(--text-muted); margin: 3px 0 0; letter-spacing: 0.5px; }
.sidebar-logo > .bell-wrap, .sidebar-logo > .bell { margin-left: auto; }
/* The sidebar bell sits at the sidebar's right edge, so its dropdown has to open
   rightward (app-shell.tsx passes align="left" for the same reason) — anchored
   right it would run off the left of the screen. */
.sidebar .bell-wrap .bell-panel { left: 0; right: auto; }
.sidebar-search { padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.nav { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; padding: 8px 0 12px; }
.nav-section {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text);
  border-top: 1px solid var(--border); margin-top: 8px; padding: 14px 20px 6px;
}
.nav-item {
  display: flex; align-items: center; padding: 8px 20px; margin: 1px 0;
  color: var(--text-muted); font-size: 13px; font-weight: 500; letter-spacing: 0.2px;
  border-left: 2px solid transparent; transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.nav-item:hover { color: var(--text); background: var(--accent-dim); border-left-color: var(--accent); text-decoration: none; }
.nav-item.active { color: var(--accent); background: var(--accent-dim); border-left-color: var(--accent); font-weight: 600; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.who-org { font-size: 12px; font-weight: 700; color: var(--text); line-height: 1.3; margin-bottom: 2px; }
.who-name { font-size: 13px; font-weight: 600; color: var(--text); }
.who-role { font-size: 11px; color: var(--text-muted); word-break: break-all; }
.sidebar .btn-ghost { color: var(--text); border-color: var(--border-2); width: 100%; }
.sidebar .btn-ghost:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.main { padding: 26px 30px; min-width: 0; max-width: 1520px; }

/* Brand block on the sign-in, forgot-password and reset-password cards
   (HOMEBASE auth-card.tsx): the 48 px mark centred above an accent title. */
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .logo-mark { margin: 0 auto 12px; }
.auth-title { font-size: 24px; font-weight: 700; color: var(--accent); line-height: 1.25; }
.auth-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* Under 860 px the sidebar becomes a light top bar: the brand, search and account
   row first, then the navigation as wrapping pills. */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: 10px 14px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .sidebar-logo { padding: 0; border: 0; align-items: center; }
  .sidebar-title { font-size: 18px; }
  .sidebar-logo p { display: none; }
  .sidebar-search { padding: 0; border: 0; }
  /* The navigation takes a full row of its own, under the brand / search / account row. */
  .nav { flex: 1 1 100%; order: 2; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0; }
  .nav-section { display: none; }
  .nav-item { padding: 6px 10px; border-left: 0; border-radius: 7px; margin: 0; }
  .sidebar-foot { order: 1; border: 0; padding: 0; flex-direction: row; align-items: center; margin-left: auto; }
  .sidebar-foot .btn-ghost { width: auto; white-space: nowrap; }
  .who-role { display: none; }
  .main { padding: 16px 14px; }
}

/* Page */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.page-header p { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; max-width: 60ch; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.detail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
.stat-n { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 12px; color: var(--text-muted); }

/* Buttons + inputs */
.btn {
  font: inherit; font-size: 13px; border-radius: 6px; padding: 6px 12px; cursor: pointer;
  border: 1px solid var(--border-2); background: transparent; color: var(--text);
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-outline { border-color: var(--accent); color: var(--accent); }
.btn-ghost:hover { background: rgba(0,0,0,0.04); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.input {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--border-2); border-radius: 6px;
  background: var(--bg); color: var(--text);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.form-error { color: var(--danger); font-size: 13px; margin: 8px 0 0; }
.form-col { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 140px; }

/* Login */
.bare { min-height: 100vh; background: var(--bg); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 26px; box-shadow: var(--shadow); }
.login-foot { font-size: 12px; color: var(--text-subtle); margin: 16px 0 0; }

/* Scheduler */
.tsched-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 1000px) { .tsched-grid { grid-template-columns: repeat(7, 1fr); } }
.day-cell { padding: 10px 12px; min-height: 86px; }
.day-cell.is-today { border-left: 3px solid var(--accent); }
.day-cell.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-dim); }
.entry-list { display: grid; gap: 6px; }
.entry {
  display: flex; align-items: flex-start; gap: 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 9px; cursor: pointer;
}
.entry.conflict { border-color: var(--danger); }
.entry.dragging { opacity: 0.35; }
.entry[draggable="true"] { cursor: grab; }
.grip { color: var(--text-subtle); font-size: 14px; line-height: 1.2; padding: 2px 2px 2px 0; user-select: none; touch-action: none; }
.entry-title, .entry-sub { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-title { font-weight: 600; }
.entry-sub { color: var(--text-muted); }
.entry-dates { display: block; font-size: 10px; color: var(--text-subtle); }
.entry-notes { display: block; font-size: 11px; color: var(--text-muted); font-style: italic; }
.entry-conflict { display: block; font-size: 10px; font-weight: 700; color: var(--danger); }
.month-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.month-head span { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 0 4px; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month-day {
  font: inherit; text-align: left; cursor: pointer; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px; min-height: 76px; color: var(--text);
}
.month-day.is-today { border-color: var(--accent); }
.month-day.is-today .month-n { color: var(--accent); font-weight: 800; }
.month-day.dim { opacity: 0.45; }
.month-n { font-size: 11px; font-weight: 600; }
.month-chips { display: grid; gap: 2px; margin-top: 4px; }
.chip { font-size: 10px; background: var(--accent-dim); border-radius: 4px; padding: 1px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 22, 35, 0.5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 480px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 18px 20px; max-height: 92vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head .x { font: inherit; background: transparent; border: 0; color: var(--text-muted); cursor: pointer; font-size: 16px; }
.modal-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #fff3cd; color: #5c4400; padding: 10px 16px; border-top: 1px solid #e0c46b; z-index: 100; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 14px; top: 10px; }

/* New version / access updated notice — HOMEBASE app/globals.css .upd-*, drawn by
   wwwroot/js/app-updates.js into #app-updates (Components/Layout/AppUpdates.razor).
   The host is the sticky element: it sits at the top of <body>, above the shell. */
#app-updates { position: sticky; top: 0; z-index: 900; }
#app-updates:empty { display: none; }
.upd-bar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px; background: var(--accent); color: #f7f1e6; font-size: 13px; }
.upd-bar.is-news { background: var(--accent-dim); color: var(--text); border-bottom: 1px solid var(--border); }
.upd-text { min-width: 0; }
.upd-new-inline { opacity: .92; margin-left: 4px; }
.upd-actions { display: inline-flex; gap: 6px; align-items: center; }
.upd-btn { font: inherit; background: #f7f1e6; color: var(--accent); border: none; border-radius: 6px; padding: 5px 14px; font-weight: 700; font-size: 12.5px; cursor: pointer; }
.upd-x { font: inherit; background: transparent; border: none; color: inherit; opacity: .8; cursor: pointer; font-size: 14px; padding: 2px 6px; }
.upd-overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(20, 30, 32, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.upd-dialog { background: var(--surface); color: var(--text); border-radius: 14px; padding: 24px; max-width: 420px; width: 100%; box-shadow: var(--shadow); }
.upd-dialog h3 { margin: 0 0 8px; font-size: 18px; }
.upd-dialog p { margin: 0 0 10px; font-size: 14px; line-height: 1.45; }
.upd-dialog .upd-muted { color: var(--text-muted); font-size: 12.5px; }
.upd-dialog .upd-new { background: var(--accent-dim); border-radius: 8px; padding: 8px 10px; }
.upd-dialog .btn { width: 100%; justify-content: center; margin-top: 6px; }

/* 🎤 Speak to Norti (Components/Shared/MicButton.razor, HOMEBASE mic-button.tsx) */
.mic-btn { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 42px; min-height: 38px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--bg); color: var(--accent); cursor: pointer; padding: 0; }
.mic-btn.is-small { width: 38px; min-height: 38px; }
.mic-btn:hover:not(:disabled) { background: var(--accent-dim); }
.mic-btn:disabled { opacity: .5; cursor: default; }
.mic-btn.is-listening { background: var(--danger); border-color: var(--danger); color: #fff; animation: mic-pulse 1.2s ease-in-out infinite; }
.mic-dot { width: 12px; height: 12px; border-radius: 3px; background: #fff; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .45); } 50% { box-shadow: 0 0 0 7px rgba(220, 38, 38, 0); } }
@media (prefers-reduced-motion: reduce) { .mic-btn.is-listening { animation: none; } }
