@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,500;0,600;0,700;1,600&display=swap');

:root {
  --forest: #4a5a3f;
  --deep: #293122;
  --cream: #f7f5ee;
  --paper: #fffefa;
  --gold: #c9b47e;
  --taupe: #7a6f5b;
  --line: #e5dfd2;
  --danger: #9c4b3d;
  --shadow: 0 16px 45px rgba(42, 50, 35, .09);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { min-width: 0; margin: 0; color: var(--deep); background: var(--cream); font-family: Montserrat, Arial, sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
aside { display: flex; flex-direction: column; padding: 30px 18px; color: #fff; background: var(--deep); }
.brand { padding: 0 8px 39px; text-align: center; }
.brand img { display: block; width: 86px; height: 86px; margin: 0 auto 12px; border-radius: 50%; box-shadow: 0 7px 25px rgba(0, 0, 0, .25); }
.brand strong { display: block; font: 600 1.3rem 'Playfair Display', serif; letter-spacing: .01em; }
.brand small { display: block; margin-top: 6px; color: #ded7c8; font-size: .55rem; letter-spacing: .25em; }
.nav-label { padding: 0 10px 10px; color: #b9b9a9; font-size: .62rem; letter-spacing: .17em; text-transform: uppercase; }
.nav { display: grid; gap: 5px; }
.nav a { display: flex; gap: 11px; align-items: center; padding: 13px 12px; border-radius: 10px; color: #d9dbd1; font-size: .81rem; font-weight: 700; text-decoration: none; }
.nav a.active, .nav a:hover { color: #fff; background: #52624a; }
.nav-icon { width: 18px; text-align: center; font-size: 1rem; }
.access { margin-top: auto; padding: 13px; border: 1px solid rgba(223, 216, 194, .22); border-radius: 13px; background: rgba(255, 255, 255, .045); color: #e9e6d9; font-size: .7rem; line-height: 1.55; }
.access strong { display: block; color: #d9bc76; font-size: .72rem; }
.logout-link { display: inline-block; margin-top: 6px; color: #fff; font-weight: 700; }

main { width: 100%; min-width: 0; max-width: 1470px; margin: auto; padding: 41px clamp(20px, 4vw, 62px); }
.top { display: flex; gap: 18px; align-items: flex-start; justify-content: space-between; margin-bottom: 29px; }
.eyebrow { margin: 0; color: var(--taupe); font-size: .73rem; letter-spacing: .04em; }
h1, h2 { margin: 0; font-family: 'Playfair Display', serif; letter-spacing: -.035em; }
h1 { margin-top: 6px; font-size: clamp(2.05rem, 3.5vw, 2.8rem); font-weight: 600; }
h2 { font-size: 1.24rem; font-weight: 600; }
.month { padding: 11px 14px; border: 1px solid var(--line); border-radius: 11px; color: var(--taupe); background: #fff; font-size: .76rem; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.14fr) minmax(330px, .86fr); gap: 23px; }
.card { border: 1px solid var(--line); border-radius: 19px; background: var(--paper); box-shadow: var(--shadow); }
.entry, .history, .chart { padding: 26px; }
.card-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 21px; }
.note { color: var(--taupe); font-size: .67rem; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.field.full { grid-column: 1 / -1; }
label { display: block; margin-bottom: 7px; color: #675f51; font-size: .69rem; font-weight: 700; }
input, select { width: 100%; min-height: 44px; padding: 11px 12px; border: 1px solid #ddd6c8; border-radius: 9px; outline: 0; color: var(--deep); background: #fffefa; font-size: max(.85rem, 16px); }
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 180, 126, .18); }
.with-suffix { position: relative; }
.with-suffix span { position: absolute; top: 11px; right: 12px; color: #928773; font-size: .82rem; }
.with-suffix input { padding-right: 29px; }
.submit { width: 100%; min-height: 46px; margin-top: 5px; padding: 13px; border: 0; border-radius: 9px; color: #fff; background: var(--forest); box-shadow: 0 8px 16px rgba(74, 90, 63, .16); font-size: .8rem; font-weight: 700; letter-spacing: .01em; }
.submit:hover { background: #5d6d51; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric { padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); }
.metric span { display: block; margin-bottom: 9px; color: var(--taupe); font-size: .69rem; }
.metric strong { font-size: 1.39rem; letter-spacing: -.055em; }
.metric em { margin-left: 4px; color: #69835e; font-size: .65rem; font-style: normal; font-weight: 700; }
.chart { margin-top: 23px; }
.chart p { margin: 5px 0 0; color: var(--taupe); font-size: .7rem; }
.tag { padding: 5px 8px; border-radius: 100px; color: #7e6c3e; background: #f4efdf; font-size: .63rem; font-weight: 700; }
.chart-area { height: 174px; min-width: 0; margin-top: 19px; }
.chart-area svg { width: 100%; height: 100%; overflow: visible; }
.gridline { stroke: #e9e4d8; stroke-width: 1; }
.area { fill: url(#goldfade); }
.line { fill: none; stroke: #879772; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.point { fill: var(--deep); }
.last { fill: var(--paper); stroke: #879772; stroke-width: 3; }
.chart-empty { display: grid; height: 100%; place-items: center; color: var(--taupe); font-size: .78rem; text-align: center; }
.axis { display: flex; justify-content: space-between; margin-top: 5px; color: #968d7d; font-size: .62rem; }
.history { min-width: 0; margin-top: 23px; }
.head-actions { display: flex; gap: 10px; align-items: center; }
.button-quiet { display: inline-block; padding: 8px 10px; border: 1px solid #d8d0c0; border-radius: 8px; color: var(--forest); background: #fff; font-size: .7rem; font-weight: 700; text-decoration: none; }
.button-quiet:hover { background: #f0efe9; }
.see-all { color: var(--forest); font-size: .71rem; font-weight: 700; text-decoration: none; }
table { width: 100%; border-collapse: collapse; font-size: .76rem; }
th { padding: 0 8px 10px; color: #958b78; font-size: .62rem; letter-spacing: .07em; text-align: left; text-transform: uppercase; }
td { padding: 13px 8px; border-top: 1px solid var(--line); }
th:first-child, td:first-child { padding-left: 0; }
.client { font-weight: 700; }
.sub { display: block; margin-top: 3px; color: #9a9284; font-size: .63rem; }
.pill { display: inline-block; padding: 5px 7px; border-radius: 99px; color: #69765c; background: #edf0e7; font-size: .64rem; font-weight: 700; }
.amount { white-space: nowrap; font-weight: 700; }
.deposit, .payment { color: #766d61; }
.empty-row { padding: 30px 0; color: var(--taupe); font-size: .78rem; text-align: center; }
.table-wrap { overflow: auto; margin-top: 23px; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 760px; }
.alert { margin: 0 0 18px; padding: 12px 14px; border-radius: 9px; font-size: .78rem; }
.alert.success { color: #385035; border: 1px solid #cbd8c4; background: #edf4e9; }
.alert.error { color: #783b31; border: 1px solid #e4bfb8; background: #fff1ef; }

.auth-page { display: grid; min-height: 100vh; padding: 24px; place-items: center; background: radial-gradient(circle at top left, #e8eadf, var(--cream) 55%); }
.auth-card { width: min(100%, 430px); padding: 38px; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); text-align: center; }
.auth-logo { width: 92px; height: 92px; margin-bottom: 18px; border-radius: 50%; }
.auth-card h1 { margin: 8px 0 10px; font-size: 2.2rem; }
.auth-copy { margin: 0 0 24px; color: var(--taupe); font-size: .82rem; }
.auth-form { display: grid; gap: 9px; text-align: left; }
.auth-form .submit { margin-top: 12px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  aside { position: sticky; top: 0; z-index: 3; flex-direction: row; align-items: center; padding: calc(10px + env(safe-area-inset-top)) 15px 10px; }
  .brand { display: flex; flex: 1; gap: 9px; align-items: center; padding: 0; text-align: left; }
  .brand img { width: 33px; height: 33px; margin: 0; }
  .brand strong { font-size: 1.02rem; }
  .brand small, .nav-label, .access { display: none; }
  .nav { display: flex; }
  .nav a { padding: 9px; }
  .nav a span:last-child { display: none; }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-head { align-items: flex-start; }
}

@media (max-width: 610px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  main { padding: 25px 14px calc(31px + env(safe-area-inset-bottom)); }
  .top { margin-bottom: 22px; }
  h1 { font-size: clamp(1.95rem, 9vw, 2.35rem); line-height: 1.05; }
  h2 { font-size: 1.18rem; }
  .month { display: none; }
  .entry, .chart, .history { padding: 18px 16px; border-radius: 16px; }
  .form { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 13px; }
  .metric strong { display: block; font-size: clamp(1.15rem, 6.2vw, 1.45rem); }
  .metric em { display: block; margin: 4px 0 0; }
  .chart-area { height: 155px; }
  .history { overflow: auto; -webkit-overflow-scrolling: touch; }
  .history table { min-width: 650px; }
  .history::after { content: 'Fais glisser le tableau pour voir toutes les colonnes.'; display: block; padding-top: 12px; color: var(--taupe); font-size: .68rem; }
  .head-actions { gap: 6px; }
  .button-quiet { min-height: 40px; padding: 9px 10px; font-size: .7rem; }
  .see-all { display: none; }
  .auth-card { padding: 28px 22px; }
}

@media (max-width: 390px) {
  aside { padding-right: 10px; padding-left: 10px; }
  .brand strong { font-size: .95rem; }
  .nav { gap: 2px; }
  .nav a { padding: 8px; }
  main { padding-right: 11px; padding-left: 11px; }
  .entry, .chart, .history { padding: 16px 13px; }
  .card-head { gap: 8px; }
  .note { max-width: 95px; text-align: right; }
  .auth-page { padding: 14px; }
  .auth-card { padding: 24px 18px; }
}
