@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800;900&family=Manrope:wght@400;500;600;700&display=swap');

:root, .theme-dark {
    --primary: #E24C4A;
    --primary-dark: #C0392B;
    --primary-light: rgba(226,76,74,0.12);
    --secondary: #386BB7;
    --secondary-light: rgba(56,107,183,0.12);
    --gradient: linear-gradient(146deg, #E24C4A 0%, #386BB7 100%);
    --gradient-hover: linear-gradient(146deg, #C0392B 0%, #2A5A9E 100%);
    --bg: #1F1F1F;
    --bg-card: #282828;
    --bg-secondary: #222222;
    --bg-input: #2A2A2A;
    --text: #FFFFFF;
    --text-secondary: rgba(255,255,255,0.65);
    --text-tertiary: rgba(255,255,255,0.35);
    --border: rgba(255,255,255,0.08);
    --border-light: rgba(255,255,255,0.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
    --sidebar-width: 250px;
    --transition: 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 999px;
}

.theme-light {
    --primary: #E24C4A;
    --primary-dark: #C0392B;
    --primary-light: rgba(226,76,74,0.08);
    --secondary: #386BB7;
    --secondary-light: rgba(56,107,183,0.08);
    --gradient: linear-gradient(146deg, #E24C4A 0%, #386BB7 100%);
    --gradient-hover: linear-gradient(146deg, #C0392B 0%, #2A5A9E 100%);
    --bg: #F2F2F7;
    --bg-card: #FFFFFF;
    --bg-secondary: #F8F9FC;
    --bg-input: #F8F9FC;
    --text: #1C1C1E;
    --text-secondary: #6B7280;
    --text-tertiary: #9CA3AF;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Montserrat', 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
body.sidebar-layout { padding-top: 52px; }

@media (min-width: 769px) {
    body.sidebar-layout { padding-top: 0; }
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: #FF6B6B; }

/* ================= LOGIN PAGE ================= */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(226,76,74,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(56,107,183,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(226,76,74,0.05) 0%, transparent 50%);
    position: relative;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 36px 36px;
    box-shadow: 0 8px 60px rgba(0,0,0,0.5);
    animation: iosSlideUp 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes iosSlideUp {
    from { opacity: 0; transform: translateY(24px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo img { height: 48px; width: auto; }

.login-card h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    text-align: center;
    color: var(--text);
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 28px;
    font-size: 13px;
}

.login-card .form-control {
    border-radius: var(--radius);
    padding: 14px 18px;
    font-size: 15px;
    border: 1.5px solid var(--border);
    background: var(--bg-input);
    transition: all var(--transition);
}
.login-card .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(226,76,74,0.12);
}
.login-card .form-group label {
    font-size: 11px;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.login-card .btn-block {
    border-radius: var(--radius);
    padding: 14px 20px;
    font-size: 13px;
}

.login-theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    transition: all var(--transition);
    z-index: 10;
}
.login-theme-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text);
    transform: scale(1.05);
}

/* ================= LAYOUT ================= */
.layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    margin-left: 0;
    flex: 1;
    padding: 32px 40px;
}

.footer {
    margin-left: 0;
    padding: 16px 40px 20px;
    font-size: 11px;
    color: var(--text-tertiary);
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--bg);
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

/* ================= SIDEBAR ================= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 210;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 4px 0 40px rgba(0,0,0,0.3);
}
.sidebar.open { transform: translateX(0); }

@media (min-width: 769px) {
    .mobile-header { display: none !important; }
    .sidebar {
        transform: none;
        box-shadow: none;
        z-index: 100;
    }
    .sidebar-overlay { display: none !important; }
    .main-content,
    .footer {
        margin-left: var(--sidebar-width);
    }
}

.sidebar-header {
    padding: 28px 20px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo-link { display: block; margin-bottom: 10px; }
.logo-text {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-header .user-info {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: var(--text-secondary);
    transition: all var(--transition);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    margin: 2px 0;
}

.sidebar-nav a:hover {
    background: var(--primary-light);
    color: var(--primary);
    text-decoration: none;
}

.sidebar-nav a.active {
    background: var(--gradient);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(226,76,74,0.3);
}

.sidebar-nav a .icon {
    margin-right: 10px;
    font-size: 16px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav a .icon-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 14px 20px 20px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.sidebar-footer a {
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 500;
    display: inline-block;
    margin: 2px 6px;
    transition: color var(--transition);
    letter-spacing: 0.3px;
}
.sidebar-footer a:hover { color: var(--primary); text-decoration: none; }

/* ================= PAGE HEADER ================= */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.6px;
    color: var(--text);
}

/* ================= CARDS ================= */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-body { padding: 22px 24px; }
.card-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
    letter-spacing: -0.2px;
}

/* ================= STATS ================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-top: 3px solid var(--border);
    transition: all var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 2px;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-card.stat-blue { border-top-color: var(--secondary); }
.stat-card.stat-blue .stat-value { color: var(--secondary); }
.stat-card.stat-green { border-top-color: #2ECC71; }
.stat-card.stat-green .stat-value { color: #2ECC71; }
.stat-card.stat-orange { border-top-color: #F39C12; }
.stat-card.stat-orange .stat-value { color: #F39C12; }
.stat-card.stat-red { border-top-color: var(--primary); }
.stat-card.stat-red .stat-value { color: var(--primary); }
.stat-card.stat-purple { border-top-color: #9B59B6; }
.stat-card.stat-purple .stat-value { color: #9B59B6; }

/* ================= TABLES ================= */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

table th, table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    white-space: nowrap;
}

table tbody tr:last-child td { border-bottom: none; }
table tbody tr { transition: background var(--transition); }
table tbody tr:hover { background: var(--primary-light); }

table .actions { white-space: nowrap; gap: 6px; display: flex; }

table .actions a,
table .actions button {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition);
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

table .actions a:hover,
table .actions button:hover {
    background: var(--gradient);
    color: #fff;
}

/* ================= BADGES ================= */
.badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1.6;
    text-transform: uppercase;
}

.badge-new { background: rgba(56,107,183,0.15); color: #5A8FD4; }
.badge-success { background: rgba(46,204,113,0.15); color: #2ECC71; }
.badge-danger  { background: rgba(226,76,74,0.15); color: #E24C4A; }
.badge-warning { background: rgba(243,156,18,0.15); color: #F39C12; }
.badge-info    { background: rgba(56,107,183,0.15); color: #5A8FD4; }
.badge-primary { background: rgba(155,89,182,0.15); color: #9B59B6; }
.badge-secondary { background: rgba(255,255,255,0.05); color: var(--text-secondary); }

/* ================= QUILL RENDER ================= */
.ticket-messages table, .art-body table, .public-content table {
    width: 100%; border-collapse: collapse; margin: 10px 0;
}
.ticket-messages table td, .art-body table td, .public-content table td {
    border: 1px solid var(--border); padding: 8px; vertical-align: top;
}
.ticket-messages img, .art-body img, .public-content img {
    max-width: 100%; height: auto; border-radius: var(--radius-sm);
}
.ticket-messages .ql-align-center, .art-body .ql-align-center, .public-content .ql-align-center { text-align: center; }
.ticket-messages .ql-align-right, .art-body .ql-align-right, .public-content .ql-align-right { text-align: right; }
.ticket-messages .ql-align-justify, .art-body .ql-align-justify, .public-content .ql-align-justify { text-align: justify; }
.ticket-messages iframe, .art-body iframe, .public-content iframe { max-width: 100%; }

/* ================= BUTTONS ================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 20px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    text-decoration: none;
    gap: 6px;
    line-height: 1.4;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }

.btn-primary {
    background: var(--gradient);
    color: #fff;
    border-color: transparent;
}
.btn-primary:hover {
    background: var(--gradient-hover);
    box-shadow: 0 6px 24px rgba(226,76,74,0.3);
    color: #fff;
}
.btn-primary::after {
    content: '';
    position: absolute;
    top: 0;
    left: -80%;
    width: 30%;
    height: 300%;
    transition: 0.3s;
    background: linear-gradient(174deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0.1) 100%);
    animation: blick 3s linear infinite;
    transform: rotate(45deg) translateY(-50%);
}
@keyframes blick {
    0% { left: -80%; }
    100% { left: 160%; }
}

.btn-success {
    background: rgba(46,204,113,0.15);
    color: #2ECC71;
    border-color: rgba(46,204,113,0.3);
}
.btn-success:hover { background: #2ECC71; color: #fff; box-shadow: 0 6px 24px rgba(46,204,113,0.3); }

.btn-danger {
    background: rgba(226,76,74,0.15);
    color: var(--primary);
    border-color: rgba(226,76,74,0.3);
}
.btn-danger:hover { background: var(--primary); color: #fff; box-shadow: 0 6px 24px rgba(226,76,74,0.3); }

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-card); color: var(--text); }

.btn-sm { padding: 5px 14px; font-size: 10px; border-radius: 7px; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ================= FORMS ================= */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all var(--transition);
    background: var(--bg-input);
    color: var(--text);
    font-family: inherit;
    outline: none;
    -webkit-appearance: none;
}

.form-control:focus {
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(226,76,74,0.1);
}

.form-control::placeholder { color: var(--text-tertiary); }

select.form-control { cursor: pointer; padding-right: 32px; }
textarea.form-control { min-height: 90px; resize: vertical; line-height: 1.5; }

input.form-control.form-date,
input.form-control[type="date"],
input.form-control[type="datetime-local"],
input.form-control[type="time"],
input.form-control[type="month"],
input.form-control[type="week"] {
    min-height: 42px;
    padding: 0 12px;
    cursor: pointer;
}
.theme-dark input.form-control.form-date,
.theme-dark input.form-control[type="date"],
.theme-dark input.form-control[type="datetime-local"],
.theme-dark input.form-control[type="time"] {
    color-scheme: dark;
}
.theme-light input.form-control.form-date,
.theme-light input.form-control[type="date"],
.theme-light input.form-control[type="datetime-local"],
.theme-light input.form-control[type="time"] {
    color-scheme: light;
}
input.form-control.form-date::-webkit-calendar-picker-indicator,
input.form-control[type="date"]::-webkit-calendar-picker-indicator,
input.form-control[type="datetime-local"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: .75;
    filter: invert(0.85);
}
.theme-light input.form-control.form-date::-webkit-calendar-picker-indicator,
.theme-light input.form-control[type="date"]::-webkit-calendar-picker-indicator,
.theme-light input.form-control[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: none;
    opacity: .65;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 28px 30px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.form-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    letter-spacing: -0.2px;
}

.checkbox-group { margin-bottom: 20px; }

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.checkbox-label input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
    border-radius: 4px;
}

/* ================= ALERTS ================= */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success { background: rgba(46,204,113,0.1); color: #2ECC71; border-color: rgba(46,204,113,0.2); }
.alert-danger  { background: rgba(226,76,74,0.1); color: #E24C4A; border-color: rgba(226,76,74,0.2); }
.alert-info    { background: rgba(56,107,183,0.1); color: #5A8FD4; border-color: rgba(56,107,183,0.2); }
.alert-warning { background: rgba(243,156,18,0.1); color: #F39C12; border-color: rgba(243,156,18,0.2); }

/* ================= TABS ================= */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
    overflow-x: auto;
}
.tab {
    padding: 10px 18px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tab:hover { color: var(--primary); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ================= PAGINATION ================= */
.pagination {
    display: flex;
    list-style: none;
    gap: 6px;
    margin-top: 20px;
    justify-content: center;
}

.page-item .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    transition: all var(--transition);
    background: var(--bg-card);
}

.page-item .page-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.page-item.active .page-link {
    background: var(--gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 16px rgba(226,76,74,0.3);
}

/* ================= TICKET MESSAGES ================= */
.ticket-messages {
    max-height: 450px;
    overflow-y: auto;
    margin-bottom: 20px;
    padding: 8px;
}

.message {
    padding: 14px 18px;
    margin-bottom: 12px;
    border-radius: var(--radius);
    max-width: 82%;
    line-height: 1.5;
    font-size: 13px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-customer {
    background: rgba(56,107,183,0.12);
    margin-right: auto;
    border-bottom-left-radius: 5px;
    border: 1px solid rgba(56,107,183,0.15);
}

.message-staff {
    background: rgba(226,76,74,0.12);
    margin-left: auto;
    border-bottom-right-radius: 5px;
    border: 1px solid rgba(226,76,74,0.15);
}

.message-system {
    background: rgba(155,89,182,0.08);
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    max-width: 100%;
    border: 1px solid rgba(155,89,182,0.15);
    font-size: 12px;
    padding: 8px 18px;
}

.message-meta {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 8px;
    font-weight: 500;
}

.message-attachments {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

.message-attachments a {
    font-size: 11px;
    color: var(--secondary);
    margin-right: 12px;
}

/* ================= SEARCH BAR ================= */
.search-bar {
    position: relative;
    max-width: 500px;
}
.search-bar input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 13px;
    background: var(--bg-secondary);
    color: var(--text);
    outline: none;
    transition: all var(--transition);
    font-family: inherit;
}
.search-bar input:focus {
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(226,76,74,0.08);
}
.search-bar input::placeholder { color: var(--text-tertiary); }
.search-bar .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    color: var(--text-tertiary);
    pointer-events: none;
}

/* ================= FILTER PILLS ================= */
.filter-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.filter-pill {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.filter-pill:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.filter-pill.active {
    background: var(--gradient);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 12px rgba(226,76,74,0.3);
}

/* ================= KB / FAQ STYLES ================= */
.kb-category {
    padding: 18px 20px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: all var(--transition);
    cursor: pointer;
    display: block;
}
.kb-category:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    text-decoration: none;
}
.kb-category h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}
.kb-category p {
    font-size: 12px;
    color: var(--text-secondary);
}
.kb-article {
    padding: 16px 20px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: all var(--transition);
    display: block;
}
.kb-article:hover {
    border-color: var(--primary-light);
    text-decoration: none;
}
.kb-article h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.kb-article p {
    font-size: 12px;
    color: var(--text-secondary);
}

.kb-content {
    padding: 24px;
    line-height: 1.7;
    font-size: 14px;
}
.kb-content h2 { font-size: 20px; font-weight: 800; margin-bottom: 16px; }
.kb-content h3 { font-size: 16px; font-weight: 700; margin: 20px 0 10px; }
.kb-content p { margin-bottom: 12px; }
.kb-content ul, .kb-content ol { margin-bottom: 12px; padding-left: 24px; }
.kb-content code { background: var(--bg-input); padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* ================= PROFILE ================= */
.profile-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 28px;
    background: var(--bg-card);
    padding: 24px 28px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(226,76,74,0.3);
}

/* ================= THEME TOGGLE ================= */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    width: 100%;
    text-align: center;
    font-family: inherit;
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.theme-toggle:hover { color: var(--text); background: var(--bg-secondary); }

/* ================= EMPTY STATE ================= */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* ================= PUBLIC PAGE ================= */
.public-page {
    min-height: 100vh;
    background: var(--bg);
}

.public-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.public-header .logo-text {
    font-size: 20px;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.public-header nav a {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    margin-left: 20px;
    transition: color var(--transition);
}
.public-header nav a:hover { color: var(--primary); text-decoration: none; }

.public-header-end {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.kb-header .container { overflow: visible; }
.public-header { overflow: visible; }

.public-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 40px 24px;
}

.public-footer {
    text-align: center;
    padding: 20px;
    font-size: 11px;
    color: var(--text-tertiary);
    border-top: 1px solid var(--border);
}

/* ================= TICKET PRIORITY COLORS ================= */
.priority-critical { color: #E24C4A; }
.priority-high { color: #E67E22; }
.priority-medium { color: #F39C12; }
.priority-low { color: #2ECC71; }

/* ================= RATING STARS ================= */
.rating-stars {
    display: inline-flex;
    gap: 2px;
}
.rating-stars .star {
    cursor: pointer;
    font-size: 18px;
    color: var(--text-tertiary);
    transition: color var(--transition);
}
.rating-stars .star.active { color: #F39C12; }
.rating-stars .star:hover { color: #F39C12; }

/* ================= RESPONSIVE ================= */
.mobile-header {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid var(--border);
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 200;
    overflow: visible;
}
.mobile-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 40px;
    flex-shrink: 0;
}

.hamburger {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 8px 10px;
    color: var(--text);
    border-radius: 8px;
    transition: background 0.2s;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hamburger:hover { background: var(--bg-secondary); }

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s;
}
.sidebar-overlay.show { display: block; opacity: 1; }

@media (max-width: 768px) {
    body { padding-top: 52px; }
    .main-content { padding: 16px; }
    .footer { padding: 12px 16px; }
    .kb-layout { grid-template-columns: 1fr !important; }
    .kb-layout > div:first-child { order: 2; }
    .kb-layout > div:last-child { order: 1; }

    .page-header { flex-direction: column; align-items: stretch; gap: 10px; }
    .page-header h1 { font-size: 22px; }
    .page-header .btn { width: 100%; justify-content: center; }

    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px 16px; }
    .stat-card .stat-value { font-size: 22px; }

    .form-row { grid-template-columns: 1fr; gap: 0; }
    .form-control { font-size: 16px; padding: 12px 14px; }

    .table-container { margin: 0 -12px; padding: 0 12px; }
    table { font-size: 12px; min-width: 600px; }

    .login-container { padding: 12px; }
    .login-card { padding: 28px 24px; border-radius: 20px; }

    .btn { padding: 12px 18px; font-size: 13px; min-height: 44px; }

    .message { max-width: 95%; }
    .ticket-messages { max-height: 350px; }

    .public-content { padding: 20px 16px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; gap: 8px; }
    .main-content { padding: 12px; }
    .form-card { padding: 14px; }

    .page-header h1 { font-size: 20px; }

    .stat-card { padding: 12px 14px; }
    .stat-card .stat-value { font-size: 20px; }

    .login-card { padding: 24px 16px; }
    .login-card h1 { font-size: 22px; }

    .message { max-width: 100%; font-size: 12px; }
}

@media print {
    .sidebar, .footer, .btn, .mobile-header, .sidebar-overlay { display: none; }
    .main-content { margin-left: 0; padding: 0; }
    body { padding-top: 0; }
    .card { box-shadow: none; border: 1px solid rgba(255,255,255,0.1); break-inside: avoid; }
}

/* Custom Quill table button + image resize */
.ql-snow .ql-toolbar .ql-table-btn {
    width: 28px;
    padding: 3px 5px;
}
.ql-snow .ql-toolbar .ql-table-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}
.ql-editor img {
    max-width: 100%;
    cursor: pointer;
}
.ql-editor img.ql-image-selected {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.ql-image-resize-overlay {
    position: absolute;
    z-index: 20;
    pointer-events: none;
    box-sizing: border-box;
    border: 2px solid var(--primary);
}
.ql-image-resize-handle {
    position: absolute;
    right: -6px;
    bottom: -6px;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: nwse-resize;
    pointer-events: auto;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.ql-image-resize-label {
    position: absolute;
    top: -24px;
    left: 0;
    font-size: 11px;
    line-height: 1.2;
    background: var(--primary);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
    white-space: nowrap;
}

/* Table borders inside Quill editor and rendered content */
.ql-editor table, .ql-editor table td, .ql-editor table th,
.ticket-messages table, .ticket-messages table td, .ticket-messages table th,
.message table, .message table td, .message table th,
.public-content table, .public-content table td, .public-content table th,
.art-body table, .art-body table td, .art-body table th,
#privacyEditorContainer table, #privacyEditorContainer table td, #privacyEditorContainer table th,
#repairContractEditor table, #repairContractEditor table td, #repairContractEditor table th,
#repairCertificateEditor table, #repairCertificateEditor table td, #repairCertificateEditor table th {
    border: 1px solid #ccc !important;
    border-collapse: collapse !important;
}
.ql-editor table td, .ql-editor table th,
.ticket-messages table td, .ticket-messages table th,
.message table td, .message table th,
.public-content table td, .public-content table th,
.art-body table td, .art-body table th,
#privacyEditorContainer table td, #privacyEditorContainer table th,
#repairContractEditor table td, #repairContractEditor table th,
#repairCertificateEditor table td, #repairCertificateEditor table th {
    padding: 8px !important;
    vertical-align: top;
}

/* Quill Snow theme dark mode overrides */
.ql-snow .ql-picker-options { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.ql-snow .ql-picker.ql-expanded .ql-picker-label { color: var(--text); border-color: var(--border); }
.ql-snow .ql-picker-label { color: var(--text); }
.ql-snow .ql-stroke { stroke: var(--text); }
.ql-snow .ql-fill { fill: var(--text); }
.ql-snow .ql-toolbar { background: var(--bg-secondary); border-color: var(--border); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.ql-container { border-color: var(--border) !important; }
.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow .ql-toolbar button:hover .ql-stroke { stroke: var(--primary); }
.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow .ql-toolbar button:hover .ql-fill { fill: var(--primary); }
.ql-snow .ql-picker-item { color: var(--text); }
.ql-snow .ql-picker-item:hover { color: var(--primary); }
.ql-editor blockquote { border-left-color: var(--border); color: var(--text-secondary); }

/* User / client autocomplete */
.form-user-search,
.form-client-search { position: relative; }
.client-suggest,
.user-suggest {
    position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px);
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); max-height: 260px; overflow: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.client-suggest button,
.user-suggest button {
    display: block; width: 100%; text-align: left; padding: 8px 12px;
    border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit;
}
.client-suggest button:hover,
.client-suggest button[aria-selected="true"],
.user-suggest button:hover,
.user-suggest button[aria-selected="true"] { background: var(--bg-secondary); }
.client-suggest .suggest-meta,
.user-suggest .suggest-meta { font-size: 11px; color: var(--text-tertiary); }
.client-suggest button:disabled,
.user-suggest button:disabled { opacity: .6; cursor: default; }
.client-suggest .suggest-create,
.user-suggest .suggest-create { color: var(--primary); font-weight: 600; }

/* Settings page */
.settings-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 10px 0 14px;
    margin: 0 0 8px;
    background: linear-gradient(180deg, var(--bg) 70%, transparent);
}
.settings-nav-link {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.settings-nav-link:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.settings-nav-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.settings-form { display: block; }
.settings-section {
    scroll-margin-top: 64px;
}
.settings-section.form-card h3 {
    margin-bottom: 4px;
    padding-bottom: 0;
    border-bottom: 0;
}
.settings-section-head { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.settings-section-desc {
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
}
.settings-subhead {
    margin: 18px 0 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.1px;
}
.settings-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.4;
}
.settings-section-actions {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.settings-inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 4px;
}
.settings-toggles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
}
.settings-toggle {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary, transparent);
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    line-height: 1.35;
}
.settings-toggle span { display: flex; flex-direction: column; gap: 4px; }
.settings-toggle .settings-hint { margin: 0; }
.settings-media-preview {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.settings-media-preview img { max-height: 40px; border-radius: 4px; }
.settings-media-preview img.settings-media-bg { max-height: 60px; }
.settings-media-preview img.settings-media-favicon { max-height: 32px; }
.settings-editor {
    border-radius: var(--radius-sm);
    background: var(--bg);
}
@media (max-width: 768px) {
    .settings-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 10px;
        scrollbar-width: thin;
    }
    .settings-section-actions .btn { width: 100%; justify-content: center; }
}

/* Модальные окна */
body.app-modal-open { overflow: hidden; }
.app-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    animation: appModalFadeIn 0.18s ease;
}
.app-modal {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 24px 28px;
    animation: appModalSlideIn 0.2s ease;
}
.app-modal-title {
    margin: 0 0 10px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}
.app-modal-text {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
    white-space: pre-wrap;
}
.app-modal-input {
    width: 100%;
    margin: 0 0 18px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}
.app-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}
@keyframes appModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes appModalSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Модальные формы (workspace и др.) */
.app-form-modal {
    position: fixed;
    inset: 0;
    z-index: 10040;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.app-form-modal.is-open { display: flex; }
.app-form-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    animation: appModalFadeIn 0.18s ease;
}
.app-form-modal-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: appModalSlideIn 0.2s ease;
}
.app-form-modal-panel.app-form-modal-wide { max-width: 760px; }
.app-form-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.app-form-modal-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}
.app-form-modal-close {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}
.app-form-modal-close:hover { color: var(--text); background: var(--bg-card); }
.app-form-modal-body {
    padding: 20px 22px 22px;
    overflow: auto;
    flex: 1;
    min-height: 0;
}
.app-form-modal-body .form-card,
.app-form-modal-body .card {
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
    background: transparent;
}
.app-form-modal-body .form-card > h2,
.app-form-modal-body .form-card > h3 {
    display: none;
}
.app-form-modal-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* Публичная страница общего файла */
.ws-share-header { justify-content: center; }
.ws-share-header .logo-text { pointer-events: none; }
.ws-share-page { max-width: 720px; margin: 0 auto; }
.ws-share-card { margin-top: 8px; }
.ws-share-file-head {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 20px;
}
.ws-share-file-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-shrink: 0;
}
.ws-share-file-name {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 700;
    word-break: break-word;
}
.ws-share-file-desc {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}
.ws-share-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px 20px;
    margin: 0 0 24px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.ws-share-meta div { margin: 0; }
.ws-share-meta dt {
    margin: 0 0 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
}
.ws-share-meta dd {
    margin: 0;
    font-weight: 600;
    color: var(--text);
}
.ws-share-actions { margin-bottom: 12px; }
.ws-share-download-btn { min-width: 200px; }
.ws-share-hint {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}

/* Ссылки «Поделиться» в админке */
.ws-file-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
}
.ws-share-links-title {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 700;
}
.ws-share-links { display: flex; flex-direction: column; gap: 12px; }
.ws-share-link-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.ws-share-link-item.is-expired { opacity: 0.65; }
.ws-share-link-fields { flex: 1; min-width: 200px; }
.ws-share-link-meta { margin-top: 6px; font-size: 12px; }
.ws-share-link-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.ws-staff-share-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.ws-staff-share-item { margin: 0; }

/* Всплывающие уведомления */
.app-toast-stack {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10040;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}
.app-toast {
    pointer-events: auto;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    animation: appToastIn 0.25s ease;
}
.app-toast.is-info { border-left-color: #386BB7; }
.app-toast.is-success { border-left-color: #27ae60; }
.app-toast.is-warning { border-left-color: #f39c12; }
.app-toast-body { flex: 1; min-width: 0; }
.app-toast-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}
.app-toast-message {
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-secondary);
}
.app-toast-close {
    border: 0;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
}
.app-toast-close:hover { color: var(--text); }
@keyframes appToastIn {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}
.app-notify-permission {
    border-left-color: #386BB7;
}
.app-notify-permission .app-toast-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* Верхняя панель: тема + уведомления */
.app-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 120;
    flex-shrink: 0;
}
.app-top-actions.is-floating {
    position: fixed;
    top: 10px;
    right: 14px;
    z-index: 10040;
}
.app-top-actions.is-in-main {
    margin-left: auto;
}
.app-theme-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,.12));
    transition: border-color var(--transition), background var(--transition), color var(--transition), transform var(--transition);
    flex-shrink: 0;
}
.app-theme-toggle:hover {
    border-color: var(--primary);
    background: var(--bg-secondary);
    color: var(--text);
    transform: scale(1.05);
}

/* Колокольчик уведомлений */
.app-notify-bar {
    position: relative;
    flex-shrink: 0;
}
.main-content-topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin: 0 0 12px;
    min-height: 40px;
}
.app-notify-wrap { position: relative; }
.app-notify-bell {
    position: relative;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,.12));
    transition: border-color var(--transition), background var(--transition);
}
.app-notify-bell:hover,
.app-notify-bell[aria-expanded="true"] {
    border-color: var(--primary);
    background: var(--bg-secondary);
}
.app-notify-bell-icon { font-size: 18px; line-height: 1; }
.app-notify-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    border: 2px solid var(--bg-card);
}
.app-notify-badge[hidden] { display: none !important; }
.app-notify-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(360px, calc(100vw - 28px));
    max-height: min(420px, calc(100vh - 80px));
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10050;
}
.app-notify-panel[hidden] { display: none !important; }
.app-notify-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.app-notify-panel-head .btn { white-space: nowrap; font-size: 11px; padding: 5px 10px; }
.app-notify-list {
    overflow-y: auto;
    flex: 1;
}
.app-notify-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    padding: 12px 14px;
    cursor: pointer;
    color: inherit;
    font: inherit;
}
.app-notify-item:hover { background: var(--bg-secondary); }
.app-notify-item.is-unread {
    background: rgba(226, 76, 74, 0.06);
    border-left: 3px solid var(--primary);
    padding-left: 11px;
}
.app-notify-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.app-notify-item-message {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 4px;
}
.app-notify-item-time {
    font-size: 11px;
    color: var(--text-tertiary);
}
.app-notify-empty {
    padding: 28px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--text-tertiary);
}
.mobile-header-actions .app-theme-toggle,
.mobile-header-actions .app-notify-bell {
    width: 36px;
    height: 36px;
}
@media (max-width: 768px) {
    .public-header-end nav a { margin-left: 12px; }
    .app-notify-panel {
        right: 0;
        width: min(320px, calc(100vw - 24px));
    }
}

/* Workspace module */
.text-muted { color: var(--text-secondary); font-size: 13px; }
.text-danger { color: var(--danger, #ef4444); }

.ws-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.ws-subnav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all .15s;
}
.ws-subnav-link:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.ws-subnav-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.ws-subnav-icon { font-size: 16px; }

.ws-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}
.ws-dashboard-wide { grid-column: 1 / -1; }
.ws-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.ws-event-list { list-style: none; padding: 0; margin: 0; }
.ws-event-list li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.ws-event-list li:last-child { border-bottom: none; }
.ws-event-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.ws-task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin: 12px 0;
    font-size: 14px;
    color: var(--text-secondary);
}
.ws-task-description {
    padding: 12px;
    background: var(--bg-secondary, rgba(255,255,255,.03));
    border-radius: var(--radius);
    line-height: 1.6;
}
.ws-comments { margin: 12px 0; }
.ws-comment {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}
.ws-comment p { margin: 6px 0 0; }

.ws-calendar-card { margin-bottom: 20px; }
.ws-calendar-card .card-body { padding: 20px 22px 22px; }

.ws-calendar-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.ws-calendar-nav {
    flex: 1;
    min-width: 240px;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}
.ws-calendar-nav .dt-picker-title h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text);
}
.ws-cal-nav-btn {
    text-decoration: none;
    flex-shrink: 0;
}
a.dt-picker-nav.ws-cal-nav-btn { color: var(--text-secondary); }
a.dt-picker-nav.ws-cal-nav-btn:hover { color: var(--text); }
.ws-calendar-title {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.ws-calendar-title h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text);
}
.ws-calendar-today-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ws-calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 12px;
    color: var(--text-secondary);
}
.ws-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.ws-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    display: inline-block;
    flex-shrink: 0;
}

.ws-calendar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.app-calendar .dt-picker-weekdays,
.ws-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}
.app-calendar .dt-picker-weekdays span,
.ws-calendar-weekdays span {
    padding: 12px 8px;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
}
.app-calendar .dt-picker-weekdays .dt-wk-end,
.ws-calendar-weekdays .ws-cal-weekend-h,
.ws-calendar-weekdays .dt-wk-end { color: var(--primary); opacity: 0.85; }

.ws-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--bg-card);
}
.ws-cal-day {
    min-height: 108px;
    border-right: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: background var(--transition);
}
.ws-cal-day:hover { background: var(--bg-secondary); }
.ws-cal-day:nth-child(7n) { border-right: none; }
.ws-cal-empty {
    background: var(--bg-secondary);
    opacity: 0.55;
    min-height: 108px;
}
.ws-cal-weekend { background: rgba(226, 76, 74, 0.03); }
.theme-light .ws-cal-weekend { background: rgba(226, 76, 74, 0.04); }

.ws-cal-today {
    background: var(--primary-light);
    box-shadow: inset 0 0 0 1px rgba(226, 76, 74, 0.25);
}
.ws-cal-day-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.ws-cal-day-num {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
}
.ws-cal-weekend .ws-cal-day-num { color: var(--primary); opacity: 0.9; }
.ws-cal-today .ws-cal-day-num {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 2px 8px rgba(226, 76, 74, 0.35);
    border-radius: var(--radius-sm);
}
.ws-cal-day-badge {
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    padding: 3px 6px;
    border-radius: var(--radius-full);
    background: var(--secondary-light);
    color: var(--secondary);
}
.ws-cal-day-events {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    flex: 1;
}
.ws-cal-event {
    display: block;
    font-size: 11px;
    line-height: 1.35;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    text-decoration: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--event-color, var(--secondary));
    transition: all var(--transition);
}
.ws-cal-event-time {
    font-weight: 700;
    color: var(--text-secondary);
    margin-right: 2px;
}
.ws-cal-event:hover {
    background: var(--secondary-light);
    border-color: rgba(56, 107, 183, 0.25);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.ws-cal-event-repair {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: #f59e0b !important;
}
.ws-cal-event-repair:hover {
    background: rgba(245, 158, 11, 0.16);
    border-color: rgba(245, 158, 11, 0.35);
}
.ws-cal-more {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    padding: 2px 4px;
}

input.form-control.form-color {
    height: 42px;
    padding: 4px 8px;
    cursor: pointer;
}

.ws-files-grid {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.ws-files-grid .card { flex: 1; min-width: 260px; }
.ws-folder-list { list-style: none; padding: 0; margin: 0; }
.ws-folder-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.ws-breadcrumb {
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}
.ws-breadcrumb a { color: var(--primary); }
.ws-forms-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .ws-dashboard-grid { grid-template-columns: 1fr; }
    .ws-forms-row { grid-template-columns: 1fr; }
    .ws-calendar-toolbar { flex-direction: column; align-items: stretch; }
    .ws-calendar-legend { justify-content: center; }
    .ws-cal-day, .ws-cal-empty { min-height: 72px; }
    .ws-cal-event { font-size: 10px; padding: 4px 6px; }
    .ws-calendar-title h2 { font-size: 18px; }
}

/* Date/time picker dropdown */
.dt-picker {
    position: relative;
    width: 100%;
}
.dt-picker-trigger {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
    cursor: pointer;
    background: var(--bg-input, var(--bg-secondary));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.dt-picker-trigger:hover { border-color: var(--text-tertiary); }
.dt-picker-trigger:focus,
.dt-picker.is-open .dt-picker-trigger {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(226, 76, 74, 0.1);
}
.dt-picker-trigger.is-empty { color: var(--text-tertiary); }
.dt-picker-icon {
    flex-shrink: 0;
    opacity: 0.65;
    font-size: 15px;
    line-height: 1;
}
.dt-picker-panel {
    position: absolute;
    z-index: 120;
    left: 0;
    top: calc(100% + 6px);
    min-width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    padding: 14px;
    display: none;
}
.dt-picker.is-open .dt-picker-panel { display: block; }
.dt-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.dt-picker-title {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.2px;
}
.dt-picker-nav {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font: inherit;
    transition: background var(--transition), color var(--transition);
}
.dt-picker-nav:hover {
    background: var(--bg-card);
    color: var(--text);
}
.dt-picker-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 6px;
}
.dt-picker-weekdays span {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    padding: 4px 0;
}
.dt-picker-weekdays .dt-wk-end { color: var(--primary); opacity: 0.85; }
.dt-picker-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.dt-picker-day {
    aspect-ratio: 1;
    min-height: 34px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.dt-picker-day:hover:not(:disabled) { background: var(--bg-secondary); color: var(--text); }
.dt-picker-day.is-outside { opacity: 0.35; }
.dt-picker-day.is-weekend { color: var(--primary); opacity: 0.9; }
.dt-picker-day.is-today {
    box-shadow: inset 0 0 0 1px rgba(226, 76, 74, 0.35);
}
.dt-picker-day.is-selected {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 2px 8px rgba(226, 76, 74, 0.35);
}
.dt-picker-day:disabled {
    opacity: 0.2;
    cursor: default;
}
.dt-picker-time {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.dt-picker-time label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}
.dt-picker-time select {
    flex: 1;
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}
.dt-picker-time select:focus {
    outline: none;
    border-color: var(--primary);
}
.dt-picker-sep {
    font-weight: 700;
    color: var(--text-tertiary);
}
.dt-picker-footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.dt-picker-footer button {
    flex: 1;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.dt-picker-footer button:hover {
    background: var(--bg-card);
    color: var(--text);
}
.dt-picker-footer .dt-picker-apply {
    background: var(--gradient);
    border-color: transparent;
    color: #fff;
}
.dt-picker-footer .dt-picker-apply:hover {
    opacity: 0.92;
    color: #fff;
}

.ws-sync-card { margin-bottom: 20px; }
.ws-sync-header { margin-bottom: 16px; }
.ws-sync-header .card-title { margin-bottom: 8px; }
.ws-sync-lead {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.ws-sync-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.ws-sync-options {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}
.ws-sync-urls { margin-bottom: 16px; }
.ws-sync-copy-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: stretch;
}
.ws-sync-input {
    flex: 1;
    min-width: 220px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.ws-sync-help {
    margin: 0 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
}
.ws-sync-help summary {
    cursor: pointer;
    padding: 12px 14px;
    font-weight: 600;
    color: var(--text);
}
.ws-sync-help-body {
    padding: 0 14px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
}
.ws-sync-help-body p { margin: 0 0 10px; }
.ws-sync-help-body p:last-child { margin-bottom: 0; }
.ws-sync-note {
    margin-top: 8px !important;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    font-size: 12px !important;
}
.ws-sync-regenerate { margin-top: 4px; }

.ws-upload-progress { margin-top: 16px; }
.ws-upload-progress-track {
    height: 12px;
    background: var(--bg-tertiary, #2a2a2a);
    border-radius: 6px;
    overflow: hidden;
}
.ws-upload-progress-fill {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #3b82f6, #22c55e);
    transition: width .25s ease;
}
.ws-upload-progress-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 8px 0 0;
}
