:root {
  --navy: #173f65;
  --navy-deep: #102f4d;
  --blue: #2d6699;
  --green: #18845f;
  --red: #c74949;
  --amber: #c8871e;
  --ink: #17222d;
  --muted: #65727e;
  --line: #cbd3da;
  --line-soft: #dde3e8;
  --surface: #ffffff;
  --surface-soft: #f4f6f8;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  color: var(--ink);
  background: #e9edf1;
  font-size: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; background: #e9edf1; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
[hidden] { display: none !important; }

.shell { min-height: 100vh; }
.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 7px clamp(16px, 2.5vw, 38px);
  background: var(--surface);
  border-top: 4px solid var(--navy);
  border-bottom: 1px solid #aeb8c1;
}
.brand { display: flex; align-items: center; gap: 10px; line-height: 1.15; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 2px;
  background: var(--navy);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 900;
}
.brand-copy strong { display: block; font-size: 1.08rem; letter-spacing: -.02em; }
.brand-copy small { display: block; margin-top: 3px; color: #6a7681; font-size: .73rem; letter-spacing: .03em; }
.topbar-status { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.system-clock { color: #62707c; font-size: .78rem; white-space: nowrap; }
.user-tag {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 1px solid var(--line);
  padding: 3px 0 3px 12px;
  color: var(--navy);
  font-size: .8rem;
  font-weight: 700;
  white-space: nowrap;
}

main { width: min(1600px, calc(100% - 24px)); margin: 0 auto; padding: 12px 0 60px; }
.panel {
  background: var(--surface);
  border: 1px solid #b6c0c9;
  border-radius: 3px;
  padding: 24px;
  box-shadow: 0 2px 7px rgba(19, 40, 58, .08);
}
#admin-panel { padding: 0; overflow: hidden; }
.login-panel { max-width: 420px; margin: 7vh auto 0; padding: 30px; }

.workspace-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 90px;
  padding: 17px 22px 14px;
  background: linear-gradient(90deg, #fff 0%, #f5f8fb 100%);
}
.workspace-kicker { margin: 0 0 4px; color: var(--blue); font-size: .68rem; font-weight: 800; letter-spacing: .12em; }
.workspace-heading h1 { margin: 0; font-size: 1.62rem; letter-spacing: -.04em; }
.workspace-meta { margin: 6px 0 0; color: #6b7782; font-size: .78rem; }
.online-badge { display: inline-flex; align-items: center; gap: 7px; border: 1px solid #a8cabd; background: #f3fbf7; color: #17694e; padding: 6px 10px; font-size: .77rem; font-weight: 800; white-space: nowrap; }
.online-badge i { width: 7px; height: 7px; border-radius: 50%; background: #22a06b; box-shadow: 0 0 0 3px #d8f0e6; }

.admin-nav {
  display: flex;
  gap: 0;
  overflow-x: auto;
  margin: 0;
  padding: 0 8px;
  background: #e9edf1;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid #9eabb6;
}
.nav-button {
  min-height: 37px;
  border: 0;
  border-right: 1px solid #c2cad1;
  border-radius: 0;
  background: transparent;
  padding: 8px 16px;
  color: #41515f;
  font-size: .83rem;
  font-weight: 700;
  white-space: nowrap;
}
.nav-button:first-child { border-left: 1px solid #c2cad1; }
.nav-button:hover { background: #f7f9fa; }
.nav-button.active { background: var(--navy); color: #fff; }

.admin-view { min-height: 560px; padding: 20px 22px 28px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.section-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
h1 { margin: 2px 0 5px; font-size: 1.48rem; letter-spacing: -.04em; }
.subhead { margin: 24px 0 8px; padding-left: 9px; border-left: 4px solid var(--navy); font-size: 1rem; }
.eyebrow { margin: 0; color: var(--blue); font-size: .75rem; font-weight: 800; }
.muted, .hint { color: var(--muted); }
.muted { margin: 5px 0; font-size: .8rem; line-height: 1.5; }
.hint { margin: 7px 0 17px; font-size: .78rem; line-height: 1.5; }

.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(125px, 1fr)); gap: 8px; margin: 18px 0 20px; }
.summary-grid > div { min-height: 82px; border: 1px solid var(--line); border-top: 3px solid var(--navy); border-radius: 1px; background: #fff; padding: 12px 13px; }
.summary-grid > div:nth-child(3) { border-top-color: var(--green); }
.summary-grid > div:nth-child(4) { border-top-color: var(--red); }
.summary-grid > div:nth-child(6) { border-top-color: var(--amber); }
.summary-grid span { display: block; color: #5d6b77; font-size: .76rem; }
.summary-grid strong { display: block; margin-top: 7px; color: #101c26; font-size: 1.55rem; font-variant-numeric: tabular-nums; }
.source-breakdown-panel { margin: 18px 0 12px; border: 1px solid #b9c4cd; background: #fff; }
.source-breakdown-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); }
.source-breakdown-grid button { min-height: 86px; border: 0; border-right: 1px solid #d1d9df; background: #fff; color: var(--ink); padding: 11px 13px; text-align: left; }
.source-breakdown-grid button:last-child { border-right: 0; }
.source-breakdown-grid button:hover { background: #edf5fb; box-shadow: inset 0 -3px 0 var(--blue); }
.source-breakdown-grid span, .source-breakdown-grid small { display: block; color: #64727d; font-size: .72rem; }
.source-breakdown-grid strong { display: block; margin: 3px 0; color: var(--navy); font-size: 1.38rem; font-variant-numeric: tabular-nums; }
.expiry-timer-panel { margin: 18px 0 20px; border: 1px solid #b9c4cd; background: #f7f9fa; }
.timer-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 13px; border-bottom: 1px solid #cbd4db; background: #edf1f4; }
.timer-panel-head h2 { margin: 2px 0 0; font-size: 1rem; }
.timer-panel-head > p { margin: 0; color: #52616d; font-size: .78rem; }
.timer-panel-head > p strong { color: var(--navy); font-size: 1rem; }
.timer-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.timer-grid > div { position: relative; min-height: 78px; border-right: 1px solid #d1d9df; border-bottom: 1px solid #d1d9df; background: #fff; color: var(--ink); padding: 10px 13px 9px 17px; text-align: left; }
.timer-grid > div:nth-child(4n) { border-right: 0; }
.timer-grid > div:nth-child(n+5) { border-bottom: 0; }
.timer-grid > div::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: #81909c; }
.timer-grid .timer-unknown::before { background: #7c8790; }
.timer-grid .timer-overdue::before { background: #b93232; }
.timer-grid .timer-30::before { background: #dc643f; }
.timer-grid .timer-60::before { background: #d5962f; }
.timer-grid .timer-90::before { background: #3478ad; }
.timer-grid .timer-year::before { background: #2877a8; }
.timer-grid .timer-two-year::before { background: #3f6f9c; }
.timer-grid .timer-long::before { background: #53697d; }
.timer-grid span, .timer-grid small { display: block; color: #64727d; font-size: .72rem; }
.timer-grid strong { display: block; margin: 3px 0 1px; color: #182733; font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.timer-help { margin: 3px 0 0; border-left: 3px solid #4d7fa8; background: #eef4f8; color: #506474; padding: 8px 10px; font-size: .75rem; line-height: 1.45; }
.structure-guide { margin: 12px 0 4px; border: 1px solid #b8cddd; border-left: 4px solid var(--blue); background: #f2f7fa; color: #455d6e; padding: 10px 12px; font-size: .79rem; line-height: 1.55; }
.structure-guide strong { color: var(--navy); margin-right: 7px; }

form { display: grid; gap: 8px; margin-top: 18px; }
label { margin-top: 5px; color: #263746; font-size: .8rem; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #aeb9c3;
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid #67a4d6; outline-offset: 1px; }
input[type=file] { height: auto; max-width: 100%; padding: 8px; line-height: 1.4; }

.primary, .quiet { border-radius: 2px; font-weight: 700; }
.primary { min-height: 40px; border: 1px solid var(--navy-deep); background: var(--navy); color: #fff; padding: 9px 16px; margin-top: 9px; }
.primary:hover { background: var(--navy-deep); }
.primary.compact { min-height: 34px; margin: 0; padding: 7px 13px; white-space: nowrap; }
.quiet { min-height: 34px; border: 1px solid #aeb8c1; background: #f7f8f9; color: #253a4b; padding: 7px 13px; }
.quiet:hover { background: #e9eef2; }
.link-button { display: block; border: 0; background: transparent; color: #285f91; font-weight: 700; padding: 7px 2px; margin: 5px 0; text-decoration: underline; }
#logout.link-button { display: inline-block; margin: 0; padding: 5px 2px; font-size: .78rem; }

.search-row, .source-search-row { display: grid; gap: 7px; margin: 14px 0 10px; padding: 10px; border: 1px solid var(--line-soft); background: var(--surface-soft); }
.search-row { grid-template-columns: minmax(260px, 560px) auto; justify-content: start; }
.property-search-row { grid-template-columns: minmax(260px, 560px) 180px auto; }
.source-search-row { grid-template-columns: minmax(240px, 1fr) repeat(3, minmax(145px, 180px)) auto; }

.record-list { margin-top: 10px; border: 1px solid #b9c3cc; background: #fff; }
.record-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  border: 0;
  border-bottom: 1px solid #d8dfe5;
  border-radius: 0;
  background: #fff;
  padding: 9px 12px;
}
.record-card:last-child { border-bottom: 0; }
.record-card:nth-child(even) { background: #fafbfc; }
.record-card.clickable { cursor: pointer; }
.record-card.clickable:hover { background: #edf5fb; box-shadow: inset 3px 0 0 var(--blue); }
.record-main { display: grid; grid-template-columns: minmax(150px, .7fr) minmax(240px, 1.7fr); column-gap: 18px; align-items: start; min-width: 0; }
.record-main h3 { grid-column: 1; grid-row: 1 / span 6; margin: 0; color: #182b3b; font-size: .9rem; line-height: 1.45; word-break: keep-all; }
.record-main p { grid-column: 2; margin: 1px 0; color: #5d6974; font-size: .78rem; line-height: 1.35; overflow-wrap: anywhere; }
.badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; max-width: 310px; }
.badge { display: inline-block; border: 1px solid #ced7de; border-radius: 2px; background: #eef2f5; color: #40525f; padding: 3px 6px; font-size: .7rem; white-space: nowrap; }
.badge.alert { border-color: #efc4b1; background: #fff1ea; color: #9d3f1f; }
.badge.good { border-color: #add7c5; background: #e9f7f0; color: #12694c; }
.badge.warning { border-color: #e3c58e; background: #fff7e6; color: #886018; }
.badge.danger { border-color: #e5a5a5; background: #fff0f0; color: #a62828; font-weight: 800; }
.badge.timer { border-color: #aac7df; background: #edf5fb; color: #245b85; }
.badge.muted { color: #75818a; background: #f3f5f6; }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.pager span { color: #50606d; font-size: .78rem; font-weight: 700; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 13px; }
.form-grid label { display: grid; gap: 5px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-section { margin: 4px 0 0; border-bottom: 1px solid #c7d2da; padding: 6px 0; color: var(--navy); font-size: .9rem; }
.form-grid .form-section.wide { grid-column: 1 / -1; }
.form-grid > .primary { justify-self: start; }
.inset { margin: 13px 0; padding: 14px; border: 1px solid #c9d3db; background: #f6f8fa; }
.check-label { grid-template-columns: auto 1fr !important; align-items: center; justify-content: start; }
.check-label input { width: 18px; min-height: 18px; }
.hint-inline { color: var(--muted); font-size: .74rem; }
.owner-summary { margin: 13px 0; padding: 10px 12px; border: 1px solid #c9d5de; border-left: 4px solid var(--blue); background: #f5f8fa; color: #344957; font-size: .8rem; line-height: 1.45; }
.upload-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 7px; margin: 12px 0; padding: 10px; border: 1px solid var(--line-soft); background: var(--surface-soft); }
.upload-row input { min-width: 0; }

.intake-list { display: grid; gap: 9px; margin-top: 14px; }
.intake-card { border: 1px solid var(--line); border-radius: 2px; padding: 12px; background: #fff; }
.intake-card h2 { margin: 0 0 5px; font-size: .94rem; line-height: 1.4; word-break: break-word; }
.intake-card p { margin: 0; color: var(--muted); font-size: .76rem; }
.photo-grid { display: flex; gap: 7px; overflow-x: auto; margin-top: 10px; }
.photo-grid img { width: 145px; height: 112px; border: 1px solid #cfd7dd; border-radius: 2px; background: #eef1f3; object-fit: cover; }
.empty { margin: 0; border: 0; color: #687682; padding: 32px 12px; text-align: center; }
.message { width: min(1600px, calc(100% - 24px)); min-height: 1.2em; margin: 9px auto; color: #a13c27; font-size: .82rem; font-weight: 700; }
.message.success { color: #147053; }
.login-divider { display: flex; align-items: center; gap: 12px; color: #789089; font-size: .76rem; margin: 21px 0 14px; }
.login-divider::before, .login-divider::after { content: ""; height: 1px; background: var(--line-soft); flex: 1; }
#google-button { min-height: 42px; }

@media (min-width: 1180px) {
  .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid .wide { grid-column: span 2; }
  .form-grid .wide:last-of-type { grid-column: 1 / -1; }
}

@media (max-width: 980px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .source-breakdown-grid { grid-template-columns: repeat(3, 1fr); }
  .source-breakdown-grid button { border-bottom: 1px solid #d1d9df; }
  .record-main { grid-template-columns: minmax(130px, .7fr) minmax(200px, 1.5fr); }
}

@media (max-width: 700px) {
  :root { font-size: 15px; }
  .topbar { min-height: 58px; padding: 7px 11px; }
  .brand-mark { width: 29px; height: 29px; }
  .brand-copy strong { font-size: .92rem; }
  .brand-copy small, .system-clock { display: none; }
  .topbar-status { gap: 6px; }
  .user-tag { max-width: 88px; padding-left: 7px; font-size: .72rem; }
  main, .message { width: calc(100% - 12px); }
  main { padding-top: 6px; }
  .panel { padding: 18px 13px; }
  #admin-panel { padding: 0; }
  .login-panel { margin-top: 7vh; }
  .workspace-heading { min-height: 76px; padding: 13px; }
  .workspace-heading h1 { font-size: 1.2rem; }
  .workspace-kicker { font-size: .58rem; }
  .workspace-meta { font-size: .67rem; }
  .online-badge { padding: 5px 7px; font-size: .66rem; }
  .admin-nav { padding: 0; }
  .nav-button { min-height: 40px; padding: 8px 12px; font-size: .76rem; }
  .admin-view { min-height: 480px; padding: 15px 10px 22px; }
  .section-head { align-items: center; gap: 10px; }
  .section-actions { flex-direction: column; align-items: stretch; }
  .section-actions .primary, .section-actions .quiet { min-height: 38px; margin: 0; }
  h1 { font-size: 1.22rem; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .summary-grid > div { min-height: 72px; padding: 10px; }
  .summary-grid strong { font-size: 1.35rem; }
  .timer-grid { grid-template-columns: repeat(2, 1fr); }
  .timer-grid > div { border-right: 1px solid #d1d9df; border-bottom: 1px solid #d1d9df; }
  .timer-grid > div:nth-child(even) { border-right: 0; }
  .timer-grid > div:nth-child(n+7) { border-bottom: 0; }
  .source-breakdown-grid { grid-template-columns: repeat(2, 1fr); }
  .source-breakdown-grid button:nth-child(even) { border-right: 0; }
  .source-breakdown-grid button:last-child { grid-column: 1 / -1; }
  .search-row, .source-search-row, .form-grid, .upload-row { grid-template-columns: 1fr; }
  .source-search-row { padding: 8px; }
  .form-grid .wide { grid-column: auto; }
  .record-card { display: block; padding: 11px 10px; }
  .record-main { display: block; }
  .record-main h3 { margin-bottom: 5px; font-size: .9rem; }
  .record-main p { font-size: .76rem; }
  .badges { justify-content: flex-start; max-width: none; margin-top: 7px; }
  .photo-grid img { width: 128px; height: 100px; }
}
