* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: ui-sans-serif, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"; background: #f8fafc; color: #0f172a; }
.container { max-width: 980px; margin: 24px auto; padding: 0 16px; }

h1 { font-size: 1.6rem; margin: 0 0 8px; }
.sub { color: #475569; margin: 0 0 18px; }

.form label { display: block; font-weight: 600; margin: 12px 0 8px; }
.form input[type="text"], .form input[type="number"], .form input[type="date"], .form input[type="datetime-local"], .form input[type="email"], .form input[type="tel"], .form select, .form textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; font-size: 14px;
}
.form textarea { resize: vertical; }
/* Focus state for all form fields */
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color:#2563eb; box-shadow: 0 0 0 3px #2563eb22; }
/* Normalize datetime-local appearance across browsers */
.form input[type="datetime-local"] { -webkit-appearance: none; appearance: none; line-height: 1.2; }

.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
/* Adjust breakpoints: use 2 columns on medium screens, 3 on large */
@media (min-width: 720px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(3, 1fr); } }

/* Added utilities */
.kv { display:grid; grid-template-columns: 160px 1fr; gap: 8px 12px; }
@media (max-width: 720px){ .kv { grid-template-columns: 1fr; } }
.grid-2 { display:grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display:grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.subpanel { background:#fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px; }
.muted { color:#64748b; }

.actions { margin-top: 16px; }
button, .button {
  background: #2563eb; color: #fff; border: 0; padding: 10px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .button:hover { background: #1d4ed8; }

.placeholders { background: #eef2ff; border: 1px solid #c7d2fe; padding: 10px; border-radius: 8px; margin-bottom: 12px; }
.placeholders .row { display: flex; gap: 8px; align-items: center; }
.placeholders select { flex: 1; }

.help { margin-top: 8px; }

.meta { color: #64748b; }

/* Layout with sidebar */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } }
/* Single-column layout for pages without sidebar */
.layout.layout--single { grid-template-columns: 1fr; }

.sidebar { background: #0f172a; color: #e2e8f0; padding: 16px; }
.sidebar .logo { font-weight: 700; margin-bottom: 12px; }
/* segmented tab controls within sidebar */
.sidebar-tabs { display:flex; gap:6px; align-items:center; margin-bottom:12px; }
.seg-btn { appearance:none; background:#1e293b; color:#e2e8f0; border:1px solid #334155; border-radius:8px; padding:8px 10px; cursor:pointer; font-size:13px; }
.seg-btn:hover { background:#243244; }
.seg-btn.active { background:#2563eb; border-color:#2563eb; color:#fff; }
.seg-btn--plus { padding:8px 10px; font-weight:700; }
/* Sidebar accordion */
.sb-acc { border: 1px solid #334155; border-radius: 10px; margin-bottom: 10px; }
.sb-acc > summary { list-style:none; cursor:pointer; padding: 10px 12px; background:#1e293b; color:#e2e8f0; border-radius: 10px; font-weight: 600; }
.sb-acc > summary:hover { background:#243244; }
.sb-acc[open] > summary { background:#2563eb; color:#fff; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.sb-acc-body { padding: 8px; display:flex; flex-direction:column; gap:8px; background:#0b1220; border-top: 1px solid #334155; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; }

.tabs { display: flex; flex-direction: column; gap: 8px; }
.tab-btn { appearance: none; background: transparent; border: 1px solid #334155; color: #e2e8f0; padding: 10px 12px; border-radius: 8px; text-align: left; cursor: pointer; }
.tab-btn:hover { background: #1e293b; }
.tab-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }

.content { padding: 16px; }

/* Keep container spacing when used inside main */
/* Replace previous global override with scoped rule */
.content .container { max-width: 980px; margin: 0 auto; padding: 0 24px; }
/* Widen single-column (shared/offboarding) pages */
.layout.layout--single .content .container { max-width: 1400px; padding: 0 32px; }

/* Panes */
.pane { display: none; }
.pane.active { display: block; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.card h3 { margin: 6px 0 4px; font-size: 1rem; }
.card .meta { color: #64748b; margin-bottom: 8px; }
.card .help { margin-top: 6px; }

/* Sub-tabs inside Applications */
.subtabs { display: flex; gap: 8px; margin: 8px 0 12px; }
.subtab-btn { appearance: none; background: #e2e8f0; border: 1px solid #cbd5e1; color: #0f172a; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.subtab-btn:hover { background: #d1d5db; }
.subtab-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.subpane { display: none; }
.subpane.active { display: block; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; }
.table th, .table td { border: 1px solid #e2e8f0; padding: 8px; font-size: 14px; }
.table thead th { background: #f1f5f9; text-align: left; }

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

/* Sections (stacked panels) */
.sections { display: flex; flex-direction: column; gap: 12px; }
.panel { background: #ffffff; border: 1px solid #e2e8f0; border-left: 4px solid #2563eb20; border-radius: 8px; padding: 12px; }
.panel h3 { margin: 4px 0 8px; font-size: 1.05rem; }
.panel .meta { margin-bottom: 6px; }

/* Document previews */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 6px; }
.doc-item { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.doc-thumb { width: 100%; height: 160px; object-fit: cover; border: 1px solid #e2e8f0; border-radius: 6px; background: #fff; }
.doc-pdf iframe { width: 100%; height: 220px; border: 1px solid #e2e8f0; border-radius: 6px; background: #fff; }
.doc-name { font-size: 12px; color: #475569; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Large inline previews */
.doc-grid--large { display: flex; flex-direction: column; gap: 14px; }
.doc-large-img { width: 100%; height: auto; max-height: 75vh; object-fit: contain; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; }
.doc-pdf-large { width: 100%; height: 75vh; border: 1px solid #e2e8f0; border-radius: 6px; background: #fff; }

/* Zoom Modal */
.doc-modal { position: fixed; inset: 0; z-index: 1000; }
.doc-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.6); }
.doc-modal-dialog { position: relative; z-index: 1001; width: min(1100px, 94vw); height: min(86vh, 900px); margin: 7vh auto; background: #ffffff; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.25); display: flex; flex-direction: column; overflow: hidden; }
.doc-modal-close { position: absolute; top: 6px; right: 8px; background: transparent; color: #0f172a; font-size: 22px; border: 0; cursor: pointer; padding: 4px 8px; }
.doc-modal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #e2e8f0; }
.doc-modal-title { font-weight: 600; color: #0f172a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-modal-controls { display: inline-flex; align-items: center; gap: 8px; }
.doc-modal-controls button { background: #e2e8f0; color: #0f172a; border: 1px solid #cbd5e1; border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.doc-modal-controls button:hover { background: #dbe3ea; }
.doc-modal-controls a { background: #2563eb; color: #fff; text-decoration: none; border-radius: 6px; padding: 6px 10px; }
.doc-modal-content { flex: 1; display: flex; align-items: center; justify-content: center; background: #f8fafc; overflow: auto; padding: 8px; }
#docModalImg { max-width: 100%; max-height: calc(86vh - 70px); transform-origin: center center; transition: transform 0.12s ease; }
#docModalFrame { width: 100%; height: calc(86vh - 70px); border: 0; background: #fff; }

/* Doc item actions */
.doc-actions { margin-top: 6px; }
.doc-actions .doc-zoom { background: #334155; border: 0; color: #fff; border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.doc-actions .doc-zoom:hover { background: #1f2937; }

/* Collapsible panels */
details { width: 100%; }
details > summary { list-style: none; cursor: pointer; font-weight: 600; margin: 4px 0 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: '\25BC'; float: right; transition: transform 0.15s ease; color: #64748b; }
details[open] > summary::after { transform: rotate(180deg); }

/* Dropzone styles */
.dropzone { border: 2px dashed #94a3b8; background: #f8fafc; border-radius: 10px; padding: 16px; text-align: center; color: #475569; cursor: pointer; }
.dropzone:hover { background: #f1f5f9; }
.dropzone.dragover { background: #e2e8f0; border-color: #2563eb; color: #0f172a; }
.dropzone p { margin: 0 0 8px; }
.file-list { list-style: none; margin: 8px 0 0; padding: 0; text-align: left; max-height: 160px; overflow: auto; }
.file-list li { font-size: 13px; color: #334155; padding: 2px 0; display: flex; align-items: center; gap: 6px; }
.file-list li::before { content: '\2713'; color: #16a34a; }

/* --- Professional UI additions for Residents pages --- */
/* Toolbar */
.toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; padding: 8px 0; }
.toolbar .title { font-size: 1.25rem; font-weight: 700; }
.toolbar .subtitle { color:#64748b; font-size: 0.95rem; }
.toolbar-actions { display:flex; align-items:center; gap:8px; }

/* Inputs */
.input { width:100%; padding:10px 12px; border:1px solid #cbd5e1; border-radius: 8px; background:#fff; font-size:14px; }
.input:focus { outline: none; border-color:#2563eb; box-shadow: 0 0 0 3px #2563eb22; }
.input--search { min-width: 240px; }

/* Badges & Pills */
.badge { display:inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background:#eef2ff; color:#3730a3; border:1px solid #c7d2fe; }
.pill { display:inline-block; padding: 4px 10px; border-radius:999px; font-size:12px; border:1px solid transparent; }
.pill--active { background:#ecfdf5; color:#065f46; border-color:#a7f3d0; }
.pill--inactive { background:#fff1f2; color:#9f1239; border-color:#fecdd3; }

/* Avatar / Photo */
.avatar { width: 140px; height: 140px; border-radius: 10px; border:1px solid #e2e8f0; background:#f1f5f9; object-fit: cover; display:block; }
.avatar--placeholder { display:flex; align-items:center; justify-content:center; color:#94a3b8; font-weight:600; }

/* Header card */
.header-card { display:grid; grid-template-columns: 160px 1fr; gap: 16px; }
@media (max-width: 760px){ .header-card { grid-template-columns: 1fr; } }
.header-title { display:flex; align-items:center; flex-wrap:wrap; gap:10px; }
.header-meta { display:flex; align-items:center; gap:16px; color:#475569; }
.header-meta .item { display:flex; align-items:center; gap:6px; }

/* Table polish */
.table tr:hover td { background:#f8fafc; }
.table .cell-actions { white-space: nowrap; }

/* Section headings */
.section-title { display:flex; align-items:center; gap:8px; margin: 4px 0 10px; }
.section-title .muted { font-weight: 400; }

/* Buttons – secondary */
.button--secondary { background:#e2e8f0; color:#0f172a; }
.button--secondary:hover { background:#cbd5e1; }
