/* Admin panel, employee portal, paystubs and letters */
[hidden] { display: none !important; }

.app { background: var(--bg); }
.app-bar { background: var(--navy); border-bottom: 4px solid transparent; border-image: linear-gradient(90deg, var(--blue), var(--violet), var(--teal), var(--coral), var(--sun), var(--pink)) 1; color: var(--paper); position: sticky; top: 0; z-index: 20; }
.app-bar-row { max-width: 1200px; margin: 0 auto; padding: 0 20px; min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.app-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700;  }
.app-brand img { max-height: 30px; width: auto; background: var(--paper); padding: 3px 6px; border-radius: 4px; }
.app-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.app-nav a, .app-nav button { color: #C5D2D8; text-decoration: none; padding: 8px 11px; border-radius: 4px; font: inherit; font-size: .95rem; background: none; border: 0; cursor: pointer; }
.app-nav a:hover, .app-nav button:hover { color: var(--paper); background: #22363F; }
.app-nav a.on { background: var(--accent); color: var(--on-accent); font-weight: 600; border-radius: 999px; }
.app-nav form { margin: 0; }
.app .nav-toggle { border-color: #C5D2D8; color: var(--paper); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #D93A2B; color: #fff; font-size: .75rem; text-align: center; line-height: 20px; font-weight: 700; }

.app-main { max-width: 1200px; margin: 0 auto; padding: 32px 20px 80px; }
.page-title { font-size: clamp(1.7rem, 3vw, 2.2rem); margin-bottom: 20px; }
.app h2 { font-size: 1.3rem; }
.section-gap { margin-top: 40px; }
.empty { color: var(--muted); padding: 28px; background: var(--paper); border: 1px dashed var(--line); border-radius: 8px; }
.notice.warn { background: #FFF4D6; color: #6B4A00; }
.notice { margin-bottom: 16px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.toolbar h2 { margin: 0; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); }
.seg a { padding: 6px 14px; text-decoration: none; color: var(--muted); font-size: .92rem; }
.seg a.on { background: var(--ink); color: var(--paper); }
.quick { margin-bottom: 24px; }
.quick form { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stats a { display: grid; gap: 2px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; text-decoration: none; color: var(--muted); }
.stats strong { font-size: 1.6rem; color: var(--ink);  }
.stats small { font-size: .82rem; }
.stats a:hover { border-color: var(--ink); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card-block { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: clamp(18px, 3vw, 28px); margin-bottom: 20px; }
.card-block > h2 { margin-bottom: 6px; }
form.card-block { display: grid; gap: 18px; }
.settings.card-block { margin-top: 0; }

.table-scroll { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.table-scroll .data { border: 0; }
table.data { width: 100%; border-collapse: collapse; background: var(--paper); font-size: .95rem; }
.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: .85rem; padding: 10px 14px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
.data td { padding: 11px 14px; border-bottom: 1px solid var(--tint); vertical-align: top; }
.data tfoot td { font-weight: 700; border-bottom: 0; border-top: 1.5px solid var(--line); }
.data small { color: var(--muted); }
.data tr.dim td { opacity: .55; }
.card-block .data td, .card-block .data th { padding-left: 0; }
.n { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-block; font-size: .8rem; padding: 2px 8px; border-radius: 4px; background: var(--tint); color: var(--muted); font-weight: 600; white-space: nowrap; }
.tag.ok { background: #E3F5EA; color: #145C33; }
.tag.wait { background: #FFF4D6; color: #6B4A00; font-variant-numeric: tabular-nums; }

.access-card { display: grid; grid-template-columns: 1fr 1fr auto; gap: 24px; align-items: start; background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 20px 24px; margin-bottom: 20px; }
.access-card > div { display: grid; gap: 2px; min-width: 0; }
.access-card .big { font-size: 1.15rem; overflow-wrap: anywhere; }
.access-card .code { font-size: 1.5rem; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.access-card small { color: var(--muted); }
.portal .access-card { grid-template-columns: repeat(3, 1fr); }

.field-row.three { grid-template-columns: repeat(3, 1fr); }
label.radio { align-items: flex-start; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius); }
label.radio input { margin-top: 4px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.tpl { display: flex; align-items: center; gap: 10px; padding: 14px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--paper); cursor: pointer; font-weight: 600; }
.tpl input { width: auto; }
.tpl:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.letter-form textarea[name=body] { font-size: 1rem; line-height: 1.6; }
.btn-danger { background: #B42318; border-color: #B42318; color: #fff; }
.btn-danger-text { color: #B42318; border-color: #E4B4AE; }
details.danger { border: 1px solid #E4B4AE; border-radius: 8px; padding: 14px 18px; background: var(--paper); }
details.danger summary { cursor: pointer; color: #B42318; font-weight: 600; }
.preview-title { margin-top: 28px; }
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 24px; margin: 12px 0; }
.details dt { color: var(--muted); font-size: .85rem; }
.details dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.portal-auth .auth-brand { display: block; margin-bottom: 20px; text-decoration: none; }
.portal-auth .auth-brand img { max-height: 48px; width: auto; }
.portal-auth .auth-brand strong { font-size: 1.3rem;  }

/* ---------- Mail ---------- */
.mail { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.mail-nav { display: grid; gap: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.mail-nav .btn { margin-bottom: 8px; }
.mail-nav > a:not(.btn) { padding: 8px 10px; border-radius: 4px; text-decoration: none; color: var(--muted); display: flex; justify-content: space-between; }
.mail-nav > a.on { background: var(--tint); color: var(--ink); font-weight: 600; }
.mail-nav .note { margin: 12px 0 0; overflow-wrap: anywhere; }
.mail-main { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; min-height: 300px; padding: 6px 0; }
.mail-main > .settings, .mail-main > .mail-read, .mail-main > p { padding: 16px 22px; margin: 0; }
.mail-main .empty { border: 0; }
.mail-list { list-style: none; margin: 0; padding: 0; }
.mail-list a { display: grid; grid-template-columns: 200px 1fr auto; gap: 16px; padding: 13px 22px; text-decoration: none; border-bottom: 1px solid var(--tint); color: var(--muted); }
.mail-list a:hover { background: var(--bg); }
.mail-list .who { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-list .subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-list li.unread .who, .mail-list li.unread .subj { font-weight: 700; color: var(--ink); }
.mail-list time { font-size: .88rem; white-space: nowrap; }
.mail-from { color: var(--muted); font-size: .92rem; }
.mail-body { padding: 18px 0; border-top: 1px solid var(--tint); border-bottom: 1px solid var(--tint); margin-bottom: 16px; max-width: 72ch; overflow-wrap: anywhere; }
.mail-read .actions form { margin: 0; }

/* ---------- Documents (paystubs and letters) ---------- */
.doc-frame { overflow-x: auto; padding: 20px; background: var(--tint); border-radius: 8px; }
.doc { background: #fff; color: #111; max-width: 8.5in; margin: 0 auto; padding: .6in .65in; box-shadow: 0 1px 3px rgba(19,35,43,.18); font-size: 13px; line-height: 1.5; }
.doc-page { background: var(--tint); padding: 24px 12px 60px; }
.doc-toolbar { max-width: 8.5in; margin: 0 auto 16px; display: flex; justify-content: space-between; gap: 12px; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 16px; border-bottom: 3px solid var(--ink); }
.doc-brand { display: flex; gap: 14px; align-items: flex-start; }
.doc-brand img { max-height: 48px; max-width: 160px; width: auto; }
.doc-title { text-align: right; }
.doc-title h2 { font-size: 20px; margin: 0; }
.doc-title p { margin: 2px 0 0; color: #4E5F68; }
.stub-meta { display: grid; grid-template-columns: 1.2fr 1fr 1.2fr auto; gap: 16px; padding: 16px 0; border-bottom: 1px solid #C6D1D5; }
.stub-meta span { display: block; color: #4E5F68; font-size: 11.5px; }
.stub-meta strong { display: block; }
.stub-net { background: var(--tint); padding: 8px 14px; border-radius: 4px; text-align: right; }
.stub-net strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.stub-table { width: 100%; border-collapse: collapse; margin-top: 18px; font-variant-numeric: tabular-nums; }
.stub-table th { text-align: left; font-size: 11.5px; color: #4E5F68; font-weight: 600; border-bottom: 1.5px solid #13232B; padding: 5px 6px; }
.stub-table td { padding: 5px 6px; border-bottom: 1px solid #E1E8EA; }
.stub-table small { color: #4E5F68; font-size: 10.5px; }
.stub-table tfoot td { font-weight: 700; border-top: 1.5px solid #13232B; border-bottom: 0; }
.stub-table tr.sub td { color: #4E5F68; }
.stub-summary { max-width: 420px; margin-left: auto; }
.stub-summary tr.net td { font-weight: 800; font-size: 15px; border-top: 2px solid #13232B; border-bottom: 0; }
.doc-note { margin-top: 14px; font-size: 11.5px; color: #4E5F68; }
.doc-foot { margin-top: 28px; padding-top: 10px; border-top: 1px solid #C6D1D5; font-size: 11px; color: #4E5F68; text-align: center; }

.letter { font-size: 14px; line-height: 1.65; min-height: 10in; display: flex; flex-direction: column; }
.letterhead { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding-bottom: 14px; border-bottom: 3px solid var(--accent); }
.letterhead img { max-height: 56px; max-width: 220px; width: auto; }
.lh-name { font-size: 20px;  }
.lh-contact { text-align: right; font-size: 11.5px; color: #4E5F68; display: grid; }
.letter-meta { display: flex; justify-content: space-between; margin: 28px 0 20px; }
.letter-to { margin-bottom: 20px; }
.letter-subject { font-weight: 700; margin-bottom: 18px; }
.letter-body p { margin: 0 0 12px; }
.letter-sign { margin-top: 18px; }
.letter-sign img { max-height: 60px; width: auto; margin: 4px 0; }
.sign-line { width: 220px; height: 44px; border-bottom: 1px solid #13232B; margin-bottom: 8px; }
.letter .doc-foot { margin-top: auto; }

@media print {
  @page { size: letter; margin: 0; }
  body.doc-page { background: #fff; padding: 0; }
  .no-print { display: none !important; }
  .doc { box-shadow: none; max-width: none; margin: 0; padding: .55in .6in; }
  .letter { min-height: 9.9in; }
  .doc { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 900px) {
  .app .nav-toggle { display: inline-block; }
  .app-nav { display: none; position: absolute; left: 0; right: 0; top: 60px; background: var(--ink); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; }
  .app-nav.open { display: flex; }
  .app-nav button { text-align: left; width: 100%; }
  .two-col, .mail { grid-template-columns: 1fr; }
  .access-card, .portal .access-card { grid-template-columns: 1fr; }
  .field-row.three { grid-template-columns: 1fr 1fr; }
  .mail-list a { grid-template-columns: 1fr auto; gap: 2px 12px; }
  .mail-list .subj { grid-column: 1 / -1; grid-row: 2; }
  .stub-meta { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .field-row.three { grid-template-columns: 1fr; }
  .doc { padding: 24px 18px; font-size: 12px; }
  .doc-frame { padding: 8px; }
  .doc-head { flex-direction: column; }
  .doc-title { text-align: left; }
  .letterhead { flex-direction: column; align-items: flex-start; }
  .lh-contact { text-align: left; }
}

/* Address field with a fixed @domain part */
.addr-input { display: flex; align-items: stretch; font-weight: 400; }
.addr-input input { border-radius: var(--radius) 0 0 var(--radius); min-width: 0; }
.addr-input > span { display: flex; align-items: center; padding: 0 12px; background: var(--tint); border: 1.5px solid var(--line); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; color: var(--muted); white-space: nowrap; }
.addr-input > span:first-child { border-left: 1.5px solid var(--line); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.addr-input > span:first-child + input { border-radius: 0 var(--radius) var(--radius) 0; }
.email-edit summary { cursor: pointer; font-weight: 650; }
.email-edit[open] summary { margin-bottom: 4px; }
