@import url('https://fonts.bunny.net/css?family=source-sans-3:400,500,600,700|fraunces:600');

:root {
    --ink: #1c1915;
    --muted: #5e584f;
    --paper: #f3efe7;
    --card: #fffdf8;
    --line: #e3dcd0;
    --accent: #3730a3;
    --accent-soft: #eeedfe;
    --good: #0f6e56;
    --warn: #9a6700;
    --bad: #9f1239;
    --shadow: 0 1px 2px rgba(28, 25, 21, 0.06);
    --font: "Source Sans 3", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--paper); font-size: 15px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.shell { display: flex; min-height: 100%; }
.rail {
    width: 228px; background: var(--ink); color: #f6f1e8; display: flex; flex-direction: column;
    padding: 18px 14px; flex-shrink: 0;
}
.brand { display: flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; margin-bottom: 22px; }
.brand strong { display: block; font-family: Fraunces, Georgia, serif; font-size: 16px; font-weight: 600; }
.brand em { display: block; font-style: normal; color: #c8bfb2; font-size: 12px; }
.mark {
    width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
    background: #f3efe7; color: var(--ink); font-family: Fraunces, Georgia, serif; font-weight: 600;
}
.rail nav { display: flex; flex-direction: column; gap: 4px; }
.rail nav a {
    color: #e7e0d6; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-weight: 600;
}
.rail nav a.active, .rail nav a:hover { background: #2a2622; color: white; }
.rail-foot { margin-top: auto; font-size: 13px; }
.rail-foot .who { color: #e7e0d6; margin-bottom: 6px; }
.rail-foot button { background: transparent; color: #c8bfb2; border: 0; padding: 0; }

.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 12px 18px; background: rgba(255, 253, 248, 0.9); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 2;
}
.switcher { display: flex; align-items: center; gap: 8px; }
.switcher select, input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], textarea, select {
    background: white; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.pill { font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: #fff4d6; color: var(--warn); }
.pill.bad { background: #ffe4e6; color: var(--bad); }
.pill.good { background: #e5f6f1; color: var(--good); }
.ghost, .bell {
    background: white; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; text-decoration: none; color: var(--ink);
}
.bell span { background: var(--accent); color: white; border-radius: 99px; padding: 0 6px; margin-left: 4px; font-size: 12px; }
.flash { margin: 12px 18px 0; background: #e5f6f1; border: 1px solid #b7e4d8; padding: 10px 12px; border-radius: 10px; }
.flash.error { background: #fff1f2; border-color: #fecdd3; color: var(--bad); }
.content { padding: 16px 18px 32px; }
.content.bleed { padding: 0; flex: 1; display: flex; min-height: 0; }

.inbox { display: grid; grid-template-columns: 250px minmax(240px, 320px) 1fr 300px; min-height: calc(100vh - 58px); width: 100%; }
.col { border-right: 1px solid var(--line); background: var(--card); min-width: 0; }
.col h2, .panel h2 { font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.filters, .thread, .panel, .chat-list { padding: 14px; }
.filters a, .chat-list a.row {
    display: block; text-decoration: none; color: inherit; padding: 8px 10px; border-radius: 8px;
}
.filters a.active, .filters a:hover, .chat-list a.row:hover, .chat-list a.row.active { background: var(--accent-soft); }
.row small, .muted { color: var(--muted); }
.row strong { display: block; }
.search { margin-bottom: 8px; }

.thread { display: flex; flex-direction: column; background: #f7f4ee; }
.bubbles { display: flex; flex-direction: column; gap: 8px; overflow: auto; max-height: calc(100vh - 280px); padding-bottom: 8px; }
.bubble { max-width: 78%; padding: 8px 10px; border-radius: 12px; background: white; border: 1px solid var(--line); }
.bubble.customer { align-self: flex-start; }
.bubble.ai { align-self: flex-start; border-left: 3px solid var(--accent); background: #f7f6ff; }
.bubble.staff { align-self: flex-end; background: var(--ink); color: #f6f1e8; }
.bubble.note { align-self: center; background: #fff7e0; max-width: 90%; }
.bubble.system { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: 13px; }
.bubble .who { font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; opacity: 0.7; }
.composer, .stack { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.composer textarea, .stack textarea { min-height: 64px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
button.primary, .primary {
    background: var(--accent); color: white; border: 0; border-radius: 8px; padding: 8px 12px; font-weight: 700; text-decoration: none;
}
button.secondary, .secondary { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
button.danger { background: white; color: var(--bad); border: 1px solid #fecdd3; border-radius: 8px; padding: 8px 12px; }

.panel { background: var(--card); }
.draft-card { background: #fff7e0; border: 1px solid #f0d48a; border-radius: 12px; padding: 10px; margin-bottom: 12px; }
.contact-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.board { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 12px; padding: 16px; width: 100%; }
.board section { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 12px; }
.metric, .card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.metric b { display: block; font-size: 26px; font-family: Fraunces, Georgia, serif; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin-top: 8px; }
.bars span { flex: 1; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 4px; position: relative; }
.bars span i { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-style: normal; font-size: 10px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
h1 { font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 32px; margin: 0; }
.steps { display: flex; flex-direction: column; gap: 4px; }
.steps a { text-decoration: none; color: inherit; padding: 8px 10px; border-radius: 8px; }
.steps a.active { background: var(--ink); color: white; }
.setup { display: grid; grid-template-columns: 200px 1fr; gap: 16px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.check { flex-direction: row; align-items: center; font-weight: 500; }
.form-error { color: var(--bad); }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tabs a { text-decoration: none; padding: 6px 10px; border-radius: 999px; background: white; border: 1px solid var(--line); color: inherit; }
.tabs a.active { background: var(--ink); color: white; }
.login-body { background: var(--ink); }
.login { min-height: 100%; display: grid; grid-template-columns: 1.1fr 0.9fr; }
.login-story { color: #f6f1e8; padding: 64px; }
.login-story h1 { font-size: 56px; color: white; }
.eyebrow { letter-spacing: 0.14em; text-transform: uppercase; font-size: 12px; color: #c8bfb2; }
.login-card { margin: 48px; background: var(--card); border-radius: 18px; padding: 28px; align-self: center; }
.demo-accounts { margin-top: 16px; font-size: 13px; color: var(--muted); }
.demo-accounts code { background: var(--paper); padding: 1px 4px; border-radius: 4px; }
.warning-box { background: #fff1f2; border: 1px solid #fecdd3; border-radius: 12px; padding: 12px; color: #6b1028; }
.qr-box { background: white; border: 1px dashed var(--line); padding: 10px; width: fit-content; }
.qr-box svg { width: 180px; height: 180px; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

@media (max-width: 1100px) {
    .inbox { grid-template-columns: 200px 1fr; }
    .panel { grid-column: 1 / -1; }
    .metric-grid, .board, .setup, .login { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .rail { width: 100%; flex-direction: row; align-items: center; gap: 8px; overflow-x: auto; }
    .rail nav { flex-direction: row; }
    .rail-foot { margin-top: 0; }
    .inbox { grid-template-columns: 1fr; }
    .login-story { padding: 28px; }
    .login-story h1 { font-size: 36px; }
}
