/* myaccount application shell — mobile-first */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a1f24;
  --muted: #5c6770;
  --border: #d7dee5;
  --primary: #0b57d0;
  --primary-hover: #0842a0;
  --danger: #b00020;
  --danger-bg: #fdecee;
  --ok-bg: #e8f5e9;
  --focus: #0b57d0;
  --radius: 10px;
  --space: 1rem;
  --max: 72rem;
  --touch: 44px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

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

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

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

.app-shell {
  min-height: 100vh;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.65rem var(--space);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.app-brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  margin-right: auto;
}

.app-brand:hover {
  text-decoration: none;
  color: var(--primary);
}

.app-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.app-user__name {
  color: var(--muted);
  font-size: 0.95rem;
}

.app-main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem var(--space) 2.5rem;
}

/* Mobile nav via details */

.nav-toggle {
  display: block;
}

.nav-toggle > summary {
  list-style: none;
  cursor: pointer;
  min-height: var(--touch);
  min-width: var(--touch);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 600;
}

.nav-toggle > summary::-webkit-details-marker {
  display: none;
}

.nav-panel {
  width: 100%;
  order: 10;
  padding: 0.5rem 0 0.25rem;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-list a,
.nav-list .nav-disabled {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--text);
}

.nav-list a:hover {
  background: #eef3fb;
  text-decoration: none;
}

.nav-list a.active {
  background: #e3edfb;
  color: var(--primary);
  font-weight: 700;
}

.nav-disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.nav-disabled small {
  margin-left: 0.4rem;
  font-size: 0.8rem;
}

.desktop-nav {
  display: none;
}

/* Desktop */

@media (min-width: 961px) {
  .nav-toggle {
    display: none;
  }

  .desktop-nav {
    display: block;
    flex: 1;
  }

  .desktop-nav .nav-list {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.15rem;
  }

  .desktop-nav .nav-list a,
  .desktop-nav .nav-list .nav-disabled {
    min-height: 2.5rem;
    padding: 0.4rem 0.7rem;
  }

  .app-user {
    margin-left: auto;
  }
}

/* ---- Login ---- */

.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space);
}

.login-card {
  width: 100%;
  max-width: 24rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.login-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
}

.login-card .lede {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.login-card .btn {
  width: 100%;
}

/* ---- Typography / cards ---- */

h1 {
  margin: 0 0 0.75rem;
  font-size: 1.6rem;
  line-height: 1.25;
}

h2 {
  margin: 0 0 0.65rem;
  font-size: 1.2rem;
}

.lede,
.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 641px) {
  .grid.grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

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

.card__title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.stat {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: #eef3fb;
  color: var(--text);
  font-size: 0.9rem;
}

.notice {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: #fff8e6;
  border: 1px solid #f0d9a0;
  color: #5c4a12;
}

.alert {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f3c0c8;
}

.alert-ok {
  background: var(--ok-bg);
  border: 1px solid #c5e1c8;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

/* ---- Forms / buttons ---- */

label {
  display: block;
  margin-top: 0.85rem;
  margin-bottom: 0.3rem;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  color: var(--text);
}

input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  margin-right: 0.4rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  margin-top: 0.75rem;
  font-weight: 500;
}

.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover,
button:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

.btn-secondary,
button.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover,
button.btn-secondary:hover {
  background: #f0f3f6;
}

.btn-danger,
button.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: #f3c0c8;
}

.btn-danger:hover,
button.btn-danger:hover {
  background: var(--danger-bg);
}

.btn-linkish,
button.btn-linkish {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

.inline-form input[type="text"] {
  min-width: 10rem;
  flex: 1 1 10rem;
}

.stack {
  margin-top: 1.75rem;
}

.section-title {
  margin-top: 0;
}

/* ---- Tables / mobile cards ---- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.7rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  font-size: 0.85rem;
  color: var(--muted);
  background: #f8fafc;
}

.record-cards {
  display: grid;
  gap: 0.85rem;
}

.record-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.record-card dl {
  margin: 0 0 0.75rem;
}

.record-card dt {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.45rem;
}

.record-card dd {
  margin: 0.1rem 0 0;
  font-weight: 600;
}

/* Mobile: cards on, table off */
@media (max-width: 768px) {
  .table-desktop {
    display: none;
  }
}

/* Tablet/desktop: table on, cards off */
@media (min-width: 769px) {
  .record-cards {
    display: none;
  }
}

.status-active {
  color: #0f6b2e;
  font-weight: 600;
}

.status-archived {
  color: var(--muted);
  font-weight: 600;
}

.future-note {
  margin-top: 1.5rem;
}

@media (min-width: 641px) {
  .grid.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.plain-list {
  margin: 0;
  padding-left: 1.2rem;
}

.plain-list li {
  margin-bottom: 0.45rem;
}

.filters details,
.filters {
  margin-bottom: 1rem;
}

.filter-form {
  display: grid;
  gap: 0.65rem;
}

@media (min-width: 769px) {
  .filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }

  .filter-form button {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

.archive-form {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.archive-form fieldset {
  border: 1px solid #f3c0c8;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin: 0;
}

.checkbox-label {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  margin: 0.35rem 0 0.65rem;
  font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
}

form.stack label {
  display: block;
  margin-top: 0.55rem;
  font-weight: 600;
}

form.stack input,
form.stack select,
form.stack textarea {
  width: 100%;
  max-width: 100%;
}
