:root {
  --ink: #211d1a;
  --muted: #70665f;
  --paper: #f5f0e7;
  --card: #fcf9f3;
  --wine: #711f31;
  --wine-dark: #50101f;
  --gold: #bd8a48;
  --green: #607c53;
  --danger: #a23a3a;
  --line: rgba(54, 43, 36, .14);
  --shadow: 0 22px 65px rgba(61, 39, 31, .09);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--paper); font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button, summary { color: inherit; }
a { color: inherit; }
.grain { position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: .08; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.25'/%3E%3C/svg%3E"); }

.site-header { position: sticky; top: 0; z-index: 12; border-bottom: 1px solid var(--line); background: rgba(245, 240, 231, .9); backdrop-filter: blur(16px); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 28px; width: min(1240px, calc(100% - 36px)); min-height: 68px; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 780; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: #fff8ee; background: var(--wine); border-radius: 50% 50% 46% 54% / 56% 44% 58% 42%; font: 20px Georgia, serif; }
.main-nav { display: flex; gap: 5px; overflow-x: auto; }
.main-nav a { flex: 0 0 auto; padding: 9px 12px; color: var(--muted); border-radius: 10px; text-decoration: none; font-size: 13px; font-weight: 650; }
.main-nav a:hover, .main-nav a.active { color: var(--wine); background: rgba(113, 31, 49, .07); }
.logout-form { display: flex; margin: 0 0 0 5px; padding-left: 9px; border-left: 1px solid var(--line); }
.logout-form button { padding: 9px 11px; color: var(--muted); background: transparent; border: 0; border-radius: 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.logout-form button:hover { color: var(--wine); background: rgba(113, 31, 49, .07); }

.page-shell { width: min(1240px, calc(100% - 36px)); min-height: calc(100vh - 150px); margin: 0 auto; padding: 48px 0 80px; }
.site-footer { display: flex; justify-content: space-between; gap: 20px; width: min(1240px, calc(100% - 36px)); margin: 0 auto; padding: 24px 0 34px; color: #8b8179; border-top: 1px solid var(--line); font-size: 12px; }

.eyebrow { margin: 0 0 7px; color: var(--wine); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3, p { text-wrap: pretty; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: -.035em; }
h1 { margin: 0; font-size: clamp(34px, 4.2vw, 48px); line-height: 1.02; }
h2 { margin: 0; font-size: clamp(27px, 3vw, 36px); line-height: 1.08; }
h3 { margin: 0; font-size: 22px; line-height: 1.12; }
.heading-copy { margin: 10px 0 0; color: var(--muted); font-size: 16px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 30px; }
.compact-heading { min-height: 92px; }
.heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.section-title-row { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin: 35px 0 20px; }
.section-title-row p:last-child { max-width: 440px; margin: 0; color: var(--muted); text-align: right; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 12px; text-decoration: none; font-weight: 720; cursor: pointer; transition: .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.button.primary { color: #fff9f2; background: var(--wine); box-shadow: 0 8px 20px rgba(113, 31, 49, .16); }
.button.primary:hover { background: var(--wine-dark); }
.button.secondary { color: var(--wine); background: #fffaf3; border-color: rgba(113, 31, 49, .2); }
.button.ghost { color: var(--muted); background: transparent; border-color: var(--line); }
.button.small { min-height: 34px; padding: 7px 11px; border-radius: 9px; font-size: 12px; }
.button.text-button { min-height: 36px; padding-inline: 8px; color: var(--muted); background: transparent; }
.quiet-link, .back-link { color: var(--wine); text-decoration: none; font-weight: 700; }
.back-link { display: inline-block; margin-bottom: 16px; }

.action-menu { position: relative; }
.action-menu summary { list-style: none; }
.action-menu summary::-webkit-details-marker { display: none; }
.menu-popover { position: absolute; top: calc(100% + 8px); right: 0; z-index: 8; width: 215px; padding: 8px; background: #fffdf8; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.menu-popover a { display: block; padding: 9px 10px; border-radius: 8px; text-decoration: none; font-size: 13px; }
.menu-popover a:hover { color: var(--wine); background: #f3ebe1; }
.menu-popover hr { margin: 6px 5px; border: 0; border-top: 1px solid var(--line); }
.import-popover { width: 310px; padding: 14px; }
.import-popover form { display: grid; gap: 9px; }
.import-popover label { display: grid; gap: 6px; }
.import-popover input[type=file] { max-width: 100%; font-size: 12px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 18px; }
.stat-card { position: relative; min-height: 135px; padding: 19px; overflow: hidden; background: rgba(252, 249, 243, .86); border: 1px solid var(--line); border-radius: 17px; }
.stat-card::after { content: ""; position: absolute; right: -45px; bottom: -60px; width: 125px; height: 125px; border-radius: 50%; background: radial-gradient(circle, rgba(113,31,49,.11), transparent 68%); }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card span { font-size: 11px; font-weight: 780; letter-spacing: .1em; text-transform: uppercase; }
.stat-card strong { display: block; margin: 10px 0 3px; font: 36px Georgia, serif; }
.stat-card small { font-size: 12px; }

.panel { padding: 22px; background: rgba(252, 249, 243, .9); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 9px 30px rgba(53, 38, 30, .045); }
.filter-form { display: grid; grid-template-columns: 1.6fr repeat(5, minmax(120px, .65fr)) auto; align-items: end; gap: 12px; }
.accord-filter { display: grid; grid-template-columns: 1fr 180px auto auto; align-items: end; gap: 12px; }
label, .field-label, legend { color: var(--muted); font-size: 11px; font-weight: 760; letter-spacing: .07em; text-transform: uppercase; }
label > span { display: block; margin-bottom: 7px; }
input, select, textarea { width: 100%; min-height: 42px; padding: 10px 12px; color: var(--ink); background: #fffdf8; border: 1px solid #d8cec2; border-radius: 10px; outline: none; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--wine); box-shadow: 0 0 0 3px rgba(113,31,49,.09); }
.filter-actions { display: flex; align-items: center; gap: 3px; }

.collection-section { margin-top: 8px; }
.table-wrap { overflow-x: auto; background: #fffdf9; border: 1px solid var(--line); border-radius: 16px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 12px 14px; color: #81756d; background: #f1eae0; border-bottom: 1px solid var(--line); text-align: left; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbf6ee; }
.wine-title { display: block; font-family: Georgia, serif; font-size: 17px; font-weight: 500; }
.wine-subtitle { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.wine-note { display: block; max-width: 430px; margin-top: 5px; color: #8b6e52; font-size: 11px; font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.color-pill, .style-pill { display: inline-flex; align-items: center; width: max-content; padding: 5px 9px; background: #eee7dc; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.color-pill::before { content: ""; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #c5a95f; }
.color-rouge::before { background: #7b2639; }.color-blanc::before { background: #d2b86f; }.color-rose::before { background: #da9094; }.color-orange::before { background: #d27a3c; }
.stock-pill { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding-inline: 7px; color: #31532d; background: #e6efe1; border-radius: 9px; font-weight: 800; }
.stock-pill.empty { color: #855a56; background: #f1e2df; }
.rating-display { display: inline-flex; gap: 1px; padding: 3px; color: #d1c5b6; background: transparent; border: 0; cursor: pointer; }
.rating-display span, .card-rating span { color: #cfc3b4; }.rating-display span.filled, .card-rating span.filled { color: var(--gold); }
.rating-display:hover span { color: var(--gold); }
.action-column { text-align: right !important; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; white-space: nowrap; }
.row-actions form { margin: 0; }
.icon-button { display: inline-grid; place-items: center; width: 33px; height: 33px; padding: 0; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 9px; text-decoration: none; cursor: pointer; }
.icon-button:hover { color: var(--wine); background: #f1e8df; }.icon-button.danger:hover { color: white; background: var(--danger); border-color: var(--danger); }.icon-button:disabled { opacity: .3; cursor: not-allowed; }

.flash-stack { position: fixed; top: 82px; right: 18px; z-index: 30; display: grid; gap: 8px; width: min(390px, calc(100% - 36px)); }
.flash { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 14px; background: #fffdf8; border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 12px; box-shadow: var(--shadow); }
.flash-error { border-left-color: var(--danger); }.flash-close { padding: 0; color: var(--muted); background: transparent; border: 0; font-size: 20px; cursor: pointer; }

.app-dialog { width: min(680px, calc(100% - 28px)); max-height: 88vh; padding: 0; color: var(--ink); background: var(--paper); border: 0; border-radius: 22px; box-shadow: 0 30px 100px rgba(30,20,18,.28); }
.app-dialog::backdrop { background: rgba(31,24,22,.56); backdrop-filter: blur(3px); }
.app-dialog form { padding: 25px; }
.small-dialog { width: min(520px, calc(100% - 28px)); }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.dialog-header h2 { font-size: 32px; }
.dialog-close { width: 36px; height: 36px; color: var(--muted); background: #e9e1d6; border: 0; border-radius: 50%; font-size: 23px; cursor: pointer; }
.dialog-actions, .form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }.span-2 { grid-column: 1 / -1; }
.star-input { display: flex; flex-direction: row-reverse; justify-content: flex-end; margin: 0 0 20px; padding: 0; border: 0; }
.star-input legend { margin-bottom: 8px; }
.star-input input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.star-input label { color: #d0c4b6; font-size: 35px; line-height: 1; cursor: pointer; letter-spacing: 0; }
.star-input input:checked ~ label, .star-input label:hover, .star-input label:hover ~ label { color: var(--gold); }

.narrow-page { width: min(780px, 100%); margin: 0 auto; }.edit-panel { padding: 30px; }.edit-panel .page-heading { margin-bottom: 26px; }
.empty-state { padding: 55px 24px; text-align: center; background: #fffdf9; border: 1px solid var(--line); border-radius: var(--radius); }
.empty-state p { color: var(--muted); }.empty-state .button { margin-top: 8px; }

.pairing-hero { padding-top: 10px; }
.pairing-heading { max-width: 720px; margin: 28px auto 30px; text-align: center; }
.pairing-heading h1 { font-size: clamp(38px, 5vw, 58px); }
.pairing-heading p:last-child { margin: 12px auto 0; color: var(--muted); font-size: 17px; }
.pairing-form { max-width: 930px; margin: 0 auto; padding: 28px; background: rgba(252,249,243,.94); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.dish-input input { min-height: 58px; padding: 10px 44px 10px 0; background: transparent; border: 0; border-bottom: 1.5px solid #aa9c90; border-radius: 0; box-shadow: none; font: clamp(21px, 3vw, 31px) Georgia, serif; letter-spacing: -.02em; }
.dish-input input:focus { border-color: var(--wine); }
.field-label { display: block; margin: 22px 0 8px; }
.dish-chips { display: flex; gap: 7px; padding-bottom: 5px; overflow-x: auto; }
.dish-chip { flex: 0 0 auto; padding: 8px 11px; color: #5f554f; background: transparent; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.dish-chip:hover { color: #fff9f2; background: var(--wine); border-color: var(--wine); }
.pairing-filters { display: grid; grid-template-columns: 1fr 1fr 150px; gap: 14px; margin-top: 22px; padding-top: 21px; border-top: 1px solid var(--line); }
.recent-settings { display: grid; grid-template-columns: auto 90px 1fr; align-items: center; gap: 10px 14px; margin-top: 20px; padding: 15px; background: #f0e9df; border-radius: 14px; }
.recent-settings small { grid-column: 1 / -1; color: #887b71; }
.switch-label { display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: 13px; letter-spacing: 0; text-transform: none; cursor: pointer; }
.switch-label input { position: absolute; opacity: 0; pointer-events: none; }.switch { position: relative; flex: 0 0 auto; width: 38px; height: 22px; background: #a89e95; border-radius: 999px; }.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: white; border-radius: 50%; transition: .2s ease; }.switch-label input:checked + .switch { background: var(--wine); }.switch-label input:checked + .switch::after { transform: translateX(16px); }
.inline-days { display: flex; align-items: center; gap: 7px; color: var(--ink); font-size: 13px; text-transform: none; letter-spacing: 0; }.inline-days input { width: 60px; }.inline-days span { margin: 0; }
.manual-recent { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; }.manual-recent span { margin: 0; }.pairing-submit { min-width: 210px; margin-top: 20px; gap: 24px; }
.pairing-results { padding: 70px 0 10px; }
.recommendation-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 15px; }.recommendation-grid.count-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 840px; }
.recommendation-card { position: relative; display: flex; flex-direction: column; min-height: 360px; padding: 22px; overflow: hidden; background: #fffdf8; border: 1px solid var(--line); border-radius: 19px; box-shadow: 0 9px 32px rgba(52,38,31,.05); }
.rank { display: grid; place-items: center; width: 33px; height: 33px; margin-bottom: 27px; color: var(--wine); border: 1px solid rgba(113,31,49,.28); border-radius: 50%; font: 17px Georgia, serif; }
.wine-tags { display: flex; gap: 7px; margin-bottom: 11px; }.recommendation-card h3 { font-size: 27px; }.recommendation-reason { margin: 19px 0 20px; color: #5e544d; font-size: 14px; }.card-rating { margin-bottom: 12px; }.card-rating small { margin-left: 6px; color: var(--muted); }
.service-details { display: flex; gap: 24px; margin: auto 0 0; padding-top: 15px; border-top: 1px solid var(--line); }.service-details dt { color: #897d73; font-size: 9px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }.service-details dd { margin: 3px 0 0; font-size: 12px; }
.alternative-card { display: grid; grid-template-columns: 145px 1fr auto; align-items: center; gap: 20px; margin-top: 15px; padding: 18px 20px; border: 1px dashed rgba(113,31,49,.3); border-radius: 16px; }.alt-label { color: var(--wine); font-size: 10px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }.alternative-card strong { font: 19px Georgia, serif; }.alternative-card p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }.alt-temp { color: var(--wine); font-weight: 750; white-space: nowrap; }

.add-accord-panel { margin: 17px 0; }.add-accord-panel > summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }.add-accord-panel > summary::-webkit-details-marker { display: none; }.add-accord-panel summary strong { font: 22px Georgia, serif; }.summary-plus { font-size: 28px; color: var(--wine); }.add-accord-panel[open] .summary-plus { transform: rotate(45deg); }.accord-form { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.reason-cell { max-width: 360px; color: var(--muted); font-size: 12px; }.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 18px; }.pagination a { color: var(--wine); text-decoration: none; font-weight: 700; }.pagination a:last-child { text-align: right; }.pagination span { color: var(--muted); text-align: center; }
.confirmation-panel h1 { margin-bottom: 12px; }.confirmation-panel > p { color: var(--muted); }.compact-table { margin-top: 22px; }.confirmation-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }.muted { color: var(--muted); font-size: 12px; }

.login-page .site-header { position: static; }
.login-page .header-inner { justify-content: center; }
.login-page .page-shell { display: grid; place-items: center; min-height: calc(100vh - 150px); padding-block: 32px; }
.login-page .site-footer { justify-content: center; }
.login-page .site-footer span:first-child { display: none; }
.login-shell { width: min(440px, 100%); }
.login-card { padding: 36px; text-align: center; background: rgba(252, 249, 243, .96); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.login-emblem { display: grid; place-items: center; width: 62px; height: 62px; margin: 0 auto 22px; color: #fff8ee; background: var(--wine); border-radius: 50% 50% 46% 54% / 56% 44% 58% 42%; font: 34px Georgia, serif; }
.login-card h1 { font-size: 43px; }
.login-copy { margin: 11px 0 25px; color: var(--muted); }
.login-form { display: grid; gap: 15px; text-align: left; }
.login-form .button { width: 100%; margin-top: 5px; }
.setup-warning { margin-top: 24px; padding: 17px; color: #73452c; background: #f4e6d7; border: 1px solid #e2c9ad; border-radius: 13px; text-align: left; }
.setup-warning p { margin: 5px 0 0; font-size: 13px; }
.security-note { margin: 20px 0 0; color: #8b8179; font-size: 11px; }
.error-panel { margin-top: 10vh; text-align: center; }
.error-panel .button { margin-top: 24px; }

@media (max-width: 1050px) {
  .filter-form { grid-template-columns: repeat(3, 1fr); }.wide-field { grid-column: span 2; }.filter-actions { justify-content: flex-end; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 780px) {
  .header-inner { align-items: flex-start; flex-direction: column; gap: 8px; padding: 12px 0 8px; }.main-nav { width: 100%; }.main-nav a { padding: 7px 9px; }.logout-form { margin-left: auto; }
  .login-page .header-inner { align-items: center; }
  .page-shell { width: min(100% - 24px, 680px); padding-top: 34px; }.site-footer { width: calc(100% - 24px); }
  .page-heading, .section-title-row { align-items: flex-start; flex-direction: column; }.heading-actions { justify-content: flex-start; }.section-title-row p:last-child { text-align: left; }
  .filter-form, .accord-filter { grid-template-columns: 1fr 1fr; }.wide-field { grid-column: 1 / -1; }
  .recommendation-grid, .recommendation-grid.count-2 { grid-template-columns: 1fr; max-width: none; }.recommendation-card { min-height: 320px; }
  .recent-settings { grid-template-columns: 1fr 90px; }.manual-recent { grid-column: 1 / -1; }.alternative-card { grid-template-columns: 1fr auto; }.alt-label { grid-column: 1 / -1; }
  .data-table thead { display: none; }.data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }.data-table tr { padding: 14px; border-bottom: 1px solid var(--line); }.data-table td { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 7px 0; border: 0; }.data-table td::before { content: attr(data-label); color: #8a7e74; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }.data-table td.row-actions { display: flex; justify-content: flex-start; margin-left: 110px; width: calc(100% - 110px); }.reason-cell { max-width: none; }
}

@media (max-width: 520px) {
  .page-shell { width: calc(100% - 18px); }.main-nav { padding-bottom: 2px; }.brand { font-size: 14px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }.stat-card { min-height: 116px; padding: 14px; }.stat-card strong { font-size: 30px; }
  .panel, .pairing-form { padding: 17px; border-radius: 16px; }.filter-form, .accord-filter, .pairing-filters, .form-grid { grid-template-columns: 1fr; }.wide-field, .span-2 { grid-column: auto; }.filter-actions { justify-content: flex-start; }
  .heading-actions { width: 100%; }.heading-actions .button, .heading-actions details { flex: 1 1 auto; }.heading-actions details .button { width: 100%; }.menu-popover { right: auto; left: 0; }
  .pairing-heading { margin-top: 8px; }.pairing-heading h1 { font-size: 38px; }.recent-settings { grid-template-columns: 1fr; }.inline-days { grid-row: 2; }.manual-recent { grid-column: auto; grid-template-columns: 1fr; }.pairing-submit { width: 100%; }
  .alternative-card { grid-template-columns: 1fr; }.alt-temp { white-space: normal; }.site-footer { flex-direction: column; }.dialog-actions, .form-actions, .confirmation-actions { align-items: stretch; flex-direction: column-reverse; }.dialog-actions .button, .form-actions .button, .confirmation-actions .button { width: 100%; }
  .data-table td { grid-template-columns: 90px 1fr; }.data-table td.row-actions { margin-left: 90px; width: calc(100% - 90px); }
  .login-card { padding: 26px 20px; border-radius: 18px; }.login-card h1 { font-size: 38px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
