:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --text: #1d2130;
    --muted: #6b7185;
    --border: #e3e5ee;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --danger: #dc2626;
    --success-bg: #ecfdf3;
    --success-text: #067647;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.1rem; margin-bottom: 1rem; }
.muted { color: var(--muted); margin-top: 0; }

/* Brand */
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-lg { font-size: 1.2rem; margin-bottom: 1.5rem; justify-content: center; }
.brand-mark {
    display: inline-grid; place-items: center;
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--primary); color: #fff; font-size: .8rem; font-weight: 800; letter-spacing: .5px;
}
.brand-mark-xl { width: 64px; height: 64px; border-radius: 16px; font-size: 1.3rem; margin-bottom: 1rem; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.card-head { display: flex; justify-content: space-between; align-items: center; }

/* Guest / auth pages */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; padding: 2rem; }
.switch { text-align: center; margin: 1.25rem 0 0; color: var(--muted); }

.hero { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2rem; }
.hero h1 { font-size: 2.2rem; }
.hero p { color: var(--muted); max-width: 480px; }
.hero-actions { display: flex; gap: .75rem; margin-top: 1rem; flex-wrap: wrap; justify-content: center; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form-inline { flex-direction: row; align-items: flex-start; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: .35rem; }
label { font-weight: 600; font-size: .9rem; }
input[type=text], input[type=email], input[type=password] {
    width: 100%; padding: .65rem .8rem; font: inherit;
    border: 1px solid var(--border); border-radius: 8px; background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
input.invalid { border-color: var(--danger); }
.error { color: var(--danger); font-size: .82rem; }
.hint { color: var(--muted); font-size: .8rem; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .65rem 1.1rem; font: inherit; font-weight: 600;
    border-radius: 8px; border: 1px solid transparent; cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #eef0f6; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-block { width: 100%; }

/* Alerts */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .92rem; }
.alert-success { background: var(--success-bg); color: var(--success-text); border: 1px solid #abefc6; }

/* App shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
    padding: 1.25rem; display: flex; flex-direction: column; gap: 1.5rem;
}
.side-nav { display: flex; flex-direction: column; gap: .25rem; }
.side-nav a { padding: .6rem .8rem; border-radius: 8px; color: var(--muted); font-weight: 500; }
.side-nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.side-nav a.active { background: #eef2ff; color: var(--primary); }
.side-logout { margin-top: auto; }

.main { flex: 1; min-width: 0; }
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 2rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.25rem; margin: 0; }
.content { padding: 2rem; max-width: 1100px; }

.user-chip { display: flex; align-items: center; gap: .6rem; font-weight: 500; }
.avatar {
    display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: #e0e7ff; color: var(--primary); font-weight: 700; font-size: .8rem;
}
.avatar-sm { width: 28px; height: 28px; font-size: .7rem; margin-right: .5rem; vertical-align: middle; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; }
.stat { display: flex; flex-direction: column; gap: .25rem; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-small { font-size: 1.15rem; padding-top: .6rem; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .75rem .5rem; border-bottom: 1px solid var(--border); }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; }
.grid-2 .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 1.5rem; }
.danger-zone { border-color: #fecaca; }
.danger-zone h3 { color: var(--danger); }

@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; align-items: center; flex-wrap: wrap; gap: .75rem; }
    .side-nav { flex-direction: row; }
    .side-logout { margin: 0 0 0 auto; }
    .side-logout .btn-block { width: auto; }
    .topbar, .content { padding: 1rem; }
}

/* ---------- Inquiries ---------- */
.nav-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: .9rem .8rem .3rem; }
.side-nav a { display: flex; justify-content: space-between; align-items: center; }
.badge { background: var(--primary); color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 700; padding: .05rem .5rem; }

select {
    width: 100%; padding: .65rem .8rem; font: inherit;
    border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }

.filters { display: flex; gap: .75rem; flex-wrap: wrap; }
.filters input { flex: 1 1 260px; }
.filters select { width: auto; flex: 0 0 200px; }

.stat-link { color: var(--text); transition: border-color .15s; }
.stat-link:hover { text-decoration: none; border-color: var(--primary); }
.stat-note { color: var(--muted); font-size: .82rem; }

.table { font-size: .92rem; }
.row-link { cursor: pointer; }
.row-link:hover td { background: #f8f9fc; }
.row-link.is-new td { font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85rem; }
.card { overflow-x: auto; }

.pill { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.pill-new { background: #eef2ff; color: var(--primary); }
.pill-read { background: #f2f4f7; color: #475467; }
.pill-replied { background: var(--success-bg); color: var(--success-text); }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
.btn.disabled { opacity: .45; pointer-events: none; }

.grid-detail { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: start; }
.grid-detail > div > .card + .card { margin-top: 1.5rem; }
.details { display: grid; grid-template-columns: 130px 1fr; gap: .55rem 1rem; margin: 0 0 1.5rem; }
.details dt { color: var(--muted); font-size: .88rem; }
.details dd { margin: 0; word-break: break-word; }
.details-small { grid-template-columns: 70px 1fr; font-size: .85rem; margin: 0; }
.message-box { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; line-height: 1.6; }

@media (max-width: 900px) { .grid-detail { grid-template-columns: 1fr; } }
