/* Base, app shell and shared components. Loaded after Bootstrap 4, so it overrides its defaults. */

html { -webkit-text-size-adjust: 100%; }
@media (pointer: fine) { html { overscroll-behavior: none; } }
a, button, .btn-t, .chip, .tab, input, select, textarea, label { touch-action: manipulation; }
body { -webkit-tap-highlight-color: rgb(47 93 84 / 0.12); }
.skip-link { position: absolute; left: 16px; top: -48px; z-index: 100; padding: 8px 14px; border-radius: var(--radius); background: var(--primary); color: var(--primary-ink); font-weight: 500; }
.skip-link:focus { top: 12px; color: var(--primary-ink); }
.app-main:focus { outline: none; }
h1, h2, h3 { text-wrap: balance; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: inherit; }
a:hover { color: inherit; text-decoration: none; }
h1, h2, h3 { color: var(--ink); margin: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tabular { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.text-muted-ink { color: var(--ink-muted); }
.text-subtle { color: var(--ink-subtle); }
.sr-only-focusable:focus { position: static; }
[data-lucide], svg.lucide { width: 18px; height: 18px; stroke-width: 1.8; flex-shrink: 0; }

/* ---------------------------------------------------------------------------------------------- */
/* App shell                                                                                        */
/* ---------------------------------------------------------------------------------------------- */

.app-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); z-index: 40;
  display: flex; flex-direction: column; padding: 28px 16px 16px;
  background: var(--sidebar); border-right: 1px solid var(--border);
  overflow-y: auto;
}
.app-main { margin-left: var(--sidebar-width); min-height: 100vh; }
.app-topbar { display: none; }
.app-backdrop { display: none; }

.brand { display: flex; align-items: center; gap: 12px; padding: 0 12px; }
.brand-word { font-size: 26px; line-height: 1; font-weight: 600; letter-spacing: 0.12em; }
.brand-sub { font-size: 11px; line-height: 1.3; color: var(--ink-subtle); }

.side-nav { margin-top: 36px; display: flex; flex-direction: column; gap: 4px; }
.side-link {
  display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: var(--radius);
  font-size: 15px; transition: background-color 0.15s;
}
.side-link:hover { background: rgb(255 255 255 / 0.7); }
.side-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }

.side-section { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.side-label { padding: 0 12px; font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-subtle); }
.portfolio { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.portfolio-link { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius); transition: background-color 0.15s; }
.portfolio-link:hover { background: rgb(255 255 255 / 0.7); }
.portfolio-link.active { background: var(--surface); box-shadow: var(--shadow-card); }
.portfolio-name { display: block; font-size: 14px; font-weight: 500; }
.portfolio-meta { display: block; font-size: 13px; color: var(--ink-subtle); }
.side-add {
  margin-top: 8px; width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 0; background: none; border-radius: var(--radius); color: var(--ink-muted); font-size: 14px; text-align: left;
}
.side-add:hover { background: rgb(255 255 255 / 0.7); color: var(--ink); }

.user-menu { margin-top: auto; padding-top: 24px; }
.user-trigger {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px; border: 0; background: none;
  border-radius: var(--radius); text-align: left;
}
.user-trigger:hover, .user-trigger[aria-expanded="true"] { background: rgb(255 255 255 / 0.7); }
.avatar {
  width: 40px; height: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 1px var(--border);
  font-size: 14px; font-weight: 500; color: var(--ink-muted);
}
.user-name { display: block; font-size: 15px; font-weight: 500; }
.user-workspace { display: block; font-size: 12px; color: var(--ink-subtle); }

/* Building thumbnail (photo or calm placeholder). */
.thumb { flex-shrink: 0; border-radius: var(--radius-sm); object-fit: cover; display: block; }
.thumb-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-soft), var(--tint-slate)); color: rgb(47 93 84 / 0.55);
}
.thumb-sm { width: 44px; height: 44px; }
.thumb-md { width: 40px; height: 40px; }

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-overlay); max-width: 85vw; overscroll-behavior: contain;
    padding-top: max(28px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  body.nav-open .app-sidebar { transform: none; }
  body.nav-open .app-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgb(28 35 32 / 0.2); }
  .app-main { margin-left: 0; }
  .app-topbar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30; height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    background: rgb(250 250 248 / 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  }
  .app-topbar .brand { padding: 0; }
  .app-topbar .brand-word { font-size: 20px; }
}

/* ---------------------------------------------------------------------------------------------- */
/* Components                                                                                       */
/* ---------------------------------------------------------------------------------------------- */

.btn-t {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: background-color 0.15s, border-color 0.15s;
}
.btn-t:hover { border-color: var(--border-strong); background: var(--surface-muted); color: var(--ink); }
.btn-t:disabled { opacity: 0.5; pointer-events: none; }
.btn-t [data-lucide], .btn-t svg { width: 16px; height: 16px; }
.btn-t.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow-card); }
.btn-t.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-ink); }
.btn-t.ghost { background: none; border-color: transparent; color: var(--ink-muted); }
.btn-t.ghost:hover { background: var(--surface-muted); color: var(--ink); }
.btn-t.lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-t.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-t.icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }

.badge-t {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--tone-bg, var(--surface-muted)); color: var(--tone-ink, var(--ink-muted));
}

.event-icon {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--tone-bg); color: var(--tone-ink);
}
.event-icon svg { width: 20px; height: 20px; stroke-width: 1.9; }
.event-icon.sm { width: 28px; height: 28px; }
.event-icon.sm svg { width: 14px; height: 14px; }
.event-icon.md { width: 36px; height: 36px; }
.event-icon.md svg { width: 18px; height: 18px; }

.page { max-width: 1152px; margin: 0 auto; padding: 40px 32px; }
.page-header { margin-bottom: 36px; }
.page-title { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.page-subtitle { margin-top: 4px; color: var(--ink-muted); }
@media (max-width: 575.98px) { .page { padding: 28px 16px; } }

.section { display: flex; flex-direction: column; gap: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.section-title svg { width: 16px; height: 16px; color: var(--ink-subtle); }
.section-link { font-size: 14px; color: var(--primary); }
.section-link:hover { color: var(--primary); text-decoration: underline; }
.grid-2 { display: grid; gap: 40px 48px; }
@media (min-width: 992px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 48px 24px; border: 1px dashed rgb(216 215 208 / 0.8); border-radius: var(--radius-lg);
}
.empty-state svg { width: 24px; height: 24px; color: var(--ink-subtle); margin-bottom: 12px; }
.empty-title { font-weight: 500; }
.empty-body { margin-top: 4px; max-width: 380px; font-size: 14px; color: var(--ink-muted); }
.muted-note { font-size: 14px; color: var(--ink-subtle); margin: 0; }

.card-t { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }

/* Compact event rows (dashboard, overview, issues, maintenance). */
.row-list { list-style: none; margin: 0 -12px; padding: 0; }
.event-row { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: var(--radius); transition: background-color 0.15s; }
.event-row:hover { background: var(--surface); }
.event-row-main { min-width: 0; flex: 1; }
.event-row-title { display: block; font-size: 14px; font-weight: 500; }
.event-row-meta { display: block; font-size: 13px; color: var(--ink-subtle); }
.event-row-date { width: 104px; flex-shrink: 0; text-align: right; font-size: 13px; color: var(--ink-muted); }
.event-row-date.overdue { color: var(--danger); font-weight: 500; }
.clip { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-subtle); }
.clip svg { width: 14px; height: 14px; }
@media (max-width: 575.98px) { .event-row .hide-xs { display: none; } }

/* Forms */
.form-t { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 500; color: var(--ink-muted); margin: 0; }
.field-hint { font-size: 13px; color: var(--ink-subtle); }
.field-error { font-size: 13px; color: var(--danger); }
.input-t {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-size: 14px; transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input-t { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.6; resize: vertical; }
select.input-t {
  appearance: none; padding-right: 36px;
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a908c' stroke-width='2' viewBox='0 0 24 24'><path d='m6 9 6 6 6-6'/></svg>") no-repeat right 12px center;
}
.input-t:hover { border-color: var(--border-strong); }
.input-t:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgb(47 93 84 / 0.28); }
.input-t.is-invalid { border-color: var(--danger); }
.form-error { padding: 8px 12px; border-radius: var(--radius); background: var(--tint-rose); color: var(--ink-rose); font-size: 14px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary); font-size: 14px; font-weight: 500; align-self: flex-start; }
.link-btn:hover { text-decoration: underline; }

/* Bootstrap modal, restyled. */
.modal-backdrop.show { opacity: 1; background: rgb(28 35 32 / 0.2); backdrop-filter: blur(2px); }
.modal-content { border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-overlay); }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.modal-title { font-size: 17px; font-weight: 600; }
.modal-subtitle { margin: 2px 0 0; font-size: 14px; color: var(--ink-muted); }
.modal-body { padding: 20px 24px; overscroll-behavior: contain; }
.modal { overscroll-behavior: contain; }
@media (min-width: 768px) { .modal-dialog.modal-wide { max-width: 720px; } }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); gap: 8px; }
.modal-footer > * { margin: 0; }
.modal-close { border: 0; background: none; padding: 6px; margin: -4px -8px 0 0; border-radius: var(--radius-sm); color: var(--ink-subtle); }
.modal-close:hover { background: var(--surface-muted); color: var(--ink); }
@media (min-width: 576px) { .modal-dialog { max-width: 576px; margin-top: 8vh; } }

/* Dropdown menu, restyled. */
.dropdown-menu { min-width: 240px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-overlay); }
.dropdown-header { padding: 6px 10px 4px; font-size: 12px; font-weight: 500; color: var(--ink-subtle); white-space: normal; }
.dropdown-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); font-size: 14px; color: var(--ink); background: none; border: 0; width: 100%; }
.dropdown-item svg { width: 16px; height: 16px; color: var(--ink-subtle); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-muted); color: var(--ink); }
.dropdown-item .check { margin-left: auto; color: var(--primary); }
.dropdown-divider { margin: 6px 0; border-color: var(--border); }

/* Auth pages */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 48px 16px; }
.auth-box { width: 100%; max-width: 384px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 40px; text-align: center; }
.auth-tagline { max-width: 300px; font-size: 14px; color: var(--ink-muted); }
.auth-card { padding: 32px; }
.auth-title { font-size: 20px; font-weight: 600; margin-bottom: 24px; }
.auth-switch { margin-top: 4px; text-align: center; font-size: 14px; color: var(--ink-muted); }
.auth-switch a { color: var(--primary); font-weight: 500; }
.auth-languages { margin-top: 24px; display: flex; justify-content: center; gap: 16px; font-size: 13px; }
.auth-languages a { color: var(--ink-subtle); }
.auth-languages a.active { color: var(--ink); font-weight: 500; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
