/* ============================================================
   Merkora — Shared Design System
   ============================================================ */

/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue:      #2563eb;
    --blue-dark: #1d4ed8;
    --blue-light:#dbeafe;
    --blue-pale: #eff6ff;
    /* Brand primary (emerald) — kept in sync with style.css so primary buttons
       look identical on shell pages (merkora.css only) and content pages
       (style.css), regardless of stylesheet load order. */
    --primary:       #10b981;
    --primary-hover: #059669;
    --green:     #16a34a;
    --amber:     #d97706;
    --red:       #dc2626;
    --red-pale:  #fef2f2;
    --text:      #1e293b;
    --text-muted:#64748b;
    --border:    #e2e8f0;
    --bg:        #f1f5f9;
    --white:     #ffffff;
    --sidebar-w: 220px;
    --topbar-h:  52px;
    --radius:    8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,.10);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
    padding-top: var(--topbar-h);
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 1000;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.topbar-left  { display: flex; align-items: center; gap: .75rem; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }

.sidebar-toggle {
    background: none; border: none; color: #bfdbfe;
    font-size: 1.1rem; cursor: pointer; padding: .25rem .35rem;
    border-radius: 4px; line-height: 1;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.15); color: #fff; }

.topbar-logo { color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: -.3px; }
.topbar-logo:hover { text-decoration: none; opacity: .9; }

.topbar-module { color: #93c5fd; font-size: .85rem; }

.tenant-badge {
    display: flex; align-items: center; gap: .35rem;
    background: rgba(255,255,255,.12);
    border-radius: 20px;
    padding: .2rem .65rem;
    font-size: .8rem; color: #bfdbfe;
}

.topbar-user { display: flex; align-items: center; gap: .3rem; font-size: .85rem; color: #bfdbfe; }
.logout-form { display: inline; }
.btn-link {
    background: none; border: none; color: #93c5fd;
    cursor: pointer; font-size: .8rem; padding: .15rem .35rem;
    border-radius: 4px;
}
.btn-link:hover { color: #fff; background: rgba(255,255,255,.12); }
.topbar-signout { font-size: .8rem; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: var(--topbar-h); left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    transition: transform .2s ease;
    z-index: 900;
}

body.sidebar-collapsed .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
body.sidebar-collapsed .page-content { margin-left: 0; }

.sidebar-nav { list-style: none; padding: .75rem 0; }
.sidebar-nav li { margin: .15rem .5rem; }

.sidebar-link {
    display: flex; align-items: center; gap: .6rem;
    padding: .5rem .75rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: .875rem;
    transition: background .12s, color .12s;
}
.sidebar-link:hover { background: var(--blue-pale); color: var(--blue); text-decoration: none; }
.sidebar-link.active { background: var(--blue-pale); color: var(--blue); font-weight: 600; }

.sidebar-section {
    padding: .5rem 1.25rem .25rem;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: .5rem;
}

.nav-icon { font-size: .95rem; width: 1.2rem; text-align: center; }

/* ── Page content area ─────────────────────────────────────── */
.page-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;            /* allow flex item to shrink so wide content scrolls inside, not the page */
    padding: 1.5rem;
    transition: margin-left .2s ease;
}

/* ── Page header ───────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-title { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: .85rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.card-header {
    padding: .9rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-weight: 600; font-size: .95rem; }
.card-body { padding: 1.25rem; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .45rem 1rem;
    border-radius: 6px;
    font-size: .85rem; font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .12s, border-color .12s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: #94a3b8; background: var(--bg); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-xs { padding: .2rem .55rem; font-size: .75rem; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: .8rem; font-weight: 600;
    color: #475569; margin-bottom: .35rem;
}
.form-control {
    width: 100%;
    padding: .55rem .85rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .875rem;
    background: #fff;
    outline: none;
    transition: border-color .15s;
}
.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-check { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.form-check input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--blue); }
.form-check-label { font-size: .875rem; color: var(--text); cursor: pointer; }

/* ── Tables ────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
    text-align: left;
    padding: .65rem 1rem;
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    font-weight: 600; font-size: .8rem;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .04em;
}
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .2rem .5rem;
    border-radius: 20px;
    font-size: .72rem; font-weight: 600;
    white-space: nowrap;
}
.badge-blue   { background: var(--blue-light); color: var(--blue-dark); }
.badge-green  { background: #dcfce7; color: var(--green); }
.badge-amber  { background: #fef3c7; color: var(--amber); }
.badge-red    { background: var(--red-pale); color: var(--red); }
.badge-grey   { background: #f1f5f9; color: var(--text-muted); }

/* Locked fiscal-year badge (shared by Books receipts / bank / invoices) */
.badge-lock{display:inline-flex;align-items:center;gap:4px;padding:2px 10px;border-radius:99px;font-size:.75rem;font-weight:600;background:#fef3c7;color:#92400e;}

/* ── shared status pills — one semantic palette across modules ── */
.mkpill{display:inline-flex;align-items:center;gap:6px;padding:2px 10px;border-radius:99px;font-size:.72rem;font-weight:700;white-space:nowrap;}
.mkpill.grey{background:#f1f5f9;color:#475569;}      /* draft / inactive / archived */
.mkpill.amber{background:#fff3da;color:#9a6a12;}     /* pending / submitted / waiting */
.mkpill.green{background:#dcfce7;color:#15803d;}     /* active / approved / paid */
.mkpill.blue{background:#dbeafe;color:#1d4ed8;}      /* info / in-progress */
.mkpill.violet{background:#ede9fe;color:#6d28d9;}    /* done / reimbursed / issued */
.mkpill.red{background:#fee2e2;color:#b91c1c;}       /* rejected / breached / danger */

/* ── breadcrumb (flow-v2 look, shared) ─────────────────────── */
.crumb{font-size:13px;color:#8a93a0;font-weight:600;display:flex;align-items:center;gap:7px;margin-bottom:11px;}
.crumb a{color:inherit;} .crumb a:hover{color:#1f57c4;} .crumb .sep{color:#e4e8ee;} .crumb b{color:#1e2530;}

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
    padding: .7rem 1rem;
    border-radius: 6px;
    font-size: .875rem;
    margin-bottom: 1rem;
    display: flex; align-items: flex-start; gap: .5rem;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-error   { background: var(--red-pale); border: 1px solid #fca5a5; color: var(--red); }
.alert-info    { background: var(--blue-pale); border: 1px solid #bfdbfe; color: var(--blue-dark); }

/* ── Module cards (dashboard) ──────────────────────────────── */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.module-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 1.25rem 1rem;
    text-decoration: none; color: inherit;
    transition: box-shadow .15s, border-color .15s;
    display: block;
}
.module-card:hover { box-shadow: var(--shadow-md); border-color: #93c5fd; text-decoration: none; }
.module-card-icon  { font-size: 1.75rem; margin-bottom: .6rem; }
.module-card-title { font-weight: 700; font-size: .95rem; color: var(--text); }
.module-card-desc  { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; line-height: 1.5; }
.module-card-badge { margin-top: .5rem; }

/* ── Module chips ──────────────────────────────────────────── */
.module-chip {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .75rem; padding: .2rem .55rem;
    border-radius: 20px; font-weight: 500;
}
.module-chip.on  { background: #dcfce7; color: #15803d; }
.module-chip.off { background: #f1f5f9; color: var(--text-muted); text-decoration: line-through; }

/* ── Login page ────────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
}
.login-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 2.5rem;
    width: 100%; max-width: 380px;
}
.login-logo h1 { font-size: 1.75rem; font-weight: 700; color: var(--blue); letter-spacing: -.5px; text-align: center; }
.login-logo p  { font-size: .8rem; color: var(--text-muted); text-align: center; margin-top: .25rem; margin-bottom: 1.75rem; }

/* ── Misc helpers ──────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: .8rem; }
.fw-600      { font-weight: 600; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.flex-end { justify-content: flex-end; }
.flex-between { justify-content: space-between; }
