:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.4;
}
* { box-sizing: border-box; }
body { margin: 0; overflow-x: hidden; background: #f4f6f8; color: #17212b; }
a { color: inherit; }
.topbar {
    display: flex; gap: 20px; align-items: center; justify-content: space-between;
    padding: 14px 18px; background: white; border-bottom: 1px solid #dde3e8;
    position: sticky; top: 0; z-index: 10;
}
.topbar nav { display: flex; flex-wrap: wrap; gap: 12px; }
.logout-form { margin: 0; }
.logout-form button { min-height: auto; padding: 4px 8px; font-size: 0.85rem; }
.mobile-account-menu { display: none; }
.brand { font-weight: 800; text-decoration: none; letter-spacing: -0.02em; }
.container { max-width: 1050px; margin: 0 auto; padding: 20px; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.actions-inline { display: flex; gap: 10px; align-items: center; }
.actions-inline form { margin: 0; }
.button, button {
    display: inline-block; padding: 10px 14px; border: 1px solid #bbb;
    border-radius: 8px; background: white; text-decoration: none; cursor: pointer;
    min-height: 44px;
}
.button.primary { background: #14532d; color: white; border-color: #14532d; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 18px 0 28px; }
.stats div, .card, .form-card, .media-card {
    background: white; border: 1px solid #dde3e8; border-radius: 14px; padding: 14px;
}
.stats strong { display: block; font-size: 1.7rem; }
.stats span { color: #666; }
.card-list { display: grid; gap: 12px; }
.card { text-decoration: none; }
.card-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.filter-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px; margin: 14px 0 20px;
}
input, select, textarea {
    width: 100%; padding: 10px; border: 1px solid #bbb; border-radius: 7px;
    background: white; font: inherit;
}
input[type="checkbox"] { width: auto; }
.field { margin-bottom: 15px; }
.field > label { display: block; font-weight: 600; margin-bottom: 5px; }
.error { color: #a00; margin-top: 4px; }
.message { background: #eef8ee; border: 1px solid #b9dab9; border-radius: 10px; padding: 10px; margin-bottom: 14px; }
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 20px; }
.login-shell { width: min(100%, 420px); }
.login-card { display: grid; gap: 16px; padding: 24px; border: 1px solid #dce5e9; border-radius: 18px; background: #fff; box-shadow: 0 12px 32px rgba(23, 33, 43, 0.08); }
.login-card h1, .login-card p { margin: 0; }
.login-form { display: grid; gap: 4px; }
.login-form button { width: 100%; }
.tag { display: inline-block; background: #e8eef0; padding: 5px 10px; border-radius: 999px; margin: 2px; }
.muted { color: #666; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.detail-grid div { background: white; border: 1px solid #ddd; border-radius: 8px; padding: 12px; }
.detail-grid strong, .detail-grid span { display: block; }
.photo-action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-action-form, .photo-action-form .button { width: 100%; margin: 0; }
.photo-action-form .button { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.photo-card { display: grid; gap: 8px; min-width: 0; }
.photo-card a { display: block; }
.photo-grid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; }
.photo-card form, .photo-card button { width: 100%; margin: 0; }
audio { width: 100%; margin-top: 8px; }
#scanner-video-wrap, #barcode-video { max-width: 100%; }
#barcode-video { width: 100%; height: auto; }
.voice-recorder { margin: 24px 0; }
.recorder-actions button { min-height: 46px; }
.recording-delete-form { margin-top: 12px; }
.mobile-page { display: grid; gap: 20px; }
.app-page-heading h1, .box-hero h1 { margin: 2px 0 4px; font-size: clamp(2rem, 9vw, 3rem); line-height: 1; letter-spacing: -0.05em; }
.app-page-heading p { margin: 0; }
.eyebrow { color: #4b6b57; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.12em; margin: 0; }
.dashboard-actions { display: grid; gap: 12px; }
.app-action { display: grid; gap: 3px; padding: 18px; border: 1px solid #d7e0e5; border-radius: 16px; background: #fff; text-decoration: none; min-height: 84px; }
.app-action span { font-size: 1.15rem; font-weight: 800; }
.app-action small { color: #5c6a74; }
.app-action-primary { background: #14532d; border-color: #14532d; color: #fff; }
.app-action-primary small { color: #d7f1df; }
.dashboard-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.dashboard-stats div, .summary-card { padding: 14px; border: 1px solid #dce5e9; border-radius: 14px; background: #fff; }
.dashboard-stats strong { display: block; font-size: 1.45rem; }
.dashboard-stats span, .summary-card span { color: #65727c; font-size: 0.82rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2, .box-section h2 { margin: 0; font-size: 1.15rem; }
.section-heading a { color: #14532d; font-size: 0.9rem; font-weight: 700; }
.recent-section, .box-section { display: grid; gap: 12px; }
.recent-box-list { display: grid; gap: 10px; }
.recent-box-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px; border: 1px solid #dde5e9; border-radius: 14px; background: #fff; text-decoration: none; }
.recent-box-card strong, .recent-box-card span { display: block; }
.recent-box-card > div:first-child span { color: #65727c; font-size: 0.88rem; margin-top: 2px; }
.recent-box-meta { text-align: right; font-size: 0.82rem; color: #65727c; }
.status-chip { margin-top: 4px; color: #14532d; font-weight: 700; }
.empty-card, .manual-barcode-card { padding: 16px; border: 1px solid #dce5e9; border-radius: 14px; background: #fff; }
.scanner-hero { display: grid; gap: 14px; padding: 18px; border: 1px solid #cfe1d4; border-radius: 16px; background: #eff8f1; }
.scanner-actions, .manual-barcode-form { display: grid; gap: 10px; }
.scanner-actions .button, .manual-barcode-form .button { width: 100%; }
.scanner-video-wrap { overflow: hidden; border-radius: 12px; background: #111; }
.scanner-status { margin: 0; }
.manual-barcode-card { display: grid; gap: 14px; }
.box-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 18px; border-radius: 18px; background: #163d2b; color: #fff; }
.box-hero .eyebrow { color: #b6dcc2; }
.box-barcode { color: #dcefe1; font-size: 0.95rem; overflow-wrap: anywhere; }
.box-edit-button { flex: 0 0 auto; border-color: #cce6d4; color: #153f28; background: #fff; }
.packing-progress { display: grid; grid-template-columns: 1fr; gap: 8px; background: #eff8f1; border-color: #cfe1d4; color: #1b5730; font-weight: 700; }
.find-mode-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
.find-mode-actions .button { width: 100%; text-align: center; }
.packing-finish-card { display: grid; gap: 12px; padding: 16px; }
.packing-finish-card h2, .packing-finish-card p { margin: 0; }
.packing-finish-card form, .packing-finish-card .button, .packing-finish-card button { width: 100%; margin: 0; }
.box-summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.summary-card strong { display: block; margin-top: 4px; font-size: 0.95rem; overflow-wrap: anywhere; }
.category-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.category-chip { margin: 0; background: #e3f2e8; color: #1b5730; }
.notes-card { padding: 16px; border-radius: 14px; background: #fff; border: 1px solid #dde5e9; }
.notes-card p { margin: 0; }
.app-card { border-radius: 16px; }
.voice-recorder h2 { margin-top: 0; }
.recording-card { display: grid; gap: 8px; padding: 16px; }
.recording-card p { margin: 0; }
.recording-card .transcribe-recording, .recording-card .recording-delete-form button { width: 100%; }
.recording-delete-form { margin: 0; }
.find-search-form { display: grid; gap: 10px; }
.find-search-form label { font-weight: 700; }
.voice-search-card { display: grid; gap: 10px; }
.voice-search-card h2 { margin: 0; font-size: 1.15rem; }
.voice-search-card label { font-weight: 700; }
.voice-search-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
.voice-search-actions button { width: 100%; min-height: 50px; }
.search-examples { margin: -10px 0 0; font-size: 0.88rem; }
.find-results { display: grid; gap: 12px; }
.find-results h2 { margin: 0; font-size: 1.1rem; }
.find-result-card { display: grid; gap: 10px; padding: 16px; border: 1px solid #dce5e9; border-radius: 16px; background: #fff; }
.find-result-heading, .find-result-meta { display: flex; justify-content: space-between; gap: 10px; }
.find-result-heading strong, .find-result-heading span { display: block; }
.find-result-heading strong { font-size: 1.3rem; }
.find-result-heading > div > span, .find-result-meta { color: #65727c; font-size: 0.9rem; overflow-wrap: anywhere; }
.match-strength { align-self: flex-start; padding: 5px 8px; border-radius: 999px; background: #e3f2e8; color: #1b5730; font-size: 0.78rem; font-weight: 700; text-align: center; }
.match-snippet { margin: 0; color: #3e4d58; overflow-wrap: anywhere; }
.find-photo img { display: block; width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; }
.bottom-nav { display: none; }
.page-heading-action { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-heading-action .button { flex: 0 0 auto; }
.mobile-filter-card { padding: 14px; border: 1px solid #dce5e9; border-radius: 14px; background: #fff; margin: 0; }
.box-card-list, .master-card-list { display: grid; gap: 12px; }
.bulk-status-form { display: grid; gap: 12px; }
.bulk-status-controls { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 14px; border: 1px solid #dce5e9; border-radius: 14px; background: #fff; }
.bulk-status-controls label { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 700; }
.bulk-status-controls button { width: 100%; }
.box-list-card, .master-card { display: grid; gap: 9px; padding: 16px; border: 1px solid #dce5e9; border-radius: 16px; background: #fff; text-decoration: none; }
.bulk-box-card { min-width: 0; }
.box-select { display: flex; align-items: center; gap: 8px; min-height: 32px; font-size: 0.86rem; color: #52616c; }
.box-card-link { display: grid; gap: 9px; min-width: 0; color: inherit; text-decoration: none; }
.box-card-heading, .master-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.box-card-heading strong, .master-card-heading strong { font-size: 1.2rem; }
.box-card-barcode { color: #52616c; font-size: 0.92rem; overflow-wrap: anywhere; }
.box-card-room { font-size: 0.92rem; }
.box-card-categories { display: flex; flex-wrap: wrap; gap: 4px; }
.box-card-counts { color: #65727c; font-size: 0.86rem; padding-top: 3px; border-top: 1px solid #edf0f2; }
.app-form { padding: 18px; }
.app-form .field { margin-bottom: 18px; }
.app-form input, .app-form select, .app-form textarea { min-height: 46px; }
.app-form textarea { min-height: 110px; }
.app-form ul { display: grid; gap: 8px; padding: 0; margin: 0; list-style: none; }
.app-form li label { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid #dce5e9; border-radius: 10px; }
.app-form li input[type="checkbox"] { flex: 0 0 auto; min-height: auto; }
.form-actions { display: grid; grid-template-columns: 1fr; margin: 6px 0 0; }
.form-actions .button, .form-save-button { width: 100%; }
.master-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 4px; }
.master-card-actions .button, .master-card-actions button, .master-card-actions form { width: 100%; margin: 0; }
.alias-values { margin: 0; color: #3e4d58; overflow-wrap: anywhere; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 10px; border-bottom: 1px solid #ddd; text-align: left; }

@media (max-width: 650px) {
    .topbar { min-height: 58px; padding: 16px; }
    .topbar nav { display: none; }
    .mobile-account-menu { display: block; position: relative; }
    .mobile-account-menu summary { cursor: pointer; font-weight: 700; }
    .mobile-account-menu[open] { position: absolute; z-index: 30; top: 50px; right: 16px; display: grid; gap: 8px; min-width: 148px; padding: 12px; border: 1px solid #dce5e9; border-radius: 12px; background: #fff; box-shadow: 0 8px 24px rgba(23, 33, 43, 0.14); }
    .mobile-account-menu a { text-decoration: none; }
    .mobile-account-menu form, .mobile-account-menu button { width: 100%; margin: 0; }
    .container { padding: 16px 16px 92px; }
    .page-head { align-items: flex-start; }
    .recorder-actions { display: grid; grid-template-columns: 1fr; }
    .recorder-actions button { width: 100%; }
    .bottom-nav { position: fixed; z-index: 20; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, 0.96); border-top: 1px solid #dce5e9; box-shadow: 0 -4px 16px rgba(23, 33, 43, 0.08); }
    .bottom-nav a { display: grid; place-items: center; min-height: 44px; color: #52616c; font-size: 0.76rem; font-weight: 700; text-decoration: none; }
    .bottom-nav a:first-child { color: #14532d; }
    .page-heading-action .button { min-width: 94px; }
    .mobile-filter-card { grid-template-columns: 1fr; }
    .master-card-actions .button, .master-card-actions button { font-size: 0.88rem; padding-right: 8px; padding-left: 8px; }
}

@media (min-width: 651px) {
    .mobile-page { gap: 24px; }
    .dashboard-actions { grid-template-columns: repeat(2, 1fr); }
    .dashboard-stats { grid-template-columns: repeat(4, 1fr); }
    .recent-box-list { grid-template-columns: repeat(2, 1fr); }
    .box-summary-grid { grid-template-columns: repeat(4, 1fr); }
    .packing-progress { grid-template-columns: repeat(3, 1fr); }
    .find-mode-actions { grid-template-columns: auto auto; justify-content: start; }
    .find-mode-actions .button { width: auto; }
    .scanner-actions { grid-template-columns: repeat(2, 1fr); }
    .manual-barcode-form { grid-template-columns: 1fr auto; align-items: end; }
    .manual-barcode-form label { grid-column: 1 / -1; }
    .manual-barcode-form .button { width: auto; }
    .box-card-list, .master-card-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bulk-status-controls { grid-template-columns: minmax(190px, 1fr) minmax(140px, auto) auto; align-items: end; }
    .bulk-status-controls button { width: auto; }
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
    .form-actions { grid-template-columns: auto auto; justify-content: start; }
    .form-actions .button { width: auto; }
    .form-save-button { width: auto; }
}
