:root {
  --ink: #1e2a22;
  --muted: #667169;
  --forest: #21372b;
  --forest-2: #36543f;
  --sage: #73836b;
  --sage-soft: #dfe6da;
  --paper: #f5f1e8;
  --surface: #fffdf8;
  --line: #dcd8ce;
  --terracotta: #b86643;
  --terracotta-dark: #8f472e;
  --amber: #d4993f;
  --red: #b3463d;
  --blue: #426d83;
  --shadow: 0 12px 35px rgba(35, 48, 39, .09);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: .78rem; }
.danger-text { color: var(--red); }
.nowrap { white-space: nowrap; }

.boot, .auth-shell { min-height: 100vh; display: grid; place-content: center; padding: 24px; text-align: center; }
.boot p { color: var(--muted); }
.brand-mark { width: 54px; height: 54px; margin: 0 auto; display: grid; place-items: center; border-radius: 15px; background: var(--forest); color: #f7e4bd; font: 800 1.5rem Georgia, serif; box-shadow: 0 9px 25px rgba(33, 55, 43, .23); }

.auth-shell { position: relative; overflow: hidden; }
.auth-shell::before, .auth-shell::after { content: ""; position: fixed; border-radius: 50%; filter: blur(2px); pointer-events: none; }
.auth-shell::before { width: 360px; height: 360px; top: -170px; right: -130px; background: #d7b879; opacity: .25; }
.auth-shell::after { width: 460px; height: 460px; bottom: -270px; left: -220px; background: var(--sage); opacity: .16; }
.auth-card { position: relative; width: min(100%, 470px); padding: 34px; border: 1px solid rgba(85, 88, 76, .15); border-radius: 28px; background: rgba(255, 253, 248, .94); box-shadow: var(--shadow); text-align: left; }
.auth-card .brand-mark { margin: 0 0 24px; }
.auth-card h1 { margin: 0; font: 700 clamp(2rem, 7vw, 3.1rem)/1 Georgia, serif; letter-spacing: -.03em; }
.auth-card > p { margin: 12px 0 26px; color: var(--muted); line-height: 1.55; }
.auth-note { padding: 13px 15px; border-radius: 12px; background: var(--sage-soft); color: var(--forest); font-size: .85rem; line-height: 1.4; }

.app-shell { min-height: 100vh; }
.topbar { position: sticky; z-index: 20; top: 0; height: 70px; display: flex; align-items: center; gap: 16px; padding: 0 22px; color: white; background: rgba(33, 55, 43, .97); backdrop-filter: blur(12px); }
.topbar .brand-mark { width: 40px; height: 40px; margin: 0; border: 1px solid rgba(255,255,255,.18); box-shadow: none; }
.brand-title { display: flex; flex-direction: column; line-height: 1.05; }
.brand-title strong { font-family: Georgia, serif; font-size: 1.22rem; }
.brand-title span { margin-top: 4px; color: #bbc9bf; font-size: .72rem; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.sync-pill { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 7px 10px; border-radius: 99px; color: #d7e1da; background: rgba(255,255,255,.08); font-size: .76rem; }
.sync-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #8dc397; box-shadow: 0 0 0 3px rgba(141,195,151,.13); }
.sync-pill.offline .sync-dot { background: #ebb05e; }

.layout { display: grid; grid-template-columns: 235px minmax(0, 1fr); min-height: calc(100vh - 70px); }
.sidebar { position: sticky; top: 70px; align-self: start; height: calc(100vh - 70px); padding: 24px 15px; border-right: 1px solid var(--line); background: #eeeae1; }
.nav-list { display: grid; gap: 6px; }
.nav-link { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-radius: 12px; color: #4d5b52; background: transparent; text-align: left; font-weight: 650; }
.nav-link:hover { background: rgba(255,255,255,.55); }
.nav-link.active { color: white; background: var(--forest); box-shadow: 0 7px 17px rgba(33,55,43,.16); }
.nav-icon { width: 22px; font-size: 1.08rem; text-align: center; }
.sidebar-footer { position: absolute; right: 15px; bottom: 20px; left: 15px; padding: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.sidebar-footer strong { display: block; color: var(--ink); }

.content { min-width: 0; padding: 34px clamp(22px, 4vw, 58px) 70px; }
.page { max-width: 1180px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 7px; color: var(--terracotta-dark); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.page-head h1, .section-title { margin: 0; font-family: Georgia, serif; letter-spacing: -.025em; }
.page-head h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1; }
.page-head p:not(.eyebrow) { max-width: 680px; margin: 11px 0 0; color: var(--muted); line-height: 1.5; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 32px 0 15px; }
.section-title { font-size: 1.35rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 16px; border: 1px solid transparent; border-radius: 11px; background: var(--forest); color: white; font-weight: 720; text-decoration: none; transition: transform .14s, box-shadow .14s, background .14s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(33,55,43,.16); }
.btn:active { transform: translateY(0); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; box-shadow: none; }
.btn.secondary { border-color: var(--line); background: var(--surface); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--forest); }
.btn.terracotta { background: var(--terracotta); }
.btn.danger { background: var(--red); }
.btn.small { min-height: 34px; padding: 6px 11px; font-size: .82rem; }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.15); border-radius: 11px; color: white; background: rgba(255,255,255,.08); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { position: relative; overflow: hidden; min-height: 132px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 4px 20px rgba(35,48,39,.035); }
.stat::after { content: ""; position: absolute; right: -28px; bottom: -38px; width: 105px; height: 105px; border-radius: 50%; background: var(--sage-soft); opacity: .6; }
.stat.warning::after { background: #f1d9b6; }
.stat.alert::after { background: #ecc6c1; }
.stat .label { position: relative; z-index: 1; color: var(--muted); font-size: .82rem; font-weight: 650; }
.stat .value { position: relative; z-index: 1; margin-top: 14px; font: 700 2.4rem/1 Georgia, serif; }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 5px 24px rgba(35,48,39,.045); }
.card-pad { padding: 21px; }
.dashboard-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; margin-top: 20px; }
.room-progress { display: grid; gap: 13px; }
.room-row { display: grid; grid-template-columns: minmax(100px, 1fr) 2fr auto; align-items: center; gap: 12px; }
.room-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .87rem; }
.progress { height: 8px; overflow: hidden; border-radius: 99px; background: #e8e7e0; }
.progress span { display: block; height: 100%; min-width: 3px; border-radius: inherit; background: var(--sage); }
.room-row em { color: var(--muted); font-size: .78rem; font-style: normal; }

.box-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.box-card { position: relative; display: flex; flex-direction: column; min-height: 205px; padding: 19px; overflow: hidden; color: inherit; text-decoration: none; transition: transform .16s, box-shadow .16s; }
.box-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.box-card::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 5px; background: var(--room-color, var(--sage)); }
.box-top { display: flex; align-items: center; gap: 10px; }
.box-number { color: var(--terracotta-dark); font-size: .75rem; font-weight: 850; letter-spacing: .08em; }
.status { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 99px; color: var(--forest); background: var(--sage-soft); font-size: .7rem; font-weight: 750; }
.status.open { color: #725019; background: #f5e5c7; }
.status.in_transit { color: #2e586c; background: #dceaf0; }
.status.unpacked { color: #686868; background: #e9e9e5; }
.box-card h3 { margin: 16px 0 6px; font: 700 1.35rem Georgia, serif; }
.box-room { color: var(--muted); font-size: .84rem; }
.box-bottom { display: flex; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 20px; color: var(--muted); font-size: .78rem; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.badge { display: inline-flex; padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; background: #f8f5ed; font-size: .67rem; font-weight: 780; }
.badge.fragile { color: var(--red); border-color: #e7c1bd; background: #fbefed; }
.badge.night { color: #4c5e8a; border-color: #cbd3e7; background: #eef1f9; }

.filters { display: grid; grid-template-columns: minmax(200px, 2fr) repeat(2, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.field { display: grid; gap: 7px; }
.field > span, .fieldset-label { color: #48544c; font-size: .8rem; font-weight: 720; }
input, select, textarea { width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid #cfcfc6; border-radius: 10px; outline: none; color: var(--ink); background: #fff; }
textarea { min-height: 92px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--forest-2); box-shadow: 0 0 0 3px rgba(54,84,63,.12); }
input[type="checkbox"], input[type="radio"] { width: 17px; min-height: 17px; margin: 0; accent-color: var(--forest); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.check { display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: #faf8f2; font-size: .81rem; }
.toggle-row { display: flex; flex-wrap: wrap; gap: 10px; }
.toggle-row .check { flex: 1 1 130px; }
.divider { height: 1px; margin: 24px 0; background: var(--line); }

.inline-add { display: flex; gap: 8px; }
.inline-add select { flex: 1 1 auto; min-width: 0; }
.inline-add .btn { flex: 0 0 auto; min-height: 43px; padding: 0 14px; }
.inline-room-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.inline-room-form input { flex: 1 1 160px; min-height: 40px; }
.inline-room-form .btn { min-height: 40px; }

.detail-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; padding: 24px; }
.detail-title { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; }
.detail-title h1 { margin: 0; font: 700 clamp(1.8rem, 5vw, 2.8rem)/1 Georgia, serif; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 18px; color: var(--muted); font-size: .84rem; }
.detail-actions { display: flex; align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.label-panel { display: grid; grid-template-columns: 190px minmax(0,1fr); gap: 20px; align-items: center; }
.label-panel.compact { grid-template-columns: 130px minmax(0,1fr); gap: 16px; padding: 14px; margin: 4px 0 18px; border: 1px solid var(--line); border-radius: 12px; background: #faf8f2; }
.label-panel.compact .label-preview { width: 110px; }
.label-preview { width: 150px; margin: 0 auto; border: 1px solid #aaa; background: white; box-shadow: 0 7px 17px rgba(0,0,0,.1); }
.print-progress { margin-top: 10px; }

.item-list { display: grid; gap: 10px; }
.item-row { display: grid; grid-template-columns: 74px minmax(0,1fr) auto; gap: 15px; align-items: center; padding: 12px; cursor: pointer; }
.item-photo { width: 74px; height: 74px; display: grid; place-items: center; overflow: hidden; border-radius: 11px; color: var(--muted); background: #e9e7df; font-size: 1.6rem; }
.item-photo img { width: 100%; height: 100%; object-fit: cover; }
.item-main { min-width: 0; }
.item-main h3 { margin: 0 0 5px; overflow: hidden; text-overflow: ellipsis; font-size: .98rem; white-space: nowrap; }
.item-sub { color: var(--muted); font-size: .78rem; }
.item-state { display: flex; align-items: flex-end; flex-direction: column; gap: 7px; }
.condition { padding: 4px 8px; border-radius: 7px; background: #eceee9; color: #4d584f; font-size: .68rem; font-weight: 750; }
.condition.broken, .condition.out_of_order, .condition.intermittent { color: #8a332e; background: #f4dcd9; }
.condition.working { color: #285a38; background: #dcebdd; }
.condition.working_fault { color: #79541f; background: #f3e5c7; }

.empty { padding: 46px 24px; border: 1px dashed #c6c8bd; border-radius: var(--radius); text-align: center; color: var(--muted); }
.empty .empty-icon { display: block; margin-bottom: 9px; font-size: 2rem; }
.empty h3 { margin: 0 0 7px; color: var(--ink); }

.report-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; }
.report-card { padding: 22px; }
.report-card h2 { margin: 0; font: 700 1.25rem Georgia, serif; }
.report-card p { min-height: 47px; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.insurance-safe { border-left: 5px solid var(--forest-2); }
.damage-report { border-left: 5px solid var(--terracotta); }
.callout { padding: 15px 17px; border-radius: 12px; background: var(--sage-soft); color: #314539; font-size: .86rem; line-height: 1.5; }
.callout.warning { color: #67491d; background: #f4e5c7; }

.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.settings-card { padding: 21px; }
.settings-card h2 { margin: 0 0 7px; font: 700 1.22rem Georgia, serif; }
.settings-card > p { color: var(--muted); font-size: .83rem; line-height: 1.45; }
.mini-list { display: grid; gap: 8px; margin-top: 14px; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: .84rem; }
.color-dot { width: 11px; height: 11px; display: inline-block; margin-right: 7px; border-radius: 50%; background: var(--dot); }

.modal { width: min(94vw, 690px); max-height: 92vh; padding: 0; overflow: hidden; border: 0; border-radius: 22px; color: var(--ink); background: var(--surface); box-shadow: 0 30px 90px rgba(18,29,22,.3); }
.modal.wide { width: min(96vw, 900px); }
.modal::backdrop { background: rgba(23,34,27,.62); backdrop-filter: blur(3px); }
.modal-head { position: sticky; z-index: 2; top: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 21px 23px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.modal-head h2 { margin: 0; font: 700 1.45rem Georgia, serif; }
.modal-close { width: 35px; height: 35px; border: 0; border-radius: 9px; background: #eeece5; font-size: 1.2rem; }
.modal-body { max-height: calc(92vh - 72px); padding: 21px 23px 28px; overflow: auto; overscroll-behavior: contain; }
.photo-strip { display: flex; gap: 10px; overflow-x: auto; padding: 3px 0 10px; }
.photo-tile { position: relative; width: 112px; height: 112px; flex: 0 0 auto; overflow: hidden; border-radius: 12px; background: #e7e5de; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; }
.photo-kind { position: absolute; right: 5px; bottom: 5px; left: 5px; padding: 4px; overflow: hidden; border-radius: 5px; color: white; background: rgba(22,30,25,.78); font-size: .62rem; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.photo-delete { position: absolute; top: 5px; right: 5px; width: 25px; height: 25px; border: 0; border-radius: 50%; color: white; background: rgba(151,45,39,.9); }
.upload-zone { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px dashed #b9beb4; border-radius: 12px; background: #faf8f3; }
.upload-zone input { display: none; }
.ai-result { margin-top: 10px; padding: 12px; border-radius: 10px; background: #edf1ea; font-size: .82rem; }

.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 20px; display: grid; gap: 9px; width: min(390px, calc(100vw - 36px)); }
.toast { padding: 13px 15px; border-radius: 12px; color: white; background: #293b30; box-shadow: 0 9px 26px rgba(20,28,23,.23); animation: toast-in .2s ease-out; font-size: .87rem; line-height: 1.4; }
.toast.error { background: #8d3732; }
.toast.warning { color: #392c17; background: #e9bd78; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.mobile-nav { display: none; }

@media (max-width: 1000px) {
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .box-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .topbar { height: 62px; padding: 0 14px; }
  .brand-title span { display: none; }
  .sync-pill span:last-child { display: none; }
  .layout { display: block; min-height: calc(100vh - 62px); }
  .sidebar { display: none; }
  .content { padding: 24px 15px 28px; }
  .page-head { align-items: stretch; flex-direction: column; margin-bottom: 21px; }
  .page-head .btn { align-self: flex-start; }
  .page-head h1 { font-size: 2.35rem; }
  .stats-grid { gap: 9px; }
  .stat { min-height: 111px; padding: 15px; }
  .stat .value { margin-top: 11px; font-size: 2rem; }
  .box-grid, .report-grid, .settings-grid { grid-template-columns: 1fr; }
  .box-card { min-height: 174px; }
  .filters { grid-template-columns: 1fr; }
  .detail-hero { grid-template-columns: 1fr; padding: 18px; }
  .detail-actions { justify-content: flex-start; }
  .label-panel { grid-template-columns: 120px minmax(0,1fr); gap: 14px; }
  .label-preview { width: 110px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .check-grid { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 58px minmax(0,1fr); gap: 11px; }
  .item-photo { width: 58px; height: 58px; }
  .item-state { grid-column: 2; align-items: flex-start; flex-direction: row; }
  .mobile-nav { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(5,1fr); padding: 6px 5px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid #415547; background: rgba(33,55,43,.98); backdrop-filter: blur(12px); }
  .mobile-nav .nav-link { min-width: 0; gap: 3px; flex-direction: column; padding: 5px 2px; border-radius: 8px; color: #c6d0c8; font-size: .62rem; text-align: center; }
  .mobile-nav .nav-link.active { background: rgba(255,255,255,.12); box-shadow: none; color: white; }
  .mobile-nav .nav-icon { width: auto; font-size: 1rem; }
  .modal, .modal.wide { width: 100vw; max-width: none; max-height: 94vh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  .modal-body { max-height: calc(94vh - 67px); padding: 18px 17px calc(26px + env(safe-area-inset-bottom)); }
  .modal-head { padding: 18px 17px 14px; }
  .form-actions { position: sticky; bottom: -26px; margin-right: -17px; margin-left: -17px; padding: 13px 17px calc(13px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
}

@media print {
  .topbar, .sidebar, .mobile-nav, .page-head .btn { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
  body { background: white; }
  .card { box-shadow: none; break-inside: avoid; }
}
