/* Modern Luxury: pearl white, midnight navy, and champagne gold. */
:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #eeeff3;
  --surface-hover: #e5e8ef;
  --text: #1c2c46;
  --muted: #606b7c;
  --border: #dce0e8;
  --green: #233d63;
  --dark: #172c4a;
  --accent: #795e2e;
  --accent-soft: #f0e8d9;
  --accent-border: #c7b48a;
  --selected: #e6ebf4;
  --selected-text: #2c456c;
  --success: #42623c;
  --success-bg: #e7eddf;
  --warning: #825d22;
  --warning-bg: #f4e9d3;
  --danger: #a04437;
  --ring: #988050;
  --ring-track: #e8ebf1;
  --primary-text: #ffffff;
  --primary-hover: #172c4a;
  --shadow: 0 3px 14px #172c4a0a;
  --shadow-raised: 0 8px 24px #172c4a18;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1626;
  --surface: #172237;
  --surface-soft: #1e2b42;
  --surface-hover: #293850;
  --text: #eef1f7;
  --muted: #aab6ca;
  --border: #33425b;
  --green: #c2d1eb;
  --dark: #dce5f5;
  --accent: #dfc79c;
  --accent-soft: #302d2a;
  --accent-border: #807052;
  --selected: #293b58;
  --selected-text: #d9e5fa;
  --success: #bed7ae;
  --success-bg: #2b3f2c;
  --warning: #e3c183;
  --warning-bg: #3c3221;
  --danger: #f0a99b;
  --ring: #cfb585;
  --ring-track: #2d3b52;
  --primary-text: #15243c;
  --primary-hover: #d8e3f5;
  --shadow: 0 3px 14px #00000018;
  --shadow-raised: 0 8px 24px #00000030;
}

body { background: var(--bg); color: var(--text); }
aside, header, .stat, .room, .panel, .table-wrap, .donut-inner, dialog, .modal-actions {
  background: var(--surface);
  color: var(--text);
}
aside, header, .workspace, .stat, .room, .panel, .table-wrap, .coverage-note, dialog, td {
  border-color: var(--border);
}
.stat, .room, .panel, .table-wrap { box-shadow: var(--shadow); }
.room:hover { box-shadow: var(--shadow-raised); }
.brand, header strong, td:first-child, .room-meta b { color: var(--text); }
.brand-icon { background: #203858; color: #f2e7d0; box-shadow: inset 0 0 0 1px #dfc79c26; }
.brand-dot, .eyebrow, .peace>span, .claim-banner>span, .stat-label span { color: var(--accent); }
p, small, header, .nav-label, nav button, .peace p, .stat-label, .stat small,
.room-meta, .legend span, td, th, .empty, label, .modal-header button,
.inventory-switch>span, .mode-note, footer { color: var(--muted); }
.saved, .saved:first-letter, .stat small em { color: var(--success); }
.home-icon, .peace, .item-thumb, .checklist, th { background: var(--surface-soft); }
.peace { border-color: var(--border); }
.avatar { background: var(--accent-soft); color: var(--accent); }
nav button:hover { background: var(--surface-hover); color: var(--text); }
nav button.active { background: var(--selected); color: var(--selected-text); box-shadow: inset 3px 0 0 var(--accent); }
nav b { background: var(--surface-soft); color: var(--selected-text); }
nav i { background: var(--accent); }
.button, .menu-toggle {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.button:hover, .menu-toggle:hover { background: var(--surface-hover); }
.button.primary { background: var(--green); color: var(--primary-text); border-color: var(--green); box-shadow: var(--shadow); }
.button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.mode-tabs .selected, .menu-toggle[aria-expanded="true"] { background: var(--selected); color: var(--selected-text); border-color: var(--accent-border); }
.text-button, .attachment { color: var(--green); }
.text-button:hover { color: var(--accent); }
.remove-item { color: var(--danger); }
.stat:first-child {
  background: linear-gradient(125deg, #14253e, #2b4367);
  color: #fff8e8;
  border-color: #435775;
  box-shadow: 0 5px 20px #14253e26;
}
.stat:first-child .stat-label, .stat:first-child small { color: #d0d9e8; }
.stat:first-child .stat-label span { color: #dfc79c; }
.stat:first-child .stat-value { color: #fff8e8; }
.room-photo { background-color: var(--surface-soft); }
.room-icon { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.badge { background: var(--success-bg); color: var(--success); }
.badge.amber, #install-local-note { background: var(--warning-bg); color: var(--warning); }
.tip { background: var(--accent-soft); border-color: var(--accent-border); }
.tip .eyebrow { color: var(--accent); }
.claim-banner { background: var(--surface-soft); border-color: var(--border); }
.toolbar input, .toolbar select, label input, label select, label textarea {
  background: var(--surface); color: var(--text); border-color: var(--border);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input, select, textarea { accent-color: var(--green); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
dialog { box-shadow: 0 20px 80px #00000040; }
dialog::backdrop { background: #080f1ec2; }
#toast { background: var(--green); color: var(--primary-text); box-shadow: var(--shadow-raised); }
::selection { background: var(--accent-soft); color: var(--text); }

.theme-switch { display: flex; flex-shrink: 0; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-soft); }
.theme-switch button { display: flex; align-items: center; justify-content: center; gap: 5px; padding: 7px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 11px; min-height: 30px; }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.theme-switch button:hover { color: var(--text); }
.theme-switch svg { width: 15px; height: 15px; flex-shrink: 0; }
.theme-switch .theme-label { margin: 0; }
.header-right { gap: 12px; }
.custom-room-photo { display: grid; place-items: center; background: linear-gradient(130deg,var(--selected),var(--surface-soft)); }
.custom-room-photo>.room-symbol { font-size: 54px; color: var(--accent); }
.room-info strong { overflow-wrap: anywhere; }
.room-add-inline { align-self: flex-start; padding: 9px 0; }
#room-dialog { width: 440px; }
#room-dialog p { font-size: 12px; line-height: 1.7; }
#room-error { color: var(--danger); }
.page-heading { align-items: flex-start; gap: 20px; }
.actions { flex-wrap: wrap; justify-content: flex-end; max-width: 460px; }
.attachment-editor { grid-column: 1 / -1; border: 1px solid var(--border); border-radius: 8px; padding: 12px; min-width: 0; }
.attachment-editor input { width: 100%; }
.attachment-editor small { line-height: 1.7; }
.attachment-preview { display: block; max-width: 100%; max-height: 260px; object-fit: contain; margin: 12px auto; border-radius: 6px; }
.attachment-editor .attachment { display: inline-block; padding: 8px 0; }
.attachment-editor .remove-item { display: block; padding: 10px 0; }
.form-error { color: var(--danger); font-size: 12px; line-height: 1.6; }
.backup-summary { font-size: 13px; line-height: 1.8; padding: 12px; background: var(--surface-soft); border-radius: 8px; }
.restore-confirm { flex-direction: row; align-items: flex-start; line-height: 1.7; gap: 10px; }
.restore-confirm input { margin-top: 3px; width: 20px; height: 20px; flex-shrink: 0; }
#backup-dialog .modal-actions { flex-wrap: wrap; }
@media(max-width:950px) { .actions { justify-content: flex-start; max-width: none; } }
@media(max-width:650px) {
  .actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); width: 100%; gap: 8px; }
  .actions .button { min-height: 44px; padding: 10px 8px; }
  #add { grid-column: 1 / -1; }
  #toast { max-width: calc(100vw - 24px); width: max-content; bottom: max(20px,env(safe-area-inset-bottom)); }
  .stat-value { font-size: clamp(22px,6vw,30px); overflow-wrap: anywhere; }
  .toolbar input,.toolbar select { max-width: 100%; min-width: 0; }
  .modal-actions .button { min-height: 44px; }
}
.profile-button { width: 100%; border: 0; background: transparent; color: var(--text); text-align: left; padding: 12px 0; margin-top: 12px; border-radius: 8px; }
.profile-button:hover { background: var(--surface-hover); }
.profile-button .avatar { flex-shrink: 0; }
.profile-copy { min-width: 0; }
.profile-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
nav .mobile-profile-trigger { display: none; }
#profile-dialog { width: 440px; }
#profile-dialog p { font-size: 12px; line-height: 1.7; }
#profile-error { color: var(--danger); }
@media(max-width:1150px) { .header-right .saved { display: none; } }
@media(max-width:650px) {
  nav .mobile-profile-trigger { display: flex; }
  header { height: auto; min-height: 62px; gap: 8px; flex-wrap: wrap; padding: 8px 15px; }
  .header-right { gap: 8px; margin-left: auto; }
  .header-right>.avatar { display: none; }
  .theme-switch .theme-label { display: none; }
  .theme-switch button { width: 36px; min-height: 36px; padding: 8px; }
  .theme-switch svg { width: 17px; height: 17px; }
  .theme-switch { padding: 2px; }
  #install-app { min-height: 42px; }
}

#activation-dialog { width: 500px; }
#activation-dialog p { font-size: 13px; line-height: 1.7; }
#activation-code { width: 100%; min-width: 0; overflow-wrap: anywhere; font-size: 16px; }
#activation-dialog .activation-help { color: var(--muted); font-size: 12px; }
#activation-dialog .modal-actions { flex-wrap: wrap; }
#activation-open { min-height: 44px; }
.inventory-switch { flex-wrap: wrap; }

/* Let cards shrink to the viewport; wide inventory tables scroll inside their wrapper. */
.shell, main, #content, .overview-grid > *, .right-column > *,
.stats > *, .rooms > *, .page-heading > *, .recent, .panel { min-width: 0; }
.stats { grid-template-columns: minmax(0,1.3fr) repeat(3,minmax(0,1fr)); }
.rooms { grid-template-columns: repeat(3,minmax(0,1fr)); }
.table-wrap { min-width: 0; max-width: 100%; width: 100%; overflow-x: auto; }
.stat-label { gap: 8px; }
.stat-label span { flex-shrink: 0; }
.stat-value, .stat small, .room-info { overflow-wrap: anywhere; }
.room-meta { flex-wrap: wrap; gap: 4px 8px; }
.section-heading { flex-wrap: wrap; gap: 8px 12px; }
.legend { flex-wrap: wrap; gap: 4px 8px; }
@media(max-width:950px) {
  .overview-grid { grid-template-columns: minmax(0,1fr); }
  .stats, .right-column { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media(max-width:650px) {
  .rooms { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .right-column { grid-template-columns: minmax(0,1fr); }
  .mode-tabs, .inventory-switch, .toolbar { min-width: 0; max-width: 100%; }
  .mode-tabs .button { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  .claim-banner > div { min-width: 0; flex: 1 1 180px; }
  .claim-banner button { white-space: normal; max-width: 100%; margin-left: 0; }
}
@media(max-width:480px) {
  .rooms { grid-template-columns: minmax(0,1fr); }
  .room-photo { height: 170px; }
  .room-info { padding: 16px; }
}
@media(max-width:380px) {
  .stats { grid-template-columns: minmax(0,1fr); }
  .stat { min-height: 0; }
}
