:root {
  color-scheme: light;
  --brand: #00665f;
  --brand-dark: #004f49;
  --ink: #122a3a;
  --muted: #6b7c82;
  --bg: #f3f8f6;
  --panel: #fff;
  --border: #d9e5e2;
  --success: #2e6e52;
  --danger: #a93133;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 Arial, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 92px 24px 24px; background: var(--bg); }
.auth-brand { display: flex; align-items: center; gap: 11px; color: var(--ink); }
.auth > .auth-brand { position: absolute; top: 0; left: 0; right: 0; height: 68px; padding: 10px clamp(18px, 4vw, 64px); background: #fff; border-bottom: 1px solid var(--border); }
.auth-brand small { display: block; color: var(--muted); font-size: 12px; }
.brand-logo { width: 172px; height: 46px; flex: 0 0 auto; object-fit: contain; }
.auth-card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--border); border-top: 3px solid var(--brand); padding: 32px; box-shadow: 0 2px 8px #0000000a; }
.auth-card h1, .page-head h1 { margin: 5px 0; font-family: Georgia, "Times New Roman", serif; font-size: 30px; font-weight: 400; letter-spacing: -.3px; }
.eyebrow { color: var(--brand); font-size: 11px; font-weight: 700; letter-spacing: 1px; margin: 0; }
.muted { color: var(--muted); }
.auth-card label { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 700; margin: 17px 0; }
.auth-card input, .member-form input, .member-form select, .search { width: 100%; min-width: 0; padding: 10px 11px; border: 1px solid #cfd1d3; border-radius: 2px; outline: none; background: #fff; color: var(--ink); }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 2px #00665f1a; }
.primary, .outline { border-radius: 2px; padding: 10px 14px; font-weight: 700; }
.primary { border: 1px solid var(--brand); background: var(--brand); color: #fff; }
.primary:hover { border-color: var(--brand-dark); background: var(--brand-dark); }
.outline { border: 1px solid #bfc1c4; background: #fff; color: var(--ink); }
.outline:hover { border-color: var(--brand); color: var(--brand); }
.auth-card .primary { width: 100%; padding: 12px; margin: 7px 0 12px; }
.auth-card .outline { width: 100%; margin: 0 0 6px; }
.auth-card a { color: var(--brand-dark); font-weight: 700; display: block; text-align: center; font-size: 13px; text-decoration: none; padding: 8px; }
.auth-card a:hover { text-decoration: underline; }
.message { color: var(--danger); min-height: 20px; font-size: 13px; }
.message.success { color: var(--success); }
.layout { min-height: 100vh; display: flex; flex-direction: column; background: #fff; }
.sidebar { background: #fff; color: var(--ink); padding: 0 clamp(16px, 4vw, 64px); display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; align-items: center; gap: 32px; border-bottom: 1px solid var(--border); }
.sidebar .auth-brand { color: var(--ink); padding: 12px 0; }
.sidebar .auth-brand small { color: var(--muted); }
.sidebar nav { display: flex; align-self: stretch; gap: 3px; }
.nav-link { border: 0; border-bottom: 3px solid transparent; padding: 18px 13px 15px; text-align: left; white-space: nowrap; background: transparent; color: #62656a; font-weight: 600; }
.nav-link:hover, .nav-link.active { color: var(--ink); border-bottom-color: var(--brand); }
.main { width: 100%; max-width: 1600px; padding: 34px clamp(18px, 4vw, 64px); margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.page-head .muted { margin: 5px 0 0; }
.profile-menu { position: relative; align-self: center; justify-self: end; }
.profile-avatar { display: grid; width: 42px; height: 42px; place-items: center; border: 0; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; letter-spacing: .3px; }
.profile-avatar:hover, .profile-avatar[aria-expanded="true"] { background: var(--brand-dark); }
.profile-avatar:focus-visible { outline: 3px solid #00665f40; outline-offset: 3px; }
.profile-menu-panel { position: absolute; z-index: 10; top: calc(100% + 10px); right: 0; display: grid; gap: 6px; width: min(280px, calc(100vw - 28px)); padding: 16px; background: #fff; border: 1px solid var(--border); box-shadow: 0 5px 18px #0000001c; }
.profile-menu-panel b { overflow-wrap: anywhere; }
.profile-menu-panel .muted { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.profile-menu-panel .outline { margin-top: 8px; }
.stats { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { padding: 16px 18px; background: var(--panel); border: 1px solid var(--border); border-top: 2px solid var(--brand); }
.stat span { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat b { display: block; color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: 25px; font-weight: 400; margin-top: 3px; }
.panel { background: var(--panel); border: 1px solid var(--border); padding: 20px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 15px; }
#tab-visits .section-head { flex-wrap: wrap; }
.section-head h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 21px; font-weight: 400; }
.section-head p { margin: 4px 0 0; font-size: 13px; }
.search { max-width: 340px; }
.visit-filters { display: grid; grid-template-columns: minmax(140px, .75fr) minmax(150px, .8fr) minmax(200px, 1.2fr) auto; gap: 8px; width: min(100%, 800px); }
.visit-filters.manager-filters { grid-template-columns: repeat(3, minmax(130px, 1fr)) minmax(180px, 1.4fr) auto; width: min(100%, 1000px); }
.visit-filters .search { max-width: none; }
.visit-filters .outline { white-space: nowrap; }
.table-scroll-hint { display: none; margin: 0 0 8px; font-size: 12px; }
.table-wrap { width: 100%; overflow: auto; }
.table-wrap.note-menu-open { padding-bottom: 90px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { padding: 10px 11px; text-align: left; background: #f4f4f3; color: #55595f; font-size: 11px; font-weight: 700; letter-spacing: .35px; text-transform: uppercase; white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 11px; border-bottom: 1px solid #e8e8e7; font-size: 13px; vertical-align: middle; }
.visit-table { min-width: 1200px; table-layout: fixed; }
.visit-table th, .visit-table td { padding: 10px 8px; white-space: normal; overflow-wrap: anywhere; }
.visit-table .visit-time, .visit-table .visit-person, .visit-table .visit-phone, .visit-table .visit-vehicle { width: 8%; }
.visit-table .visit-unit { width: 5%; }
.visit-table .visit-estate, .visit-table .visit-type, .visit-table .visit-security { width: 6%; }
.visit-table .visit-document { width: 11%; }
.visit-table .visit-flag { width: 7%; }
.visit-table .visit-notes { width: 10%; }
.visit-table .note-cell { min-width: 0; }
tbody tr:hover { background: #fafafa; }
.member-form { display: grid; grid-template-columns: 1.1fr 1.2fr 1fr .8fr .9fr .9fr auto; gap: 8px; margin-bottom: 16px; }
.estate-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-bottom: 16px; }
.estate-form input { width: 100%; min-width: 0; padding: 10px 11px; border: 1px solid #cfd1d3; border-radius: 2px; outline: none; background: #fff; color: var(--ink); }
.contact-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-bottom: 16px; }
#tab-contacts { display: grid; gap: 16px; padding: 0; border: 0; background: transparent; box-shadow: none; }
.directory-card { min-width: 0; padding: 20px; background: var(--panel); border: 1px solid #9fb6af; border-radius: 9px; box-shadow: 0 3px 12px #20354108; }
.security-member-form { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
#caretaker-form { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
.contact-form .primary { min-width: 180px; }
.contact-table { min-width: 480px; table-layout: fixed; }
.contact-table th:first-child { width: 22%; }
.contact-table th:nth-child(2) { width: 39%; }
.caretaker-table th:nth-child(2), .caretaker-table th:nth-child(3) { width: 26%; }
.contact-form input, .contact-form select { width: 100%; min-width: 0; padding: 10px 11px; border: 1px solid #cfd1d3; border-radius: 2px; outline: none; background: #fff; color: var(--ink); }
.member-form .primary { white-space: nowrap; }
.note-cell { position: relative; display: flex; align-items: flex-start; gap: 8px; min-width: 125px; min-height: 32px; }
.note-text { display: flex; flex: 1; flex-direction: column; gap: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-menu-button { flex: 0 0 28px; width: 28px; height: 28px; margin: -4px 0 0 auto; padding: 0; border: 1px solid transparent; border-radius: 2px; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; }
.note-menu-button:hover, .note-menu-button[aria-expanded="true"] { border-color: var(--border); background: #f5f5f4; color: var(--ink); }
.note-menu { position: absolute; z-index: 5; top: 26px; right: 0; min-width: 130px; padding: 4px; background: #fff; border: 1px solid var(--border); box-shadow: 0 3px 10px #00000018; }
.note-menu.above { top: auto; bottom: 26px; }
.note-menu[hidden] { display: none; }
.note-menu button { display: block; width: 100%; padding: 8px 10px; border: 0; background: transparent; color: var(--ink); text-align: left; font-size: 12px; }
.note-menu button:hover:not(:disabled) { background: #f5f5f4; color: var(--brand); }
.note-menu button:disabled { color: #a4a6a8; cursor: not-allowed; }
.note-dialog { width: min(460px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-top: 3px solid var(--brand); color: var(--ink); box-shadow: 0 8px 30px #00000030; }
.delete-member-dialog { border-top-color: var(--danger); }
.delete-confirm { border-color: var(--danger); background: var(--danger); }
.delete-confirm:hover { border-color: #812326; background: #812326; }
.note-dialog::backdrop { background: #22283166; }
.note-dialog form { display: grid; gap: 12px; padding: 22px; }
.note-dialog h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 22px; font-weight: 400; }
.note-dialog label { font-size: 13px; font-weight: 700; }
.note-dialog textarea { min-height: 120px; resize: vertical; padding: 10px; border: 1px solid #cfd1d3; border-radius: 2px; color: var(--ink); font: inherit; }
.note-dialog input { min-width: 0; padding: 10px; border: 1px solid #cbd5d2; border-radius: 6px; color: var(--ink); }
.note-dialog textarea:focus { border-color: var(--brand); outline: 0; box-shadow: 0 0 0 2px #00665f1a; }
.note-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.pill { display: inline-flex; border-radius: 2px; padding: 3px 7px; background: #e7f2ec; color: var(--success); font-size: 11px; font-weight: 700; text-transform: capitalize; }
.pill.off { background: #f7e9e7; color: var(--danger); }
.table-action { border: 1px solid #cfd1d3; border-radius: 2px; padding: 6px 9px; background: #fff; color: var(--ink); font-size: 12px; font-weight: 600; }
.table-action:hover { border-color: var(--brand); color: var(--brand); }
.table-action.flagged, .table-action.delete { border-color: #e2a4a0; color: var(--danger); }
.member-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.empty { padding: 22px; text-align: center; color: var(--muted); }
.toast { min-height: 20px; margin: 12px 0 0; color: var(--danger); }
@media (max-width: 1100px) {
  .sidebar { grid-template-columns: 1fr auto; gap: 0 20px; }
  .sidebar nav { grid-column: 1 / -1; grid-row: 2; overflow-x: auto; }
  .sidebar > .profile-menu { grid-column: 2; grid-row: 1; }
  .nav-link { padding: 12px 13px 10px; }
  .member-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .estate-form { grid-template-columns: minmax(0, 1fr) auto; }
  #tab-visits .section-head { align-items: flex-start; flex-direction: column; }
  .visit-filters.manager-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1360px) {
  .table-scroll-hint { display: block; }
}
@media (max-width: 600px) {
  .auth { padding: 78px 16px 20px; }
  .auth > .auth-brand { height: 58px; padding: 9px 14px; gap: 8px; }
  .brand-logo { width: 132px; height: 36px; }
  .auth-card { padding: 24px; }
  .auth-card h1, .page-head h1 { font-size: 26px; }
  .sidebar { padding: 0 14px; }
  .sidebar .auth-brand { padding: 9px 0; }
  .mark { width: 36px; height: 36px; }
  .sidebar nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0 -14px; padding: 0 8px; }
  .nav-link { padding: 11px 10px 9px; text-align: center; font-size: 12px; }
  .main { padding: 23px 14px; }
  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: 24px; }
  .stats { grid-template-columns: 1fr; gap: 8px; }
  .stat { padding: 12px 14px; }
  .stat b { font-size: 22px; }
  .panel { padding: 15px 12px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .search { max-width: none; }
  .visit-filters { grid-template-columns: minmax(0, 1fr); width: 100%; }
  .visit-filters.manager-filters { grid-template-columns: minmax(0, 1fr); }
  .member-form, .security-member-form, .contact-form, .estate-form, #caretaker-form { grid-template-columns: 1fr; }
  .directory-card { padding: 15px 12px; }
}

/* Refined estate operations visual system */
:root {
  --brand: #176c61;
  --brand-dark: #10564e;
  --ink: #203541;
  --muted: #6c7a80;
  --bg: #f3f5f4;
  --border: #dce3e1;
  --success: #287452;
  --danger: #b74743;
}
body { font-family: Inter, "Segoe UI", Arial, sans-serif; line-height: 1.55; }
.auth-card { border-radius: 8px; box-shadow: 0 12px 32px #2035410c; }
.auth-card h1, .page-head h1 { font-family: Inter, "Segoe UI", Arial, sans-serif; font-weight: 700; letter-spacing: -.45px; }
.primary, .outline { border-radius: 6px; }
.sidebar { box-shadow: 0 2px 8px #20354108; }
.nav-link { color: #647178; }
.main { max-width: 1500px; }
.stat { border-radius: 8px; }
.stat b { font-family: inherit; font-weight: 700; }
.panel { border-radius: 9px; box-shadow: 0 3px 12px #20354108; }
.section-head h2 { font-family: inherit; font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.auth-card input, .member-form input, .member-form select, .contact-form input, .contact-form select, .search, .estate-form input {
  border-color: #cbd5d2; border-radius: 6px; padding: 11px 12px;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px #176c6118; }
th { background: #f1f4f3; color: #526168; }
td { border-bottom-color: #e8edeb; }
tbody tr:hover { background: #f7faf9; }
.note-dialog { border-radius: 8px; box-shadow: 0 8px 30px #20354130; }
.table-action { border-color: #cbd5d2; border-radius: 5px; padding: 7px 10px; }
.pill { border-radius: 20px; padding: 4px 9px; }
.profile-avatar { border-radius: 10px; }
@media (max-width: 600px) {
  .panel { border-radius: 8px; }
  .main { padding-top: 20px; }
}
