/* ============================================================
   Lightning-inspired design system
   Plain CSS. No frameworks, no build step.
   ============================================================ */

:root {
  --brand: #0176d3;
  --brand-dark: #014486;
  --brand-light: #e3f3ff;
  --accent: #ff9a3c;
  --success: #2e844a;
  --error: #ba0517;
  --warning: #a86403;

  --bg: #f3f3f3;
  --surface: #ffffff;
  --surface-alt: #fafaf9;
  --border: #c9c9c9;
  --border-soft: #e5e5e5;

  --text: #181818;
  --text-weak: #5c5c5c;
  --text-inverse: #ffffff;

  --radius: 0.25rem;
  --radius-lg: 0.75rem;
  --shadow-1: 0 2px 2px rgba(0, 0, 0, .05);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, .16);
  --shadow-3: 0 8px 24px rgba(0, 0, 0, .18);

  --sidebar-w: 260px;
  --header-h: 52px;

  --font: "Salesforce Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------- Auth / login ---- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--surface);
}

.auth-hero {
  position: relative;
  padding: 3rem 3.5rem;
  color: var(--text-inverse);
  background:
    radial-gradient(120% 120% at 0% 0%, #1b96ff 0%, var(--brand) 45%, var(--brand-dark) 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.auth-hero::after {
  content: "";
  position: absolute;
  right: -140px; bottom: -160px;
  width: 420px; height: 420px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .10);
}

.auth-hero__brand {
  display: flex; align-items: center; gap: .75rem;
  font-weight: 700; letter-spacing: .02em; font-size: 1rem;
}

.auth-hero__mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255, 255, 255, .18);
  display: grid; place-items: center;
  font-size: 1.1rem; font-weight: 700;
  border: 1px solid rgba(255, 255, 255, .35);
}

.auth-hero h2 {
  font-size: 2.25rem;
  line-height: 1.2;
  margin: 2.5rem 0 1rem;
  max-width: 22ch;
}

.auth-hero p { max-width: 46ch; color: rgba(255, 255, 255, .88); margin: 0 0 1.5rem; }

.auth-hero__list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.auth-hero__list li { display: flex; gap: .6rem; align-items: flex-start; color: rgba(255,255,255,.92); }
.auth-hero__list li::before {
  content: "✓";
  flex: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  display: grid; place-items: center; font-size: .7rem;
}

.auth-hero__foot { font-size: .75rem; color: rgba(255, 255, 255, .75); position: relative; z-index: 1; }

.auth-panel {
  display: flex; align-items: center; justify-content: center;
  padding: 2.5rem 1.5rem;
  background: var(--surface-alt);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  padding: 2rem;
}

.auth-card h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
.auth-card__sub { color: var(--text-weak); margin: 0 0 1.5rem; font-size: .875rem; }

/* ------------------------------------------------------------- Forms ----- */
.field { margin-bottom: 1.1rem; }

.field label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-weak);
  margin-bottom: .3rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.control { position: relative; display: flex; align-items: center; }

.control input {
  width: 100%;
  padding: .65rem .75rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.control input::placeholder { color: #9a9a9a; }

.control input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
  outline: none;
}

.control input[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.control--with-action input { padding-right: 3.25rem; }

.control__toggle {
  position: absolute; right: .35rem;
  border: 0; background: transparent;
  color: var(--brand); font: inherit; font-size: .75rem; font-weight: 600;
  padding: .35rem .5rem; cursor: pointer; border-radius: var(--radius);
}
.control__toggle:hover { background: var(--brand-light); }

.field__error {
  display: block;
  min-height: 1rem;
  margin-top: .25rem;
  font-size: .75rem;
  color: var(--error);
}

.field__hint { font-size: .75rem; color: var(--text-weak); margin-top: .25rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1.1rem;
  font: inherit; font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.btn--brand { background: var(--brand); color: #fff; }
.btn--brand:hover { background: var(--brand-dark); text-decoration: none; }

.btn--neutral { background: var(--surface); color: var(--brand); border-color: var(--border); }
.btn--neutral:hover { background: var(--surface-alt); text-decoration: none; }

.btn--block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

.form-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-top: 1.25rem; flex-wrap: wrap;
}

/* -------------------------------------------------------------- Alerts --- */
.alert {
  display: flex; gap: .6rem; align-items: flex-start;
  padding: .7rem .85rem;
  border-radius: var(--radius);
  font-size: .8125rem;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
}
.alert--error   { background: #fdeded; color: #8e0000; border-color: #f5c2c0; }
.alert--success { background: #eaf5ec; color: #1c5c33; border-color: #bfe0c8; }
.alert--info    { background: var(--brand-light); color: var(--brand-dark); border-color: #b8ddf7; }

/* --------------------------------------------------------- App chrome --- */
.app-header {
  position: sticky; top: 0; z-index: 1000;
  height: var(--header-h);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1rem;
  color: #fff;
  background: linear-gradient(90deg, var(--brand-dark), var(--brand));
  box-shadow: var(--shadow-2);
}

.app-header__brand {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 700; color: #fff; white-space: nowrap;
}
.app-header__brand:hover { text-decoration: none; }

.app-header__mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(255, 255, 255, .2);
  display: grid; place-items: center; font-size: .8rem;
}

.app-header__search { flex: 1; max-width: 520px; }
.app-header__search input {
  width: 100%;
  padding: .4rem .75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .16);
  color: #fff; font: inherit;
}
.app-header__search input::placeholder { color: rgba(255, 255, 255, .75); }
.app-header__search input:focus { background: #fff; color: var(--text); outline: none; }
.app-header__search input:focus::placeholder { color: #9a9a9a; }

.app-header__spacer { flex: 1; }

.app-header__actions { display: flex; align-items: center; gap: .5rem; }

.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .65rem;
  font-size: .75rem; font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 999px;
  white-space: nowrap;
}
.pill:hover { text-decoration: none; background: rgba(255, 255, 255, .26); }

.badge {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 .3rem;
  border-radius: 999px;
  font-size: .6875rem; font-weight: 700;
  background: var(--accent); color: #3b1b00;
}

/* Dropdowns (menu button + panel) */
.menu { position: relative; }

.menu__panel {
  position: absolute; right: 0; top: calc(100% + .4rem);
  min-width: 240px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  padding: .5rem;
  display: none;
  z-index: 1200;
}
.menu.is-open .menu__panel { display: block; }

.menu__title { font-size: .75rem; font-weight: 700; color: var(--text-weak); padding: .35rem .5rem; }

.menu__panel ul { list-style: none; margin: 0; padding: 0; }
.menu__panel li a,
.menu__panel li label {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .5rem; border-radius: var(--radius);
  color: var(--text); font-size: .8125rem;
}
.menu__panel li a:hover { background: var(--surface-alt); text-decoration: none; }

.select-plain {
  font: inherit; font-size: .8125rem;
  padding: .3rem .5rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .16);
  color: #fff;
}
.select-plain option { color: var(--text); }

.header-toggle {
  display: none;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .16);
  color: #fff; border-radius: var(--radius);
  padding: .35rem .6rem; cursor: pointer; font: inherit;
}

/* --------------------------------------------------------- Sidebar ------- */
.app-sidebar {
  position: fixed;
  top: var(--header-h); bottom: 0; left: 0;
  width: var(--sidebar-w);
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  padding: .75rem .6rem 2rem;
  z-index: 900;
  transition: transform .25s ease;
}

.nav-section-label {
  font-size: .6875rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-weak);
  padding: .75rem .6rem .35rem;
}

.nav { list-style: none; margin: 0; padding: 0; }
.nav > li { margin-bottom: 2px; }

.nav > li > a,
.nav > li > .nav__toggle {
  width: 100%;
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .7rem;
  border: 0; background: transparent;
  border-radius: var(--radius);
  color: var(--text); font: inherit; font-size: .8125rem; font-weight: 500;
  text-align: left; cursor: pointer;
  border-left: 3px solid transparent;
}

.nav > li > a:hover,
.nav > li > .nav__toggle:hover { background: var(--surface-alt); text-decoration: none; }

.nav__icon { width: 18px; text-align: center; flex: none; color: var(--brand); }
.nav__text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav__count {
  font-size: .6875rem; font-weight: 700;
  background: var(--brand-light); color: var(--brand-dark);
  border-radius: 999px; padding: 1px 7px;
}

.nav > li.is-active > a,
.nav > li.is-active > .nav__toggle {
  background: var(--brand-light);
  border-left-color: var(--brand);
  color: var(--brand-dark);
  font-weight: 700;
}

.nav__caret { transition: transform .2s ease; font-size: .625rem; color: var(--text-weak); }
.nav > li.is-open .nav__caret { transform: rotate(90deg); }

.nav__sub {
  list-style: none;
  margin: 2px 0 6px;
  padding: .25rem 0 .25rem 2rem;
  display: none;
  border-left: 1px dashed var(--border);
  margin-left: 1rem;
}
.nav > li.is-open .nav__sub { display: block; }

.nav__sub a {
  display: block;
  padding: .4rem .6rem;
  border-radius: var(--radius);
  font-size: .8125rem;
  color: var(--text-weak);
}
.nav__sub a:hover { background: var(--surface-alt); color: var(--brand-dark); text-decoration: none; }
.nav__sub a.is-active { color: var(--brand-dark); font-weight: 700; background: var(--brand-light); }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: var(--header-h) 0 0 0;
  background: rgba(0, 0, 0, .4);
  z-index: 890;
}
.sidebar-backdrop.is-visible { display: block; }

/* -------------------------------------------------------- Content -------- */
.app-content {
  margin-left: var(--sidebar-w);
  padding: 1.25rem;
  min-height: calc(100vh - var(--header-h));
}

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

.page-title { font-size: 1.25rem; margin: 0 0 .25rem; }

/* ------------------------------------------------------- Responsive ------ */
@media (max-width: 960px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { padding: 2rem 1.5rem; }
  .auth-hero h2 { font-size: 1.6rem; margin-top: 1.5rem; }
  .auth-hero__list { display: none; }
}

@media (max-width: 880px) {
  .header-toggle { display: inline-block; }
  .app-header__search { display: none; }
  .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-3); }
  .app-sidebar.is-open { transform: translateX(0); }
  .app-content { margin-left: 0; }
  .pill--optional { display: none; }
}

@media (max-width: 520px) {
  .auth-card { padding: 1.25rem; box-shadow: var(--shadow-2); }
  .form-foot { flex-direction: column-reverse; align-items: stretch; }
  .form-foot .btn { width: 100%; }
}

@media print {
  .app-header, .app-sidebar, .sidebar-backdrop { display: none !important; }
  .app-content { margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
