/* Résidence Chay Manager - styles */
:root {
  --bg: #f3f5f8; --card: #ffffff; --ink: #1f2a37; --muted: #6b7686; --line: #e3e7ee;
  --brand: #f6d55c; --brand-dark: #e2bf3a; --brand-soft: #fff9e0; --brand-ink: #111;
  --side: #000000; --side-ink: #b8bec8; --green: #1f8a4c; --red: #c23b3b; --blue: #2b6cb0;
  --radius: 14px; --shadow: 0 1px 3px rgba(20,30,50,.06), 0 6px 20px rgba(20,30,50,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; -webkit-text-size-adjust: 100%; overflow-x: hidden; }
a { color: var(--blue); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
p { margin: 0 0 10px; }
small, .muted { color: var(--muted); }
.inline { display: inline; }

/* Layout */
.layout { display: flex; min-height: 100vh; width: 100%; }
.sidebar { width: 240px; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 20; }
.sidebar .brand, .login .brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); color: #fff; }
.sidebar .brand img, .login .brand img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #000; }
.sidebar .brand small, .login .brand small { display: block; color: var(--side-ink); font-size: 12px; }
.sidebar nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.sidebar a { display: flex; align-items: center; gap: 12px; padding: 12px 18px; color: var(--side-ink); font-weight: 500; }
.sidebar a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar a.active { background: var(--brand); color: var(--brand-ink); }
.sidebar .ico { width: 22px; text-align: center; font-size: 16px; }
.sidefoot { border-top: 1px solid rgba(255,255,255,.08); padding: 6px 0; }
.main { flex: 1; margin-left: 240px; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { padding: 24px; max-width: 1200px; width: 100%; }
.bottomnav { display: none; }

/* Cards & grid */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.soft { background: var(--brand-soft); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .value { font-size: 21px; font-weight: 700; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sub { font-size: 10px; color: var(--muted); margin-top: 3px; line-height: 1.25; }
.kpi.pos .value { color: var(--green); } .kpi.neg .value { color: var(--red); } .kpi.brand { border-left: 4px solid var(--brand); }
.kpi.big .value { font-size: 28px; } .kpi.big .label { font-size: 12px; color: var(--ink); }
.coffee { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.coffee input { width: 70px; text-align: center; font-size: 22px; font-weight: 700; padding: 6px; }
.coffee .btn { width: 44px; padding: 8px 0; font-size: 20px; }
.eurwrap { display: flex; align-items: center; gap: 8px; } .eurwrap input { flex: 1; } .eurmad { white-space: nowrap; font-size: 13px; }
.cashbox .cashline { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dotted var(--line); font-size: 15px; }
.cashbox .cashline.sub { font-size: 12px; color: var(--muted); border: 0; padding: 3px 0; }
.cashbox .cashline.total { font-weight: 700; font-size: 18px; border-bottom: 2px solid var(--brand); }
.cashbox .cashline.grand { font-weight: 800; font-size: 26px; color: var(--green); border: 0; padding-top: 12px; }
.warnbox { border: 1px solid var(--red); }
.res-fields { display: grid; gap: 8px; grid-template-columns: 1.3fr 1fr; }
.res-fields .row3 { grid-column: 1 / -1; display: grid; gap: 8px; grid-template-columns: 1fr 1fr 1fr; }
.res-fields .row4 { grid-column: 1 / -1; display: grid; gap: 8px; grid-template-columns: repeat(4, 1fr); }
.res-fields .full { grid-column: 1 / -1; }
.res-fields .remark input { padding: 7px 10px; font-size: 13px; }
.paystatus .switch label { padding: 8px 4px; font-size: 13px; }
.solde { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.solde .amount { font-size: 34px; font-weight: 800; color: var(--green); }
.solde .amount.neg { color: var(--red); }
.cashout-form { display: none; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.cashout-form.open { display: flex; }
.cashout-form input { flex: 1; min-width: 120px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 10px 16px; border-radius: 10px 10px 0 0; color: var(--muted); font-weight: 600; }
.tabs a.active { background: #111; color: var(--brand); }
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.legend div { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.bars div { flex: 1; background: var(--brand-dark); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars div:hover:after { content: attr(data-v); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #111; color: #fff; font-size: 10px; padding: 2px 5px; border-radius: 4px; white-space: nowrap; }
.mv { display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; align-items: center; }
.mv .t { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.mv .t.cash_in { color: var(--green); } .mv .t.cash_out { color: #b45309; } .mv .t.cash_exp { color: var(--red); } .mv .t.bank_in { color: var(--blue); } .mv .t.bank_out { color: #7c3aed; }
.saving { opacity: .6; pointer-events: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.right { text-align: right; } .center { text-align: center; }
.pos { color: var(--green); } .neg { color: var(--red); } .bold { font-weight: 700; }

/* Forms */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input[type=text], input[type=number], input[type=date], input[type=month], input[type=password], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; background: #fff; color: var(--ink); font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(246,213,92,.18); }
.is-invalid, .switch.is-invalid { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgba(255,107,107,.25) !important; }
.req { color: var(--red); }
.hidden { display: none !important; }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 12px; }
.fields { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 10px; border: 0; background: var(--brand); color: var(--brand-ink); font-weight: 600; font-size: 15px; cursor: pointer; font-family: inherit; }
.btn:hover { background: var(--brand-dark); }
.btn-black { background: #111; color: var(--brand); }
.btn-light { background: #fff; color: var(--ink); border: 1px solid var(--line); } .btn-light:hover { background: #f7f8fa; }
.btn-danger { background: var(--red); color: #fff; } .btn-sm { padding: 7px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-green { background: var(--green); color: #052e16; font-size: 17px; padding: 14px 16px; }
.switch { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.switch label { flex: 1; margin: 0; text-align: center; padding: 10px 4px; cursor: pointer; font-size: 14px; color: var(--muted); font-weight: 600; }
.switch input { display: none; }
.switch input:checked + span { display: block; }
.switch label.on { background: var(--brand); color: var(--brand-ink); }
.switch label.on.warn { background: var(--red); color: #fff; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
td.r, th.r { text-align: right; }
tr.total td { font-weight: 700; background: #fafbfc; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1f5; color: var(--ink); }
.badge.booking { background: #e3edfb; color: #1d4ed8; } .badge.expedia { background: #fff4d6; color: #92400e; } .badge.airbnb { background: #ffe4e6; color: #be123c; } .badge.direct { background: #dcfce7; color: #166534; } .badge.virement { background: #ede9fe; color: #5b21b6; }
.badge.ok { background: #dcfce7; color: #166534; } .badge.warn { background: #fff4d6; color: #92400e; } .badge.bad { background: #ffe4e6; color: #be123c; }

/* Flash */
.flash { padding: 12px 16px; margin: 16px 24px 0; border-radius: 10px; font-weight: 500; }
.flash.ok { background: #dcfce7; color: #166534; } .flash.err { background: #ffe4e6; color: #be123c; border: 1px solid #f5a3a3; }

/* Reception apartment cards */
.apt { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: #fff; transition: background .2s; }
.apt.occupied { border-color: var(--brand-dark); background: #fffdf3; }
.apt .dates { font-size: 15px; font-weight: 600; margin-top: 3px; }
.del-check { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin: 0; }
.del-check input { width: auto; }
.apt-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.apt-head strong { font-size: 17px; }
.apt-body { display: none; } .apt.occupied .apt-body { display: block; }
.apt-summary { font-size: 13px; color: var(--muted); }
.toggle { position: relative; width: 52px; height: 30px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: #d7dce4; border-radius: 30px; cursor: pointer; transition: .2s; }
.toggle span:before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span:before { transform: translateX(22px); }
.exp-row { display: grid; grid-template-columns: 28px 150px 1fr 110px 34px; gap: 6px; margin-bottom: 8px; align-items: center; }
.exp-ico { color: var(--brand); display: flex; justify-content: center; }
.cat-ico { vertical-align: middle; }
.exp-row .del { background: none; border: 0; color: var(--red); font-size: 20px; cursor: pointer; }
.totals { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.totals div { background: #f7f8fa; border-radius: 10px; padding: 10px 12px; }
.totals .label { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.totals .value { font-weight: 700; font-size: 17px; }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 12px 0 4px; z-index: 5; }
.monthnav { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.monthnav input { width: auto; padding: 9px 10px; }
.bar { height: 10px; background: #eef1f5; border-radius: 6px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand-dark); }
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.list-item:last-child { border-bottom: 0; }
.login { max-width: 380px; margin: 8vh auto; padding: 0 16px; }
.login .card { padding: 28px; }
.login .brand { color: var(--ink); justify-content: center; border: 0; padding: 0 0 18px; }
.login .brand img { width: 96px; height: 96px; }
.help { font-size: 13px; color: var(--muted); background: #f7f8fa; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }

/* Print (rapport A4) */
@media print {
  .sidebar, .topbar, .bottomnav, .noprint, .flash { display: none !important; }
  .main { margin: 0; } .content { padding: 0; max-width: none; }
  body { background: #fff; font-size: 12px; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; padding: 12px; }
  @page { size: A4; margin: 12mm; }
}

/* Mobile */
@media (max-width: 900px) {
  .sidebar { width: 250px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 0 30px rgba(0,0,0,.5); }
  body.menu-open .sidebar { transform: translateX(0); }
  .overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 19; }
  body.menu-open .overlay { display: block; }
  .main { margin-left: 0; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--side); color: #fff; padding: 8px 10px; position: sticky; top: 0; z-index: 18; }
  .topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
  .topbar-brand img { width: 28px; height: 28px; border-radius: 7px; background: #000; object-fit: cover; }
  .menu-btn { width: 38px; height: 34px; border: 0; border-radius: 8px; background: #1a1a1a; color: var(--brand); font-size: 20px; line-height: 1; cursor: pointer; }
  .topbar-user { color: var(--side-ink); font-size: 12px; }
  .content { padding: 10px 10px 24px; }
  .flash { margin: 10px 10px 0; padding: 8px 12px; font-size: 13px; }
  .bottomnav { display: none; }
  h1 { font-size: 17px; margin-bottom: 8px; } h2 { font-size: 14px; margin-bottom: 8px; } h3 { font-size: 12px; }
  body { font-size: 13px; }
  .grid { gap: 8px; grid-template-columns: repeat(2, 1fr); } .grid.two { grid-template-columns: 1fr; }
  .kpi { padding: 8px 10px; } .kpi .label { font-size: 9px; } .kpi .value { font-size: 16px; } .kpi .sub { font-size: 9px; }
  .kpi.big .value { font-size: 20px; } .kpi.big .label { font-size: 10px; }
  .card { padding: 10px; margin-bottom: 10px; border-radius: 10px; }
  .table-wrap { margin: 0 -10px; padding: 0 10px; } th, td { padding: 6px 5px; font-size: 12px; }
  label { font-size: 11px; margin-bottom: 2px; }
  input[type=text], input[type=number], input[type=date], input[type=month], input[type=password], select, textarea { padding: 8px 9px; font-size: 14px; border-radius: 8px; }
  .btn { padding: 8px 12px; font-size: 13px; } .btn-sm { padding: 5px 8px; font-size: 12px; } .btn-green { font-size: 15px; padding: 11px 12px; }
  .fields { gap: 6px; grid-template-columns: 1fr 1fr; }
  .apt { padding: 9px; margin-bottom: 8px; } .apt-head strong { font-size: 14px; } .apt .dates { font-size: 12px; } .apt-summary { font-size: 11px; }
  .res-fields { gap: 6px; } .res-fields .remark input { padding: 5px 8px; font-size: 12px; }
  .switch label { padding: 7px 3px; font-size: 12px; } .paystatus .switch label { font-size: 11px; }
  .totals { gap: 6px; } .totals div { padding: 6px 8px; } .totals .value { font-size: 14px; }
  .cashbox .cashline { font-size: 13px; padding: 6px 0; } .cashbox .cashline.total { font-size: 15px; } .cashbox .cashline.grand { font-size: 21px; padding-top: 8px; } .cashbox .cashline.sub { font-size: 11px; }
  .coffee input { width: 56px; font-size: 18px; padding: 4px; } .coffee .btn { width: 36px; padding: 5px 0; font-size: 18px; }
  .help { font-size: 11px; padding: 7px 9px; }
  .list-item { padding: 7px 0; font-size: 13px; } .list-item small { font-size: 11px; }
  .solde h2 { font-size: 14px; } .solde small { font-size: 11px; }
  .badge { font-size: 10px; padding: 2px 6px; }
  .monthnav { gap: 6px; margin-bottom: 8px; } .monthnav input { padding: 7px 8px; font-size: 13px; }
  .tabs a { padding: 8px 10px; font-size: 13px; }
  .donut-wrap svg { width: 120px; height: 120px; } .legend div { font-size: 12px; }
  .bars { height: 70px; }
  .sticky-save { padding: 8px 0 2px; }
  .login .card { padding: 18px; } .login .brand img { width: 72px; height: 72px; }
  .res-fields { grid-template-columns: 1fr 1fr; } .res-fields .row3 { grid-template-columns: 1fr 1fr 1fr; } .res-fields .row4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
  .mv { grid-template-columns: 52px 1fr auto; font-size: 12px; padding: 6px 0; } .mv .t { font-size: 9px; }
  .exp-row { grid-template-columns: 22px 1fr 1fr 28px; gap: 4px; margin-bottom: 6px; } .exp-row .exp-cat { grid-column: 2 / 4; } .exp-row input[name="exp_label[]"] { grid-column: 1 / 3; } .exp-row .exp-amount { grid-column: 3; } .exp-row .del { grid-column: 4; grid-row: 1; }
  .kpi.big .value { font-size: 26px; }
}

@media (max-width: 420px) {
  .res-fields .row3 { grid-template-columns: 1fr 1fr 1fr; } .res-fields .row3 select, .res-fields .row3 input { padding: 7px 5px; font-size: 12px; }
  .res-fields .row4 { grid-template-columns: 1fr 1fr 1fr 1fr; } .res-fields .row4 input { padding: 7px 5px; font-size: 12px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .eurmad { font-size: 10px; }
}
