@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

/* ===================== Tokens ===================== */
:root {
    --ink:        #1c1a22;
    --ink-soft:   #3a3644;
    --muted:      #6b6675;
    --paper:      #faf7f4;
    --surface:    #ffffff;
    --border:     #e8e2dc;
    --accent:     #e6396f;
    --accent-dk:  #c72b5c;
    --accent-tint:#fdeef3;
    --ok:         #1f7a52;
    --ok-bg:      #e7f5ee;
    --err:        #b3261e;
    --err-bg:     #fbeae9;
    --warn:       #8a5a00;
    --warn-bg:    #fdf3e2;
    --radius:     14px;
    --radius-sm:  9px;
    --shadow:     0 1px 2px rgba(28,26,34,.05), 0 8px 24px rgba(28,26,34,.06);
    --sans: 'Inter', system-ui, -apple-system, sans-serif;
    --display: 'Space Grotesk', var(--sans);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: var(--sans);
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ===================== Brand ===================== */
.brand {
    font-family: var(--display);
    font-weight: 700;
    letter-spacing: -0.02em;
    font-size: 1.5rem;
    color: var(--ink);
}
.brand span { color: var(--accent); }

/* ===================== Login / Install ===================== */
.login-page, .install-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1200px 500px at 50% -10%, var(--accent-tint), transparent 60%),
        var(--paper);
}
.login-card, .install-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px 34px;
}
.login-card .brand, .install-card .brand { font-size: 1.9rem; }
.login-sub { color: var(--muted); margin: 6px 0 26px; }

.login-card label {
    display: block;
    font-size: .84rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--ink-soft);
}
.login-card input[type=password] {
    width: 100%;
    margin-bottom: 20px;
}

/* ===================== App shell ===================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 246px;
    flex-shrink: 0;
    background: var(--ink);
    color: #d9d5df;
    padding: 26px 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}
.brand-side { color: #fff; }
.brand-side span { color: var(--accent); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: #cfcad6;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.is-active { background: var(--accent); color: #fff; }
.nav-link.is-soon { opacity: .5; pointer-events: none; }
.nav-link em {
    font-style: normal;
    font-size: .64rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    background: rgba(255,255,255,.12);
    padding: 2px 7px;
    border-radius: 20px;
}
.nav-logout {
    color: #948fa0;
    font-size: .88rem;
    padding: 8px 14px;
}
.nav-logout:hover { color: #fff; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    padding: 28px 40px 0;
}
.page-title {
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.7rem;
    letter-spacing: -0.02em;
    margin: 0;
}
.page-body { padding: 24px 40px 60px; max-width: 960px; }

/* ===================== Welcome / cards ===================== */
.welcome-lead { color: var(--muted); font-size: 1.02rem; max-width: 60ch; margin: 4px 0 8px; }

.grid-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 20px 0 34px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow);
}
.card-title { font-size: .8rem; font-weight: 600; color: var(--muted); margin: 0 0 10px; }
.big { font-family: var(--display); font-size: 1.5rem; font-weight: 600; margin: 0 0 4px; }
.muted { color: var(--muted); margin: 2px 0; font-size: .92rem; }
.strong { font-weight: 600; }

/* ===================== Blocks ===================== */
.block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px 28px;
    margin-bottom: 26px;
}
.block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.block-head h2 {
    font-family: var(--display);
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
}

/* ===================== Table ===================== */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    font-size: .78rem;
    font-weight: 600;
    color: var(--muted);
    padding: 0 12px 10px;
    border-bottom: 1px solid var(--border);
}
.table td { padding: 13px 12px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.right { text-align: right; }

/* ===================== Forms ===================== */
.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 18px;
    margin-bottom: 22px;
}
.field { display: flex; flex-direction: column; }
.field-wide { grid-column: 1 / -1; }
.field label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 7px;
}
input[type=text], input[type=email], input[type=password], textarea {
    font-family: var(--sans);
    font-size: .95rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-tint);
}
textarea { resize: vertical; line-height: 1.5; }
textarea.mono { font-family: 'Space Grotesk', ui-monospace, monospace; font-size: .88rem; }
.help { font-size: .82rem; color: var(--muted); margin: 8px 0 0; }
.form-actions { margin-top: 8px; }

/* Formules */
.formules-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.formule-row {
    display: grid;
    grid-template-columns: 1.4fr .7fr 2fr auto auto;
    gap: 14px;
    align-items: end;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--paper);
}
.formule-row.is-off { opacity: .55; }
.formule-new { background: var(--accent-tint); border-color: #f6d3de; }
.field-price { max-width: 120px; }
.formule-actions { display: flex; gap: 8px; }

.switch { display: flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 500; color: var(--ink-soft); padding-bottom: 11px; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ===================== Buttons ===================== */
.btn {
    font-family: var(--sans);
    font-size: .92rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 11px 18px;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dk); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-danger { background: transparent; border-color: #eccaca; color: var(--err); }
.btn-danger:hover { background: var(--err-bg); }
.btn-block { width: 100%; }

/* ===================== Alerts ===================== */
.alert {
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 20px;
    font-size: .93rem;
    line-height: 1.5;
}
.alert ul { margin: 8px 0 0; padding-left: 18px; }
.alert code { background: rgba(0,0,0,.06); padding: 1px 6px; border-radius: 5px; font-family: 'Space Grotesk', monospace; }
.alert-ok   { background: var(--ok-bg);   color: var(--ok);   border: 1px solid #bfe3d0; }
.alert-error{ background: var(--err-bg);  color: var(--err);  border: 1px solid #f0cdca; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #f2ddb0; }
.install-card .btn { margin-top: 6px; display: inline-block; }

/* ===================== Responsive ===================== */
@media (max-width: 820px) {
    .app { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        gap: 16px;
        padding: 14px 18px;
    }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .nav-logout { margin-left: auto; }
    .topbar, .page-body { padding-left: 20px; padding-right: 20px; }
    .grid-cards { grid-template-columns: 1fr; }
    .field-grid { grid-template-columns: 1fr; }
    .formule-row { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
