:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-muted: #f8fbff;
    --border: #dbe6f3;
    --text: #112132;
    --muted: #60758c;
    --primary: #1070d6;
    --primary-dark: #0c5caf;
    --accent: #18a789;
    --danger: #cf4e5e;
    --warning: #db8c1d;
    --shadow: 0 20px 40px rgba(14, 36, 63, 0.08);
    --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--text); }
body.modal-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; }

.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.main-content { min-height: calc(100vh - 180px); }
.public-header { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 0; }
.brand { display: inline-flex; align-items: center; gap: 14px; }
.brand strong { display: block; font-size: 1rem; }
.brand small { color: var(--muted); display: block; margin-top: 4px; }
.brand-mark { width: 42px; height: 42px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), #55a5ff); color: #fff; display: grid; place-items: center; font-weight: 700; }
.top-nav, .footer-links, .admin-topbar-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.top-nav form, .admin-topbar-actions form { margin: 0; display: inline-flex; }
.top-nav a { color: var(--muted); font-weight: 600; }
.top-nav a.active, .top-nav a:hover { color: var(--text); }
.public-footer { border-top: 1px solid var(--border); background: #fff; margin-top: 64px; }
.footer-row { display: flex; justify-content: space-between; gap: 24px; padding: 28px 0; color: var(--muted); }

.hero { background: linear-gradient(180deg, #1275db, #0e66bc); color: #fff; padding: 72px 0 110px; border-radius: 0 0 38px 38px; }
.hero-inner { max-width: 860px; margin: 0 auto; text-align: center; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .76rem; color: rgba(255,255,255,.72); margin-bottom: 14px; }
.hero h1 { font-size: clamp(2.6rem, 6vw, 4.8rem); line-height: 1.05; margin: 0 0 16px; }
.hero p { font-size: 1.08rem; color: rgba(255,255,255,.84); margin: 0 auto 28px; max-width: 700px; }
.search-card { background: rgba(7, 19, 33, .2); border: 1px solid rgba(255,255,255,.16); padding: 14px; border-radius: 24px; display: flex; gap: 12px; box-shadow: var(--shadow); }
.search-card input { flex: 1; border: 0; border-radius: 16px; padding: 18px 20px; background: #fff; color: var(--text); }
.hero-tags { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.hero-tags span { background: rgba(255,255,255,.14); border-radius: 999px; padding: 10px 14px; font-size: .9rem; }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.section { margin-top: -56px; }
.section + .section-normal { margin-top: 38px; }
.section-normal { padding-top: 30px; }
.card, .panel, .metric, .article-card, .app-card, .category-card, .ticket-card, .install-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card, .panel, .install-card { padding: 26px; }
.soft-card { background: var(--surface-muted); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 14px; margin-bottom: 18px; }
.section-heading h2, .section-heading h3 { margin: 0; font-size: 1.7rem; }
.section-heading p { margin: 6px 0 0; color: var(--muted); }

.category-card, .app-card, .article-card, .ticket-card, .metric { padding: 22px; }
.category-icon { width: 52px; height: 52px; border-radius: 16px; background: linear-gradient(180deg, #eef6ff, #ddecff); display: grid; place-items: center; color: var(--primary); font-weight: 700; margin-bottom: 16px; }
.article-meta, .ticket-meta, .meta { color: var(--muted); font-size: .92rem; display: flex; gap: 12px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 700; cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-soft { background: #eef5fc; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: #fff1f3; color: var(--danger); border: 1px solid #f4c3ca; }
.btn-block { width: 100%; }

.flash { margin-top: 16px; padding: 14px 18px; border-radius: 14px; border: 1px solid var(--border); }
.flash-success { background: #ebfff8; color: #136954; border-color: #bde7d9; }
.flash-error { background: #fff2f3; color: #9f3140; border-color: #efc7cd; }
.flash-admin { margin-bottom: 20px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field label { font-weight: 700; }
.field small { color: var(--muted); }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--border); background: #fff; border-radius: 14px; padding: 14px 16px; color: var(--text); }
.field textarea { min-height: 160px; resize: vertical; }

.badge { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 999px; font-size: .83rem; font-weight: 700; }
.badge-info { background: #e8f3ff; color: #1362c5; }
.badge-success { background: #e7fbf4; color: #13745a; }
.badge-warning { background: #fff5e6; color: #8f5d11; }
.badge-danger { background: #fff2f3; color: #a53545; }
.badge-muted { background: #eef3f7; color: #5f7287; }

.page-header { padding: 34px 0 18px; }
.page-header h1 { margin: 0 0 8px; font-size: 2.2rem; }
.page-header p { margin: 0; color: var(--muted); max-width: 760px; }

.split-layout { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(320px, .9fr); gap: 22px; align-items: start; }
.stack { display: grid; gap: 22px; }

.conversation { display: grid; gap: 16px; }
.message { padding: 18px; border-radius: 18px; border: 1px solid var(--border); background: #fff; }
.message.internal { background: #fff8eb; border-color: #f0dbaf; }
.message header { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.message .author { font-weight: 700; }
.message .date { color: var(--muted); font-size: .9rem; }

.data-list { display: grid; gap: 12px; }
.data-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.data-row:last-child { border-bottom: 0; }

.admin-body { background: #eef4fa; }
.admin-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.admin-sidebar { background: #ffffff; border-right: 1px solid var(--border); padding: 26px 18px; }
.admin-nav { display: grid; gap: 8px; margin-top: 28px; }
.admin-nav a { padding: 12px 14px; border-radius: 14px; color: var(--muted); font-weight: 700; }
.admin-nav a.active, .admin-nav a:hover { background: #edf5fe; color: var(--primary); }
.admin-main { padding: 24px 28px; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 22px; }
.admin-topbar h1 { margin: 0 0 4px; font-size: 1.6rem; }
.admin-topbar p { margin: 0; color: var(--muted); }
.admin-content { display: grid; gap: 22px; }
.agent-pill { padding: 10px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--border); font-weight: 700; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.metric strong { display: block; font-size: 2rem; margin-top: 10px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }

.confirm-shell { position: fixed; inset: 0; background: rgba(11, 23, 40, 0.56); display: grid; place-items: center; padding: 24px; z-index: 50; }
.confirm-shell[hidden] { display: none !important; }
.confirm-card { width: min(460px, 100%); background: #fff; border-radius: 22px; border: 1px solid var(--border); box-shadow: var(--shadow); padding: 28px; }
.confirm-card h3 { margin-top: 0; }
.confirm-actions { display: flex; justify-content: end; gap: 12px; margin-top: 20px; }

.empty-state { padding: 32px; text-align: center; color: var(--muted); }
.breadcrumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; color: var(--muted); font-size: .92rem; }
.attachments-list { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; background: #eef5fc; border: 1px solid var(--border); border-radius: 999px; font-size: .9rem; }
.search-inline { display: flex; gap: 12px; }
.search-inline input { flex: 1; }

@media (max-width: 1024px) {
    .grid-3, .metrics-grid, .split-layout, .form-grid { grid-template-columns: 1fr; }
    .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
}

@media (max-width: 760px) {
    .header-row, .footer-row, .admin-topbar { flex-direction: column; align-items: start; }
    .hero { padding-top: 52px; border-radius: 0 0 24px 24px; }
    .search-card { flex-direction: column; }
    .container { width: min(100% - 20px, 1180px); }
}
