:root {
    --bg-1: #f2f6ff;
    --bg-2: #eefcf5;
    --surface: #ffffff;
    --text: #1c2533;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-2: #1d4ed8;
    --success: #15803d;
    --warning: #b45309;
    --danger: #b91c1c;
    --border: #d9e3f3;
    --shadow: 0 16px 32px rgba(29, 59, 110, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 0%, #e8f0ff 0%, transparent 40%),
        radial-gradient(circle at 88% 4%, #ddfbe9 0%, transparent 34%),
        linear-gradient(160deg, #f9fcff 0%, #f4f9ff 50%, #f8fdf9 100%);
}

.app-nav {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.brand-logo {
    width: 64px;
    height: 34px;
    object-fit: contain;
}

.app-toggler {
    border: 1px solid var(--border);
}

.app-menu .btn {
    border: 1px solid var(--border);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    height: 34px;
    min-height: 34px;
    line-height: 1;
}

.app-menu {
    display: flex;
    align-items: center;
}

.app-menu .btn.btn-light {
    background: #ffffff;
}

.app-menu .btn.btn-light:hover {
    background: #f1f6ff;
    border-color: #bcd0ee;
}

.min-vh-100 {
    min-height: 100dvh;
}

.card {
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    background: var(--surface);
}

.page-head {
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.page-head-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.page-head-actions form {
    margin: 0;
    display: flex;
    align-items: center;
}

.page-head-actions .btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
}

.page-head-actions .btn.btn-sm {
    height: 36px;
    min-height: 36px;
    line-height: 1;
}

.page-head h5,
h5 {
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.page-sub {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.table-shell {
    border: 1px solid #e4ecf8;
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
}

.table {
    margin-bottom: 0;
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    border-bottom-color: #e6edf7;
}

.table thead th,
.table tr:first-child th {
    background: #f7faff;
    color: #334155;
    font-weight: 700;
}

.form-control,
.form-select {
    border-color: #cfd9ea;
    border-radius: 10px;
}

.form-control:focus,
.form-select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.15);
}

.btn {
    border-radius: 10px;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border: 0;
}

.btn-primary:hover {
    filter: brightness(0.97);
}

.app-alert {
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 500;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-pending { color: #8a4b00; background: #ffedd5; }
.status-processing { color: #1e3a8a; background: #dbeafe; }
.status-done { color: #14532d; background: #dcfce7; }
.status-rejected { color: #7f1d1d; background: #fee2e2; }
.status-default { color: #374151; background: #eef2f7; }

.password-wrap .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.password-wrap .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    width: 48px;
    min-width: 48px;
}

.auth-shell {
    width: 100%;
    margin-top: 10px;
    display: grid;
    grid-template-columns: minmax(320px, 560px);
    justify-content: center;
}

.auth-card {
    padding: 28px;
    border-radius: 18px;
}

.auth-title {
    margin-bottom: 4px;
    font-size: 2rem;
    font-weight: 800;
}

.auth-sub {
    color: var(--muted);
    margin-bottom: 18px;
}

.auth-divider {
    text-align: center;
    color: #64748b;
    margin: 12px 0;
    position: relative;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 34%;
    height: 1px;
    background: #d9e2f0;
}

.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

.auth-google {
    width: 100%;
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.home-hero {
    width: 100%;
    margin-top: 6px;
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 18px;
}

.hero-main {
    padding: 34px;
    border-radius: 20px;
    background: linear-gradient(145deg, #0f172a, #1e3a8a 55%, #2563eb);
    color: #e9f1ff;
    box-shadow: 0 22px 48px rgba(30, 58, 138, 0.32);
}

.hero-main h1 {
    font-size: 2.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}

.hero-main p {
    color: #d8e6ff;
    margin-bottom: 22px;
}

.hero-cta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hero-kpis {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.hero-kpi {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 10px 12px;
}

.hero-kpi strong {
    display: block;
    color: #fff;
    font-size: 1.05rem;
}

.hero-kpi span {
    color: #d6e4ff;
    font-size: 0.85rem;
}

.home-side {
    display: grid;
    gap: 14px;
}

.mini-card {
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    background: #fff;
    padding: 18px;
}

.mini-card h6 {
    margin: 0 0 8px;
    font-size: 1rem;
    font-weight: 700;
}

.mini-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.section-grid {
    width: 100%;
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.section-card {
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    background: #fff;
    padding: 20px;
}

.section-card .icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e0ecff;
    color: #1d4ed8;
    margin-bottom: 10px;
}

.section-card h6 {
    margin-bottom: 6px;
    font-weight: 700;
}

.section-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

.stat-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    background: #fff;
}

.stat-label {
    color: var(--muted);
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.45rem;
    font-weight: 750;
    line-height: 1.1;
}

.info-box {
    border: 1px dashed #c6d4eb;
    border-radius: 12px;
    padding: 10px 12px;
    background: #f8fbff;
    color: #334155;
    font-size: 0.92rem;
}

.chat-window {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #fcfdff;
    max-height: 480px;
    overflow-y: auto;
}

.new-msg-indicator {
    display: none;
}

.new-msg-indicator.show {
    display: inline-flex;
}

.chat-item {
    max-width: 86%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #e3ebf7;
    margin-bottom: 8px;
    background: #fff;
}

.chat-item.mine {
    margin-left: auto;
    background: #eff6ff;
    border-color: #bfdbfe;
}

.chat-item.theirs {
    margin-right: auto;
}

.chat-item .chat-meta {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.media-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.media-thumb {
    width: 92px;
    height: 68px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid #dbe6f7;
    cursor: pointer;
    background: #f8fbff;
}

.media-full {
    max-width: 100%;
    max-height: 72dvh;
    border-radius: 10px;
}

.selected-file-list {
    display: grid;
    gap: 6px;
    margin: -4px 0 10px;
}

.selected-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 10px;
    border: 1px solid #dbe6f7;
    border-radius: 10px;
    background: #f8fbff;
    color: #334155;
    font-size: 0.9rem;
}

.selected-file-item span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ticket-content-cell {
    max-width: 360px;
    white-space: normal;
    line-height: 1.35;
}

.internal-note-card {
    border-left: 4px solid #f59e0b;
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 10px 12px;
    align-items: start;
    padding: 12px 16px !important;
    margin-bottom: 12px !important;
}

.internal-note-inline {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e6edf7;
}

.compact-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.internal-note-inline .internal-note-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: end;
    margin-bottom: 10px;
}

.internal-note-inline textarea {
    min-height: 72px;
    height: 72px;
}

.internal-note-inline .btn {
    height: 38px;
    white-space: nowrap;
}

.internal-note-inline .internal-note-list {
    display: grid;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
}

.internal-note-list {
    display: grid;
    gap: 8px;
    grid-column: 2;
    grid-row: 1 / span 2;
    max-height: 112px;
    overflow-y: auto;
}

.internal-note-item {
    padding: 10px 12px;
    border: 1px solid #fde2b1;
    border-radius: 10px;
    background: #fffaf0;
}

.internal-note-card .page-head {
    margin-bottom: 0;
}

.internal-note-card form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: end;
    margin-bottom: 0 !important;
}

.internal-note-card textarea {
    min-height: 54px;
    height: 54px;
}

.internal-note-card .btn {
    height: 38px;
    white-space: nowrap;
}

.internal-note-card .page-sub {
    font-size: 0.88rem;
}

.ticket-summary-card {
    margin-bottom: 10px !important;
}

.ticket-summary-card .page-head {
    margin-bottom: 10px;
}

.ticket-summary-card .info-box {
    padding: 8px 12px;
}

.admin-ticket-detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: start;
}

.admin-ticket-side {
    display: none;
    gap: 14px;
}

.ticket-status-card select {
    border-color: #f59e0b;
    background: #fff7d6;
}

.internal-note-side textarea {
    min-height: 108px;
}

.internal-note-side .internal-note-form {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
}

.internal-note-side .internal-note-list {
    display: grid;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.ticket-reply-card .internal-note-inline {
    display: block;
}

.ticket-chat-card,
.ticket-reply-card {
    min-height: 100%;
    padding: 14px 16px !important;
}

.ticket-chat-card .chat-window {
    height: min(58dvh, 560px);
    max-height: none;
}

.ticket-reply-card textarea[name="message"] {
    min-height: 90px;
}

.ticket-two-col {
    gap: 12px;
}

.ticket-reply-card .row {
    align-items: center;
}

.ticket-reply-card .col-md-4 {
    flex: 0 0 34%;
    max-width: 34%;
}

.ticket-reply-card .col-md-5 {
    flex: 0 0 36%;
    max-width: 36%;
}

.ticket-reply-card .col-md-3 {
    flex: 0 0 30%;
    max-width: 30%;
}

.vote-card {
    border: 1px solid #dbe6f7 !important;
}

.vote-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.vote-mail-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.vote-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.vote-option-row {
    border: 1px solid #dbe6f7;
    border-radius: 12px;
    padding: 10px 12px;
    background: #ffffff;
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 10px;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.vote-option-row:hover {
    border-color: #9ec5ff;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.08);
}

.vote-option-row.selected {
    border-color: #93c5fd;
    background: #eff6ff;
}

.vote-option-input {
    margin: 0;
}

.vote-option-content {
    display: grid;
    gap: 6px;
}

.vote-option-title {
    font-weight: 600;
    color: #1f2937;
}

.vote-option-percent {
    font-size: 0.82rem;
    color: #64748b;
}

.vote-option-bar {
    height: 6px;
    border-radius: 999px;
    background: #e9f1ff;
    overflow: hidden;
}

.vote-option-bar > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
}

.ticket-two-col {
    display: grid;
    grid-template-columns: 6fr 4fr;
    gap: 12px;
}

.quick-update-cell {
    min-width: 210px;
    display: flex;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 8px;
}

.quick-update-cell .form-select {
    height: 38px;
    min-height: 38px;
}

.quick-update-cell .btn {
    height: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
}

.action-cell {
    min-width: 150px;
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
}

.action-cell form {
    margin: 0;
    display: flex;
    align-items: center;
}

.action-cell .btn {
    white-space: nowrap;
    height: 36px;
    min-height: 36px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.table td.td-quick,
.table td.td-actions {
    vertical-align: middle;
}

.table td.td-actions .action-cell,
.table td.td-quick .quick-update-cell {
    height: 40px;
}

.pagination .page-link {
    border-color: #cad8ef;
    color: #1e3a8a;
}

.pagination .active .page-link {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border-color: var(--primary);
}

@media (max-width: 992px) {
    .home-hero { grid-template-columns: 1fr; }
    .section-grid { grid-template-columns: 1fr 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .app-menu { padding-top: 10px; }
}

@media (max-width: 768px) {
    .card { border-radius: 14px; }
    .table { font-size: 14px; }
    .table th,
    .table td {
        white-space: nowrap;
    }
    .chat-item {
        max-width: 96%;
    }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-card { padding: 18px; }
    .hero-main { padding: 22px; }
    .hero-main h1 { font-size: 1.9rem; }
    .hero-kpis { grid-template-columns: 1fr; }
    .section-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .media-thumb {
        width: 78px;
        height: 58px;
    }
    .ticket-two-col {
        grid-template-columns: 1fr;
    }
    .admin-ticket-detail-grid {
        grid-template-columns: 1fr;
    }
    .internal-note-card {
        grid-template-columns: 1fr;
    }
    .internal-note-card form {
        grid-template-columns: 1fr;
    }
    .internal-note-inline .internal-note-form {
        grid-template-columns: 1fr;
    }
    .internal-note-list {
        grid-column: auto;
        grid-row: auto;
        max-height: 260px;
    }
    .ticket-chat-card .chat-window {
        height: 60dvh;
    }
    .ticket-reply-card .col-md-4,
    .ticket-reply-card .col-md-5,
    .ticket-reply-card .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    .quick-update-cell {
        min-width: 0;
    }
    .quick-update-cell .form-select {
        width: 130px;
    }
    .action-cell {
        min-width: 0;
    }
    .page-head-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    .vote-grid {
        grid-template-columns: 1fr;
    }
    .vote-options {
        grid-template-columns: 1fr;
    }
}
