:root {
    --primary: #2563eb;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}
.logo {
    display: inline-flex; align-items: center; gap: 6px;
    font-weight: 600; text-decoration: none; color: var(--text);
}
.topbar nav { display: flex; align-items: center; gap: 14px; }
.link-muted { color: var(--muted); text-decoration: none; }
.link-muted:hover { color: var(--text); }

.app-shell { display: flex; min-height: 100vh; }
.app-content { flex: 1; min-width: 0; }

.sidebar {
    width: 200px; flex-shrink: 0;
    display: flex; flex-direction: column;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
}
.sidebar-logo {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; text-decoration: none; color: var(--text);
    padding: 4px 8px; margin-bottom: 20px; font-size: 15px;
}
.sidebar-logo .ti { font-size: 20px; color: var(--primary); }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 10px;
    color: var(--text); text-decoration: none; font-size: 14px;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.sidebar-link .ti { font-size: 18px; color: var(--muted); }
.sidebar-link:hover { background: var(--bg); }
.sidebar-link-disabled { color: var(--muted); cursor: not-allowed; opacity: 0.6; }
.sidebar-link-disabled:hover { background: none; }

.sidebar-user {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 8px; margin-top: 12px;
    border-top: 1px solid var(--border);
}
.sidebar-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
    font-size: 13px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-user-role { font-size: 12px; color: var(--muted); }
.sidebar-logout-form { margin: 0; }
.sidebar-logout-btn {
    background: none; border: none; padding: 6px; border-radius: 8px;
    color: var(--muted); cursor: pointer; font-size: 16px; display: flex;
}
.sidebar-logout-btn:hover { background: var(--bg); color: var(--text); }

.mobile-topbar { display: none; }
.sidebar-overlay { display: none; }
.hamburger-btn {
    background: none; border: none; font-size: 22px;
    color: var(--text); cursor: pointer; padding: 4px; border-radius: 8px;
    display: flex;
}
.hamburger-btn:hover { background: var(--bg); }

.container { max-width: 960px; margin: 0 auto; padding: 24px; }

.btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
}
.btn:hover { opacity: 0.9; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-outline {
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; font-size: 14px; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
    padding: 5px 10px; border-radius: 14px; font-size: 13px;
    background: #fff; border: 1px solid var(--border);
    color: var(--muted); text-decoration: none;
}
.chip-active { background: var(--primary); color: #fff; border-color: var(--primary); }

.request-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
}
.request-card {
    text-decoration: none; color: var(--text); display: block;
    transition: border-color 0.15s ease;
}
.request-card:hover { border-color: var(--primary); }
.card-top { display: flex; justify-content: space-between; margin-bottom: 6px; }
.card-bottom { display: flex; justify-content: space-between; margin-top: 8px; font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }

.badge {
    padding: 2px 10px; border-radius: 10px; font-size: 12px; color: #fff;
}
.badge-new { background: #6c757d; }
.badge-assigned { background: #0d6efd; }
.badge-in_progress { background: #fd7e14; }
.badge-done { background: #20c997; }
.badge-confirmed { background: #198754; }
.badge-closed { background: #343a40; }
.badge-cancelled { background: #adb5bd; }
.badge-dispute { background: #dc3545; }

.form { max-width: 480px; }
.form-narrow { max-width: 320px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 500; }
.form-row input, .form-row select, .form-row textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px; font-family: inherit;
}
.field-error { color: #dc2626; font-size: 13px; margin-top: 4px; }

.detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.detail-main .card { margin-bottom: 16px; }
.meta-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; }

.status-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.inline-form { display: inline; }

.event-list { list-style: none; padding: 0; font-size: 13px; }
.event-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }

.chat-box {
    max-height: 360px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px;
}
.chat-message {
    background: #fff; border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 10px; font-size: 14px; max-width: 90%;
}
.chat-mine { background: #dbeafe; align-self: flex-end; }
.chat-meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.chat-form { display: flex; gap: 8px; }
.chat-form textarea { flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; }

.empty-state { color: var(--muted); }

.confirm-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 1000;
}
.confirm-modal-overlay.is-open { display: flex; }
.confirm-modal-overlay.is-visible { opacity: 1; }

.confirm-modal {
    width: 100%;
    max-width: 360px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
}
.confirm-modal-text { margin: 0 0 16px; color: var(--text); font-size: 14px; }
.confirm-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

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

@media (max-width: 768px) {
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100%; z-index: 901;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 0 0 30px rgba(15, 23, 42, 0.15);
    }
    .sidebar.is-open { transform: translateX(0); }

    .sidebar-overlay {
        display: block;
        position: fixed; inset: 0; z-index: 900;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0; pointer-events: none;
        transition: opacity 0.2s ease;
    }
    .sidebar-overlay.is-open { opacity: 1; pointer-events: auto; }

    .mobile-topbar {
        display: flex; align-items: center; gap: 12px;
        padding: 12px 16px;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border);
    }
}
