* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #1f3d36; background: #f6faf8; }
a { color: #16a085; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.25rem; }
.muted { color: #7c8f88; font-size: 0.875rem; }
pre { white-space: pre-wrap; font-family: inherit; margin: 0; }

/* ====== Layout shell: sidebar | (topbar + content + footer) ====== */
.layout { display: flex; min-height: 100vh; align-items: stretch; }
.main-col { flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }

/* ====== Sidebar ====== */
.sidebar {
    width: 240px; background: #fff; border-right: 1px solid #e6efe9;
    padding: 1rem 0.75rem; display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand {
    display: block; font-size: 1.05rem; padding: 0.25rem 0.5rem 0.75rem;
    text-decoration: none; color: inherit; border-bottom: 1px solid #f0f4f2;
}
.sidebar .brand:hover { text-decoration: none; }
.sidebar .brand-accent { color: #16a085; }
.sidebar .brand-suffix { color: #7c8f88; font-weight: normal; font-size: 0.85rem; margin-left: 0.4rem; }
.sidebar nav { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.75rem; }
.nav-group { display: flex; flex-direction: column; gap: 0.125rem; }
.nav-group-label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: #9aaba4; font-weight: 600; padding: 0 0.75rem 0.25rem;
}
.nav-link {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.45rem 0.75rem; border-radius: 6px; color: #1f3d36;
    font-size: 0.9rem; text-decoration: none;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.nav-link:hover { background: #f0f8f4; text-decoration: none; }
.nav-link.active { background: #16a085; color: #fff; }
.nav-link.active .nav-icon { color: #fff; }
.nav-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.25rem; font-size: 1rem; color: #7c8f88; flex-shrink: 0;
}

/* ====== Topbar ====== */
.topbar {
    height: 56px; background: #fff; border-bottom: 1px solid #e6efe9;
    padding: 0 1.5rem; display: flex; align-items: center; gap: 1rem;
    position: sticky; top: 0; z-index: 10;
}
.topbar-left { flex: 1; max-width: 420px; }
.topbar-search { position: relative; width: 100%; }
.topbar-search input {
    width: 100%; height: 34px; padding: 0 0.75rem;
    border: 1px solid #e6efe9; border-radius: 6px;
    background: #f6faf8; font-size: 0.9rem; font-family: inherit;
}
.topbar-search input:focus { outline: 2px solid rgba(22, 160, 133, 0.25); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.topbar-icon {
    background: none; border: 0; padding: 0.5rem; border-radius: 6px;
    color: #516862; cursor: pointer; position: relative;
    display: inline-flex; align-items: center; justify-content: center;
}
.topbar-icon:hover { background: #f0f8f4; }
.topbar-icon:disabled { cursor: default; opacity: 0.65; }
.topbar-icon-dot {
    position: absolute; top: 8px; right: 8px;
    width: 7px; height: 7px; background: #ef4444;
    border-radius: 50%; border: 2px solid #fff;
}
.topbar-user { position: relative; }
.topbar-user > summary {
    list-style: none; cursor: pointer; display: inline-flex;
    align-items: center; gap: 0.5rem; padding: 0.35rem 0.5rem;
    border-radius: 6px; user-select: none;
}
.topbar-user > summary::-webkit-details-marker { display: none; }
.topbar-user > summary:hover { background: #f0f8f4; }
.topbar-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(22, 160, 133, 0.12); color: #16a085;
    font-weight: 600; font-size: 0.85rem; flex-shrink: 0;
}
.topbar-username {
    font-size: 0.85rem; color: #1f3d36; max-width: 180px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-chevron { color: #7c8f88; }
.topbar-dropdown {
    position: absolute; top: calc(100% + 0.25rem); right: 0;
    min-width: 220px; background: #fff;
    border: 1px solid #e6efe9; border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 0.75rem; z-index: 20;
}
.topbar-dropdown hr { border: 0; border-top: 1px solid #f0f4f2; margin: 0.5rem 0; }
.topbar-dropdown-email { display: block; font-size: 0.8rem; color: #7c8f88; word-break: break-all; }
.topbar-dropdown-logout button {
    width: 100%; background: none; border: 1px solid #e6efe9;
    color: #1f3d36; padding: 0.4rem 0.6rem; border-radius: 6px;
    cursor: pointer; font-size: 0.85rem; text-align: center;
}
.topbar-dropdown-logout button:hover { background: #f0f8f4; }
@media (max-width: 720px) {
    .topbar-search { display: none; }
    .topbar-username { display: none; }
}

/* ====== Content + Footer ====== */
.content { flex: 1; padding: 1.5rem 2rem; overflow: visible; min-width: 0; }
.site-footer {
    margin-top: auto; border-top: 1px solid #e6efe9;
    padding: 1rem 2rem; background: #fff;
    font-size: 0.78rem; color: #7c8f88;
    display: flex; flex-wrap: wrap; justify-content: space-between;
    align-items: center; gap: 0.75rem;
}
.site-footer .footer-links { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.site-footer .footer-links a { color: #516862; }
.site-footer .footer-links .sep { color: #c8d6d1; }

/* ====== Cards / Tables / Filters / Badges ====== */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.stat-card { display: block; background: #fff; border: 1px solid #e6efe9; border-radius: 8px; padding: 1rem; }
.stat-card:hover { border-color: #16a085; text-decoration: none; }
.stat-value { font-size: 2rem; font-weight: 700; color: #0f2a25; }
.stat-title { font-size: 0.85rem; color: #7c8f88; margin-top: 0.25rem; }

.data { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e6efe9; border-radius: 8px; overflow: hidden; font-size: 0.9rem; }
.data th, .data td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid #f0f4f2; vertical-align: top; }
.data th { background: #f8fafa; font-weight: 600; color: #516862; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.data tr:last-child td { border-bottom: none; }
.data tr:hover { background: #f8fafa; }
.data .categories { font-size: 0.8rem; color: #516862; }

.filters { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input, .filters select { height: 34px; padding: 0 0.5rem; border: 1px solid #d3ece0; border-radius: 4px; font-size: 0.9rem; background: #fff; }
.filters button, button { background: #16a085; color: #fff; border: none; border-radius: 4px; padding: 0.45rem 0.9rem; cursor: pointer; font-size: 0.9rem; }
.filters button:hover, button:hover { background: #138a72; }
button:disabled { background: #b0c5be; cursor: not-allowed; }
.link { background: none; color: #16a085; padding: 0; cursor: pointer; border: none; }
.link:hover { background: none; text-decoration: underline; }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 500; }
.badge.ok { background: #d3ece0; color: #0f2a25; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.info { background: #dbeafe; color: #1e40af; }
.badge.muted { background: #f0f4f2; color: #7c8f88; }
.badge.danger { background: #fee2e2; color: #991b1b; }

/* ====== Login (z _Layout, ale strona renders bez sidebar/topbar przez EmptyLayout) ====== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f6faf8; }
.login-card { background: #fff; padding: 2rem; border-radius: 12px; border: 1px solid #e6efe9; min-width: 360px; }
.login-card h1 { margin: 0 0 0.25rem; }
.login-card label { display: block; margin: 1rem 0 0.25rem; font-size: 0.85rem; color: #516862; }
.login-card input { width: 100%; height: 38px; padding: 0 0.6rem; border: 1px solid #d3ece0; border-radius: 4px; font-size: 0.95rem; }
.login-card button { width: 100%; padding: 0.6rem; margin-top: 1rem; font-size: 0.95rem; }
.error { background: #fee2e2; color: #991b1b; padding: 0.5rem 0.75rem; border-radius: 4px; margin: 0.75rem 0; font-size: 0.85rem; }

/* ====== Ticket detail ====== */
.ticket-status-row { display: flex; gap: 0.75rem; align-items: center; margin: 1rem 0; }
.ticket-status-row select { height: 32px; padding: 0 0.5rem; }
.message-box { background: #fff; border: 1px solid #e6efe9; border-radius: 8px; padding: 1rem; margin: 1rem 0; }
.reply { background: #fff; border: 1px solid #e6efe9; border-radius: 8px; padding: 0.75rem 1rem; margin: 0.5rem 0; }
.reply.internal { background: #fefcbf; border-color: #fbcb24; }
.reply-meta { font-size: 0.8rem; color: #7c8f88; margin-bottom: 0.5rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.reply-form { background: #fff; border: 1px solid #e6efe9; border-radius: 8px; padding: 1rem; margin-top: 1.5rem; }
.reply-form textarea { width: 100%; padding: 0.6rem; border: 1px solid #d3ece0; border-radius: 4px; font-family: inherit; font-size: 0.9rem; }
.reply-form .checkbox { display: block; margin: 0.5rem 0; font-size: 0.85rem; }

/* ====== Page chrome / buttons ====== */
.page-header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-header-row h1 { margin: 0; }
.button-primary { display: inline-block; background: #16a085; color: #fff; padding: 0.5rem 0.9rem; border-radius: 4px; text-decoration: none; font-size: 0.9rem; border: 0; cursor: pointer; }
.button-primary:hover { background: #138a72; text-decoration: none; }
.button-secondary { display: inline-block; background: #fff; color: #16a085; padding: 0.4rem 0.85rem; border: 1px solid #c8d6d1; border-radius: 4px; text-decoration: none; font-size: 0.85rem; cursor: pointer; }
.button-secondary:hover { background: #f0f8f4; border-color: #16a085; text-decoration: none; }
.button-danger { display: inline-block; background: #ef4444; color: #fff; padding: 0.4rem 0.85rem; border-radius: 4px; text-decoration: none; font-size: 0.85rem; border: 0; cursor: pointer; }
.button-danger:hover { background: #dc2626; }

/* ====== Forms ====== */
.form-stack { display: flex; flex-direction: column; gap: 0.75rem; max-width: 720px; margin-top: 1rem; }
.form-stack label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: #516862; }
.form-stack input[type="text"], .form-stack input[type="datetime-local"], .form-stack input[type="number"], .form-stack input[type="date"], .form-stack select, .form-stack textarea {
    padding: 0.45rem 0.6rem; border: 1px solid #d3ece0; border-radius: 4px; font: inherit; background: #fff;
}
.form-stack textarea { resize: vertical; min-height: 240px; font-family: ui-monospace, "Cascadia Code", "JetBrains Mono", "Consolas", monospace; font-size: 0.85rem; line-height: 1.5; }
.form-stack button[type="submit"] { align-self: flex-start; padding: 0.55rem 1.1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-row label { font-size: 0.85rem; color: #516862; display: flex; flex-direction: column; gap: 0.25rem; }
.form-row input { padding: 0.45rem 0.6rem; border: 1px solid #d3ece0; border-radius: 4px; font: inherit; }

/* ====== CRUD toolbar ====== */
.crud-toolbar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.crud-actions { display: flex; gap: 0.25rem; }
