/* GW System - modern work app UI */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --sidebar-width: 232px;
  --header-height: 60px;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #111827;
  --text-muted: #6b7280;
  --text-subtle: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 22px rgba(15, 23, 42, 0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  min-height: 100vh;
  font-family: 'Pretendard', 'Malgun Gothic', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }

#sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: #111827;
  color: #d1d5db;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.2s ease;
}
.sidebar-header {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; }
.sidebar-logo-icon {
  width: 32px; height: 32px; border-radius: 8px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 15px; flex: 0 0 auto;
}
.sidebar-logo-text strong { display: block; color: #fff; font-size: 14px; font-weight: 800; }
.sidebar-logo-text span { display: block; color: #9ca3af; font-size: 11px; line-height: 1.2; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sidebar-section-label { padding: 12px 10px 6px; color: #6b7280; font-size: 11px; font-weight: 700; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 9px 10px;
  border-radius: 8px; color: #cbd5e1; text-decoration: none; font-size: 13px; font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-link i { width: 18px; text-align: center; color: #9ca3af; font-size: 15px; }
.sidebar-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar-link.active { background: #1f2937; color: #fff; }
.sidebar-link.active i { color: #60a5fa; }
.sidebar-footer { padding: 12px 10px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 9px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); }
.sidebar-user-avatar, .header-profile-avatar, .avatar { display: inline-grid; place-items: center; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; }
.sidebar-user-avatar { width: 32px; height: 32px; font-size: 12px; flex: 0 0 auto; }
.sidebar-user-info strong { display: block; overflow: hidden; color: #fff; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-info span { display: block; overflow: hidden; color: #9ca3af; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(17, 24, 39, 0.45); z-index: 999; }

#header {
  position: fixed; top: 0; left: var(--sidebar-width); right: 0; height: var(--header-height); z-index: 998;
  display: flex; align-items: center; gap: 12px; padding: 0 22px;
  background: rgba(255, 255, 255, 0.92); border-bottom: 1px solid var(--border); backdrop-filter: blur(12px);
}
.header-toggle { display: none; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); cursor: pointer; }
.header-title { color: var(--text); font-size: 15px; font-weight: 800; }
.header-spacer { flex: 1; }
.header-search { position: relative; width: min(280px, 28vw); }
.header-search i { position: absolute; top: 50%; left: 11px; transform: translateY(-50%); color: var(--text-subtle); font-size: 14px; }
.header-search input { width: 100%; height: 36px; padding: 0 12px 0 34px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-muted); color: var(--text); outline: none; }
.header-search input:focus { border-color: #93c5fd; background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-btn, .icon-btn {
  position: relative; width: 36px; height: 36px; display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text-muted);
  text-decoration: none; cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.header-btn:hover, .icon-btn:hover { border-color: #bfdbfe; background: var(--primary-soft); color: var(--primary); }
.header-btn .dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 999px; background: var(--danger); border: 1px solid #fff; }
.header-profile { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 4px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); text-decoration: none; }
.header-profile-avatar { width: 28px; height: 28px; border-radius: 7px; font-size: 12px; }
.header-profile-name { font-size: 13px; font-weight: 700; }
#main { margin-left: var(--sidebar-width); margin-top: var(--header-height); min-height: calc(100vh - var(--header-height)); padding: 24px; }

.page-header, .hero-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-title { color: var(--text); font-size: 22px; font-weight: 800; line-height: 1.25; }
.page-subtitle { margin-top: 4px; color: var(--text-muted); font-size: 13px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.content-grid { display: grid; gap: 16px; }
.dashboard-grid { grid-template-columns: minmax(0, 1fr) 340px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.org-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.form-grid { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 180px minmax(0, 1fr) 240px; gap: 14px; }

.card, .table-wrapper, .search-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card { overflow: hidden; }
.card-header { min-height: 48px; padding: 13px 16px; border-bottom: 1px solid var(--border); background: #fff; color: var(--text); display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 800; }
.card-title { display: inline-flex; align-items: center; gap: 8px; }
.card-title i { color: var(--primary); }
.card-body { padding: 18px; }
.stat-card, .quick-card { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; color: var(--text); text-decoration: none; box-shadow: var(--shadow); }
a.stat-card:hover, a.quick-card:hover { border-color: #bfdbfe; box-shadow: var(--shadow-md); }
.stat-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-size: 18px; flex: 0 0 auto; }
.stat-icon.green { background: #ecfdf5; color: var(--success); }
.stat-icon.orange { background: #fff7ed; color: var(--warning); }
.stat-icon.red { background: #fef2f2; color: var(--danger); }
.stat-icon.cyan { background: #ecfeff; color: var(--info); }
.stat-icon.indigo, .stat-icon.blue { background: var(--primary-soft); color: var(--primary); }
.stat-label { color: var(--text-muted); font-size: 12px; font-weight: 700; }
.stat-value { margin-top: 2px; color: var(--text); font-size: 25px; font-weight: 800; line-height: 1; }
.stat-change, .meta-text { margin-top: 5px; color: var(--text-muted); font-size: 12px; }
.quick-card { flex-direction: column; align-items: flex-start; }
.quick-title { color: var(--text); font-size: 13px; font-weight: 800; }
.quick-desc { margin-top: 2px; color: var(--text-muted); font-size: 12px; }

.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; min-width: 720px; border-collapse: collapse; }
.data-table thead { background: var(--surface-muted); }
.data-table th { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 12px; font-weight: 800; text-align: left; white-space: nowrap; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid #eef2f7; color: var(--text); font-size: 13px; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f9fbff; }
.link-strong, .board-link { color: var(--text); text-decoration: none; font-weight: 700; }
.link-strong:hover, .board-link:hover { color: var(--primary) !important; }

.badge { display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; font-size: 11px; font-weight: 800; line-height: 1.2; white-space: nowrap; }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: #dbeafe; }
.badge-success { background: #ecfdf5; color: var(--success); border-color: #d1fae5; }
.badge-warning { background: #fffbeb; color: var(--warning); border-color: #fde68a; }
.badge-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.badge-secondary { background: #f3f4f6; color: #4b5563; border-color: #e5e7eb; }
.badge-info { background: #ecfeff; color: var(--info); border-color: #cffafe; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 8px 13px; border: 1px solid transparent; border-radius: 8px; background: #fff; color: var(--text); cursor: pointer; font-size: 13px; font-weight: 800; line-height: 1; text-decoration: none; white-space: nowrap; transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease; }
.btn-sm { min-height: 30px; padding: 6px 10px; font-size: 12px; }
.btn-lg { min-height: 42px; padding: 10px 18px; font-size: 14px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-secondary, .btn-ghost { background: #fff; border-color: var(--border); color: var(--text-muted); }
.btn-secondary:hover, .btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-muted); color: var(--text); }
.btn-outline { background: #fff; border-color: #bfdbfe; color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); border-color: #93c5fd; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; color: #374151; font-size: 13px; font-weight: 800; }
.form-label .req, .req { color: var(--danger); }
.form-control { width: 100%; min-height: 38px; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; color: var(--text); font-size: 13px; outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.form-control:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.form-control::placeholder { color: #a1a1aa; }
textarea.form-control { min-height: 160px; resize: vertical; line-height: 1.7; }
.input-with-icon { position: relative; }
.input-with-icon .form-control { padding-left: 36px; }
.input-with-icon i { position: absolute; top: 50%; left: 12px; transform: translateY(-50%); color: var(--text-subtle); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.search-bar { padding: 14px; margin-bottom: 16px; }
.search-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-field { position: relative; flex: 1; min-width: 220px; }
.search-field i { position: absolute; top: 50%; left: 12px; transform: translateY(-50%); color: var(--text-subtle); }
.search-field .form-control { padding-left: 36px; }

.tab-nav { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.tab-link { display: inline-flex; align-items: center; min-height: 32px; padding: 7px 12px; border-radius: 6px; color: var(--text-muted); font-size: 13px; font-weight: 800; text-decoration: none; }
.tab-link:hover { background: var(--surface-muted); color: var(--text); }
.tab-link.active { background: var(--primary-soft); color: var(--primary); }
.pagination { display: flex; justify-content: center; gap: 5px; margin-top: 16px; }
.page-link { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text-muted); font-size: 13px; font-weight: 800; text-decoration: none; }
.page-link:hover, .page-link.active { border-color: var(--primary); background: var(--primary); color: #fff; }

.empty-state { padding: 44px 18px; color: var(--text-muted); text-align: center; }
.empty-state i { display: block; margin-bottom: 10px; color: #cbd5e1; font-size: 36px; }
.empty-state p { margin-top: 4px; color: var(--text-subtle); font-size: 13px; }
.avatar { width: 28px; height: 28px; font-size: 11px; flex: 0 0 auto; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 38px; height: 38px; font-size: 14px; }
.list-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.status-banner { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; padding: 13px 15px; border-radius: 8px; font-size: 13px; font-weight: 700; }
.status-banner.pending { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.status-banner.approved { background: #ecfdf5; color: #065f46; border: 1px solid #bbf7d0; }
.status-banner.rejected { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.comment-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.comment-item:last-child { border-bottom: none; }
.comment-author { font-size: 13px; font-weight: 800; }
.comment-meta { color: var(--text-subtle); font-size: 12px; }
.comment-body { margin-top: 6px; color: #374151; font-size: 14px; line-height: 1.7; }

.chat-shell { height: calc(100vh - 184px); min-height: 420px; display: flex; flex-direction: column; }
.chat-header { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); background: #fff; }
.chat-status-dot { width: 9px; height: 9px; border-radius: 999px; background: var(--success); }
.chat-box { flex: 1; overflow-y: auto; padding: 18px; background: var(--surface-muted); }
.chat-composer { padding: 12px 14px; border-top: 1px solid var(--border); background: #fff; }
.chat-bubble { max-width: 360px; padding: 9px 12px; border-radius: 12px; word-break: break-word; font-size: 13px; line-height: 1.55; }
.chat-bubble.me { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble.other { background: #fff; color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-time { color: var(--text-subtle); font-size: 11px; white-space: nowrap; }

.modal-overlay { display: none; position: fixed; inset: 0; z-index: 2000; align-items: center; justify-content: center; padding: 18px; background: rgba(17, 24, 39, 0.48); }
.modal-overlay.open { display: flex; }
.modal-box { width: min(520px, 100%); max-height: 90vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; box-shadow: 0 22px 70px rgba(17, 24, 39, 0.25); }
.modal-header, .modal-body, .modal-footer { padding-left: 20px; padding-right: 20px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding-top: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.modal-title { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; }
.modal-close { width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text-muted); cursor: pointer; }
.modal-body { padding-top: 18px; padding-bottom: 18px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px; padding-bottom: 18px; border-top: 1px solid var(--border); }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) 420px; background: var(--bg); }
.auth-brand { display: flex; flex-direction: column; justify-content: center; padding: 64px; background: #111827; color: #fff; }
.auth-brand h1 { max-width: 560px; margin-top: 40px; font-size: clamp(32px, 5vw, 56px); line-height: 1.06; letter-spacing: -0.03em; }
.auth-brand p { max-width: 500px; margin-top: 18px; color: #cbd5e1; font-size: 16px; }
.auth-feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-width: 480px; margin-top: 38px; }
.auth-feature { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 10px 12px; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px; background: rgba(255, 255, 255, 0.04); color: #e5e7eb; font-size: 13px; font-weight: 700; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px; background: #fff; }
.auth-box { width: 100%; max-width: 360px; }
.auth-box-wide { max-width: 520px; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 32px; color: var(--text); font-size: 18px; font-weight: 800; }
.auth-logo-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; background: var(--primary); color: #fff; }
.auth-title { margin-bottom: 6px; color: var(--text); font-size: 24px; font-weight: 800; }
.auth-subtitle { margin-bottom: 24px; color: var(--text-muted); font-size: 14px; }
.error-box { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 11px 12px; border: 1px solid #fecaca; border-radius: 8px; background: #fef2f2; color: #991b1b; font-size: 13px; font-weight: 700; }
.demo-panel { margin-top: 18px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.demo-panel-header { padding: 10px 12px; background: var(--surface-muted); border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 12px; font-weight: 800; }
.demo-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.demo-row:last-child { border-bottom: none; }
.demo-row:hover { background: var(--surface-muted); }
.demo-info { display: flex; align-items: center; gap: 10px; }
.demo-avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 800; }
.demo-name { color: var(--text); font-size: 13px; font-weight: 800; }
.demo-dept, .demo-pw, .auth-link { color: var(--text-muted); font-size: 12px; }
.auth-link { margin-top: 18px; text-align: center; }
.auth-link a { color: var(--primary); font-weight: 800; text-decoration: none; }

.text-primary { color: var(--primary) !important; } .text-success { color: var(--success) !important; } .text-danger { color: var(--danger) !important; } .text-warning { color: var(--warning) !important; } .text-muted { color: var(--text-muted) !important; }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; } .fw-800 { font-weight: 800; }
.d-flex { display: flex; } .align-items-center { align-items: center; } .justify-content-between { justify-content: space-between; } .justify-content-end { justify-content: flex-end; } .flex-wrap { flex-wrap: wrap; } .flex-grow-1 { flex: 1; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 10px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 10px; } .mt-3 { margin-top: 16px; } .ms-auto { margin-left: auto; } .me-1 { margin-right: 4px; } .me-2 { margin-right: 8px; }
.p-0 { padding: 0 !important; } .w-100 { width: 100%; } .text-center { text-align: center; } .text-end { text-align: right; } .rounded { border-radius: 8px; }
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.col, .col-auto, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-12 { padding: 0 8px; }
.col { flex: 1; } .col-auto { flex: none; } .col-2 { width: 16.666%; } .col-3 { width: 25%; } .col-4 { width: 33.333%; } .col-5 { width: 41.666%; } .col-6 { width: 50%; } .col-7 { width: 58.333%; } .col-8 { width: 66.666%; } .col-9 { width: 75%; } .col-12 { width: 100%; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }

@media (max-width: 1180px) { .dashboard-grid { grid-template-columns: 1fr; } .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1024px) { #sidebar { transform: translateX(-100%); } #sidebar.open { transform: translateX(0); } .sidebar-overlay.open { display: block; } #header { left: 0; } .header-toggle { display: inline-grid; place-items: center; } #main { margin-left: 0; } }
@media (max-width: 768px) {
  #main { padding: 16px; }
  .page-header, .hero-header { align-items: flex-start; flex-direction: column; }
  .header-search { display: none; }
  .stats-grid, .quick-grid, .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .search-form { align-items: stretch; flex-direction: column; }
  .search-field, .search-form select, .search-form .btn { width: 100% !important; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-panel { min-height: 100vh; }
  .row { flex-direction: column; }
  .col, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-12 { width: 100%; }
}
@media (max-width: 520px) { #main { padding: 12px; } .header-profile-name { display: none; } .stats-grid { grid-template-columns: 1fr; } .card-body { padding: 14px; } .auth-panel { padding: 22px; } }

/* Design preset switcher */
.design-switcher {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.design-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 6px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.design-option:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.design-option.active {
  background: var(--primary);
  color: #fff;
}

body {
  transition: background 0.2s ease, color 0.2s ease;
}

body[data-design="modern"] {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #111827;
  --text-muted: #6b7280;
  --text-subtle: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 22px rgba(15, 23, 42, 0.08);
}

/* Dark: dense command-center feel */
body[data-design="dark"] {
  --primary: #38bdf8;
  --primary-dark: #0ea5e9;
  --primary-soft: rgba(56, 189, 248, 0.13);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;
  --info: #67e8f9;
  --bg: #080d16;
  --surface: #111827;
  --surface-muted: #0b1220;
  --text: #e5e7eb;
  --text-muted: #aab3c2;
  --text-subtle: #748094;
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.32);
  --radius: 6px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 30px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 18px 46px rgba(0, 0, 0, 0.36);
  background:
    linear-gradient(180deg, rgba(56, 189, 248, 0.06), transparent 260px),
    var(--bg);
}

body[data-design="dark"] #sidebar {
  background: #050914;
  border-right-color: rgba(148, 163, 184, 0.16);
}

body[data-design="dark"] #header {
  background: rgba(8, 13, 22, 0.86);
  border-bottom-color: var(--border);
}

body[data-design="dark"] .card,
body[data-design="dark"] .table-wrapper,
body[data-design="dark"] .search-bar,
body[data-design="dark"] .header-btn,
body[data-design="dark"] .header-profile,
body[data-design="dark"] .header-search input,
body[data-design="dark"] .design-switcher,
body[data-design="dark"] .tab-nav,
body[data-design="dark"] .modal-box,
body[data-design="dark"] .demo-panel {
  background: rgba(17, 24, 39, 0.92);
  border-color: var(--border);
  color: var(--text);
}

body[data-design="dark"] .card-header,
body[data-design="dark"] .chat-header,
body[data-design="dark"] .chat-composer,
body[data-design="dark"] .modal-header,
body[data-design="dark"] .modal-footer,
body[data-design="dark"] .data-table thead,
body[data-design="dark"] .demo-panel-header {
  background: #0b1220;
  border-color: var(--border);
}

body[data-design="dark"] .stat-card,
body[data-design="dark"] .quick-card,
body[data-design="dark"] .form-control,
body[data-design="dark"] .btn-secondary,
body[data-design="dark"] .btn-ghost,
body[data-design="dark"] .chat-bubble.other,
body[data-design="dark"] .page-link {
  background: #101827;
  border-color: var(--border);
  color: var(--text);
}

body[data-design="dark"] .btn:not(.btn-primary):not(.btn-success):not(.btn-danger),
body[data-design="dark"] .icon-btn {
  background: #101827;
  border-color: var(--border);
  color: var(--text-muted);
}

body[data-design="dark"] .data-table td,
body[data-design="dark"] .comment-item,
body[data-design="dark"] .list-item {
  border-color: rgba(148, 163, 184, 0.12);
}

body[data-design="dark"] .data-table tbody tr:hover,
body[data-design="dark"] .demo-row:hover,
body[data-design="dark"] .design-option:hover {
  background: rgba(56, 189, 248, 0.08);
}

body[data-design="dark"] .chat-box {
  background: #080d16;
}

body[data-design="dark"] .auth-panel {
  background: #111827;
}

body[data-design="dark"] .auth-brand {
  background: #050914;
}

/* Vivid: roomy SaaS dashboard feel */
body[data-design="vivid"] {
  --primary: #7c3aed;
  --primary-dark: #6d28d9;
  --primary-soft: #f3e8ff;
  --success: #10b981;
  --warning: #f97316;
  --danger: #e11d48;
  --info: #06b6d4;
  --bg: #f7f2ff;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-muted: rgba(250, 245, 255, 0.95);
  --text: #20123a;
  --text-muted: #6d5b82;
  --text-subtle: #9788aa;
  --border: rgba(124, 58, 237, 0.16);
  --border-strong: rgba(124, 58, 237, 0.32);
  --radius: 16px;
  --shadow: 0 10px 28px rgba(80, 40, 145, 0.10);
  --shadow-md: 0 22px 54px rgba(80, 40, 145, 0.18);
  background:
    radial-gradient(circle at top left, rgba(124, 58, 237, 0.16), transparent 340px),
    radial-gradient(circle at 92% 12%, rgba(6, 182, 212, 0.14), transparent 360px),
    linear-gradient(180deg, #fbf8ff 0%, #f7f2ff 46%, #f4f8ff 100%);
}

body[data-design="vivid"] #sidebar {
  width: 248px;
  background: linear-gradient(180deg, #3b0764 0%, #581c87 48%, #1e1b4b 100%);
  border-right: 0;
  box-shadow: 16px 0 44px rgba(88, 28, 135, 0.24);
}

body[data-design="vivid"] #header {
  left: 248px;
  height: 68px;
  margin: 14px 18px 0;
  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

body[data-design="vivid"] #main {
  margin-left: 248px;
  margin-top: 82px;
  padding: 28px 32px;
}

body[data-design="vivid"] .sidebar-header {
  height: 74px;
  border-bottom-color: rgba(255, 255, 255, 0.12);
}

body[data-design="vivid"] .sidebar-logo-icon,
body[data-design="vivid"] .avatar,
body[data-design="vivid"] .header-profile-avatar,
body[data-design="vivid"] .sidebar-user-avatar {
  background: linear-gradient(135deg, #f97316, #ec4899 48%, #7c3aed);
}

body[data-design="vivid"] .sidebar-link {
  min-height: 42px;
  border-radius: 12px;
  color: #ede9fe;
}

body[data-design="vivid"] .sidebar-link.active {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

body[data-design="vivid"] .page-title {
  font-size: 26px;
}

body[data-design="vivid"] .stats-grid {
  gap: 18px;
  margin-bottom: 24px;
}

body[data-design="vivid"] .card,
body[data-design="vivid"] .table-wrapper,
body[data-design="vivid"] .search-bar,
body[data-design="vivid"] .stat-card,
body[data-design="vivid"] .quick-card,
body[data-design="vivid"] .modal-box {
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

body[data-design="vivid"] .card-header {
  min-height: 56px;
  background: linear-gradient(135deg, rgba(255,255,255,0.86), rgba(243,232,255,0.78));
}

body[data-design="vivid"] .stat-card,
body[data-design="vivid"] .quick-card {
  padding: 20px;
}

body[data-design="vivid"] .stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
}

body[data-design="vivid"] .stat-value {
  font-size: 30px;
}

body[data-design="vivid"] .btn-primary,
body[data-design="vivid"] .design-option.active,
body[data-design="vivid"] .page-link.active {
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(124, 58, 237, 0.28);
}

body[data-design="vivid"] .data-table tbody tr:hover,
body[data-design="vivid"] .demo-row:hover,
body[data-design="vivid"] .design-option:hover {
  background: rgba(243, 232, 255, 0.66);
}

body[data-design="vivid"] .chat-box {
  background: linear-gradient(180deg, rgba(250,245,255,0.82), rgba(240,249,255,0.82));
}

@media (max-width: 1024px) {
  body[data-design="vivid"] #header {
    left: 0;
    margin: 10px 10px 0;
  }
  body[data-design="vivid"] #main {
    margin-left: 0;
    margin-top: 78px;
  }
}

@media (max-width: 820px) {
  .design-option span { display: none; }
  .design-switcher { gap: 2px; }
  .design-option { width: 32px; padding: 6px; justify-content: center; }
}

@media (max-width: 620px) {
  .design-switcher { order: 5; width: 100%; justify-content: space-between; }
  .design-option { flex: 1; width: auto; }
  .design-option span { display: inline; }
}

/* Customizable dashboard widgets */
.dashboard-hero {
  align-items: center;
}

.dashboard-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  grid-auto-rows: minmax(84px, auto);
  grid-auto-flow: dense;
  gap: 14px;
  align-items: stretch;
}

.dashboard-widget {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 86px;
  flex-direction: column;
  gap: 8px;
  border: 1px dashed transparent;
  border-radius: calc(var(--radius) + 4px);
  transition: opacity 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.dashboard-widget.is-hidden {
  display: none;
}

.dashboard-widget.is-dragging {
  opacity: 0.45;
  transform: scale(0.985);
}

.dashboard-widget.is-drop-target {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dashboard-widget.is-resizing {
  z-index: 5;
}

.widget-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.widget-drag,
.widget-hide {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

.widget-drag {
  cursor: grab;
}

.widget-drag:active {
  cursor: grabbing;
}

.widget-drag:hover,
.widget-hide:hover {
  border-color: var(--border-strong);
  color: var(--primary);
}

.widget-fill {
  flex: 1;
  min-height: 0;
  height: 100%;
}

.dashboard-widget > .card,
.dashboard-widget > .stat-card,
.dashboard-widget > .quick-grid {
  min-height: 100%;
}

.widget-resize {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.widget-resize::before {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--text-subtle);
  border-bottom: 2px solid var(--text-subtle);
}

.dashboard-widget:hover .widget-resize,
.dashboard-widget.is-resizing .widget-resize {
  opacity: 1;
  background: rgba(255, 255, 255, 0.7);
}

.widget-panel {
  position: fixed;
  top: calc(var(--header-height) + 14px);
  right: 24px;
  z-index: 1200;
  width: min(320px, calc(100vw - 32px));
  display: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.widget-panel.open {
  display: block;
}

.widget-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.widget-panel-body {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.widget-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.widget-toggle-row:hover {
  background: var(--surface-muted);
}

.widget-toggle-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.dashboard-table {
  min-width: 560px;
}

.dashboard-quick-grid,
.dashboard-shortcuts {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-content: start;
}

body[data-design="dark"] .dashboard-widget.is-drop-target {
  background: rgba(56, 189, 248, 0.08);
}

body[data-design="dark"] .widget-drag,
body[data-design="dark"] .widget-hide,
body[data-design="dark"] .widget-panel {
  background: var(--surface);
  border-color: var(--border);
}

body[data-design="dark"] .widget-panel-head {
  background: var(--surface-muted);
}

body[data-design="vivid"] .dashboard-board {
  gap: 20px;
  grid-auto-rows: minmax(92px, auto);
}

body[data-design="vivid"] .widget-toolbar {
  padding: 0 6px;
}

body[data-design="vivid"] .widget-drag,
body[data-design="vivid"] .widget-hide {
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.75);
}

body[data-design="vivid"] .widget-panel {
  border-radius: 18px;
  backdrop-filter: blur(18px);
}

@media (max-width: 1180px) {
  .dashboard-board {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 760px) {
  .dashboard-board {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }
  .dashboard-widget {
    grid-column: span 1 !important;
    grid-row: auto !important;
  }
  .widget-resize {
    display: none;
  }
  .widget-panel {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
  }
}

body.is-widget-dragging {
  user-select: none;
  cursor: grabbing;
}

body.is-widget-dragging .dashboard-board {
  touch-action: none;
}

body.is-widget-dragging .dashboard-widget:not(.is-dragging) {
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.widget-drag {
  touch-action: none;
}

.dashboard-widget.widget-placeholder {
  min-height: 86px;
  border: 2px dashed var(--primary);
  background: var(--primary-soft);
  box-shadow: none;
}

.dashboard-widget.is-dragging {
  opacity: 0.96;
  transform-origin: top left;
  filter: drop-shadow(0 22px 36px rgba(15, 23, 42, 0.18));
  will-change: transform;
}

.dashboard-widget.is-dragging .widget-resize {
  display: none;
}

body[data-design="dark"] .dashboard-widget.widget-placeholder {
  background: rgba(56, 189, 248, 0.10);
}

body[data-design="vivid"] .dashboard-widget.widget-placeholder {
  background: rgba(243, 232, 255, 0.72);
}

.widget-panel-section {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

.widget-panel-section:last-child {
  border-bottom: 0;
}

.widget-panel-label {
  margin: 0 0 8px 2px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.layout-preset-list {
  display: grid;
  gap: 8px;
}

.layout-preset-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.layout-preset-info {
  min-width: 0;
}

.layout-preset-info strong,
.layout-preset-info span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout-preset-info strong {
  color: var(--text);
  font-size: 13px;
}

.layout-preset-info span {
  margin-top: 2px;
  color: var(--text-subtle);
  font-size: 11px;
}

.layout-preset-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.layout-preset-actions .icon-btn {
  width: 30px;
  height: 30px;
}

.layout-preset-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

body[data-design="dark"] .layout-preset-row {
  background: #101827;
  border-color: var(--border);
}

body[data-design="vivid"] .layout-preset-row {
  background: rgba(255, 255, 255, 0.72);
}

@media (max-width: 420px) {
  .layout-preset-row {
    grid-template-columns: 1fr;
  }
  .layout-preset-actions {
    justify-content: stretch;
  }
  .layout-preset-actions .btn {
    flex: 1;
  }
}

/* Multi-room chat */
.chat-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 240px;
  gap: 16px;
  align-items: stretch;
}

.chat-room-sidebar,
.chat-member-panel,
.chat-main-shell {
  min-height: calc(100vh - 170px);
}

.chat-room-list {
  display: grid;
  gap: 4px;
  padding: 8px;
  max-height: calc(100vh - 230px);
  overflow-y: auto;
}

.chat-room-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.chat-room-item:hover {
  background: var(--surface-muted);
}

.chat-room-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.chat-room-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-muted);
  color: var(--primary);
}

.chat-room-main {
  min-width: 0;
}

.chat-room-name,
.chat-room-meta,
.chat-room-last {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-room-name {
  font-size: 13px;
  font-weight: 800;
}

.chat-room-meta,
.chat-room-last {
  color: var(--text-muted);
  font-size: 12px;
}

.chat-room-last {
  margin-top: 3px;
}

.chat-member-stack {
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.chat-member-stack .avatar,
.chat-member-stack .badge {
  margin-left: -6px;
  border: 2px solid var(--surface);
}

.chat-author-line {
  margin-bottom: 4px;
  color: #374151;
  font-size: 12px;
  font-weight: 800;
}

.room-type-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.invite-user-list {
  display: grid;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}

.invite-user-item {
  display: grid;
  grid-template-columns: 18px 24px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.invite-user-item:hover {
  background: var(--surface-muted);
}

.invite-user-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.invite-user-item strong,
.invite-user-item small {
  display: block;
}

.invite-user-item strong {
  font-size: 13px;
}

.invite-user-item small {
  color: var(--text-muted);
  font-size: 11px;
}

body[data-design="dark"] .chat-author-line {
  color: var(--text);
}

body[data-design="dark"] .chat-room-item.active {
  background: rgba(56, 189, 248, 0.10);
}

body[data-design="vivid"] .chat-room-item.active {
  background: rgba(243, 232, 255, 0.82);
}

@media (max-width: 1180px) {
  .chat-layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }
  .chat-member-panel {
    display: none;
  }
}

@media (max-width: 760px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }
  .chat-room-sidebar,
  .chat-main-shell {
    min-height: auto;
  }
  .chat-room-list {
    max-height: 260px;
  }
}

/* Calendar enhancements */
.calendar-month-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calendar-month-banner strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
}

body[data-design="dark"] .fc-theme-standard td,
body[data-design="dark"] .fc-theme-standard th,
body[data-design="dark"] .fc-scrollgrid {
  border-color: var(--border) !important;
}

body[data-design="dark"] .fc-daygrid-day,
body[data-design="dark"] .fc-list,
body[data-design="dark"] .fc-timegrid-slot,
body[data-design="dark"] .fc-timegrid-axis,
body[data-design="dark"] .fc-col-header-cell {
  background: var(--surface) !important;
}

body[data-design="dark"] .fc-list-day-cushion,
body[data-design="dark"] .fc-popover-header {
  background: var(--surface-muted) !important;
  color: var(--text) !important;
}

body[data-design="dark"] .fc-event-main,
body[data-design="dark"] .fc-list-event-title,
body[data-design="dark"] .fc-list-event-time {
  color: var(--text) !important;
}

body[data-design="vivid"] .calendar-month-banner {
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(18px);
}

@media (max-width: 640px) {
  .calendar-month-banner {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Approval line picker */
.approval-line-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.approval-picker {
  position: relative;
}

.approval-picker-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: text;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.approval-picker-input:focus,
.approval-picker.open .approval-picker-input {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  outline: 0;
}

.approval-placeholder {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 26px;
}

.approval-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.approval-picker-menu {
  display: none;
  position: absolute;
  z-index: 80;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 260px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.approval-picker.open .approval-picker-menu {
  display: block;
}

.approval-user-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  margin-top: 8px;
  overflow-y: auto;
  padding: 2px;
}

.approval-user-item {
  display: grid;
  grid-template-columns: 18px 28px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.approval-user-item:hover {
  background: var(--surface-muted);
}

.approval-user-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.approval-user-item strong,
.approval-user-item small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.approval-user-item strong {
  color: var(--text);
  font-size: 13px;
}

.approval-user-item small {
  color: var(--text-muted);
  font-size: 11px;
}

.approval-line-summary {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 3px 0;
  min-width: 0;
  color: var(--text);
  font-size: 13px;
}

.approval-line-summary span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.approval-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.35fr);
  gap: 16px;
  margin-bottom: 16px;
}

.approval-document-title {
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.35;
}

.approval-line-detail-grid {
  display: grid;
  gap: 12px;
}

.approval-line-detail-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.approval-line-detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.approval-line-person {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.approval-line-person strong,
.approval-line-person small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.approval-line-person strong {
  color: var(--text);
  font-size: 13px;
}

.approval-line-person small {
  color: var(--text-muted);
  font-size: 11px;
}

.approval-document-content {
  min-height: 220px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.85;
  white-space: pre-wrap;
}

.approval-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.approval-reject-form {
  display: flex;
  flex: 1 1 320px;
  gap: 8px;
  min-width: 280px;
}

.empty-inline {
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

body[data-design="dark"] .approval-picker-input,
body[data-design="dark"] .approval-picker-menu,
body[data-design="dark"] .approval-user-item,
body[data-design="dark"] .approval-line-person {
  background: var(--surface);
}

body[data-design="dark"] .approval-chip,
body[data-design="dark"] .approval-line-detail-group {
  background: var(--surface-muted);
}

body[data-design="vivid"] .approval-picker-menu,
body[data-design="vivid"] .approval-line-detail-group {
  border-radius: 16px;
}

@media (max-width: 980px) {
  .approval-line-grid,
  .approval-detail-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .approval-picker-menu {
    min-width: 0;
  }
  .approval-reject-form {
    flex-basis: 100%;
    min-width: 0;
  }
  .approval-reject-form .btn {
    flex: 0 0 auto;
  }
}

/* Mail */
.mail-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.mail-sidebar {
  position: sticky;
  top: 86px;
  padding: 10px;
}

.mail-folder {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 10px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.mail-folder:hover,
.mail-folder.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.mail-folder strong {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface);
  color: inherit;
  font-size: 11px;
  text-align: center;
}

.mail-folder-meta {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.mail-folder-meta div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.mail-list-head {
  gap: 12px;
  flex-wrap: wrap;
}

.mail-search-form {
  display: flex;
  gap: 6px;
  margin-left: auto;
  min-width: min(360px, 100%);
}

.mail-list {
  display: grid;
}

.mail-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.mail-row:hover {
  background: var(--surface-muted);
}

.mail-row.unread {
  background: color-mix(in srgb, var(--primary-soft) 48%, var(--surface));
}

.mail-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 900;
}

.mail-row-main {
  min-width: 0;
}

.mail-row-top,
.mail-subject {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mail-row-top {
  justify-content: space-between;
  margin-bottom: 4px;
}

.mail-row-top strong,
.mail-subject {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-row-top span,
.mail-preview {
  color: var(--text-muted);
  font-size: 12px;
}

.mail-subject {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.mail-preview {
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-compose-card {
  max-width: 980px;
}

.mail-recipient-picker {
  position: relative;
}

.mail-recipient-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 7px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  cursor: text;
}

.mail-recipient-input:focus,
.mail-recipient-picker.open .mail-recipient-input {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  outline: 0;
}

.mail-recipient-placeholder {
  color: var(--text-muted);
  font-size: 13px;
}

.mail-recipient-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.mail-recipient-menu {
  display: none;
  position: absolute;
  z-index: 80;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.mail-recipient-picker.open .mail-recipient-menu {
  display: block;
}

.mail-user-list {
  display: grid;
  gap: 6px;
  max-height: 280px;
  margin-top: 8px;
  overflow-y: auto;
}

.mail-user-item {
  display: grid;
  grid-template-columns: 18px 26px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.mail-user-item:hover {
  background: var(--surface-muted);
}

.mail-user-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.mail-user-item strong,
.mail-user-item small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-user-item strong {
  color: var(--text);
  font-size: 13px;
}

.mail-user-item small {
  color: var(--text-muted);
  font-size: 11px;
}

.mail-body-input {
  min-height: 320px;
}

.mail-view-card {
  overflow: hidden;
}

.mail-view-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.mail-view-kicker {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.mail-view-header h1 {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 24px;
  line-height: 1.35;
}

.mail-meta-box,
.mail-recipient-summary {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.mail-person-row {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.mail-person-row strong,
.mail-person-row span {
  display: block;
}

.mail-person-row span,
.mail-meta-time {
  color: var(--text-muted);
  font-size: 12px;
}

.mail-recipient-summary {
  justify-content: flex-start;
  align-items: flex-start;
  color: var(--text-muted);
  font-size: 13px;
}

.mail-view-body {
  min-height: 280px;
  padding: 24px 20px 32px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.85;
  white-space: pre-wrap;
}

body[data-design="dark"] .mail-row.unread {
  background: rgba(56, 189, 248, 0.10);
}

body[data-design="dark"] .mail-recipient-input,
body[data-design="dark"] .mail-recipient-menu,
body[data-design="dark"] .mail-user-item,
body[data-design="dark"] .mail-folder strong {
  background: var(--surface);
}

body[data-design="vivid"] .mail-sidebar,
body[data-design="vivid"] .mail-list-card,
body[data-design="vivid"] .mail-compose-card,
body[data-design="vivid"] .mail-view-card,
body[data-design="vivid"] .mail-recipient-menu {
  border-radius: 16px;
}

@media (max-width: 920px) {
  .mail-layout {
    grid-template-columns: 1fr;
  }
  .mail-sidebar {
    position: static;
  }
}

@media (max-width: 640px) {
  .mail-row {
    grid-template-columns: 32px minmax(0, 1fr);
    padding: 12px;
  }
  .mail-avatar {
    width: 32px;
    height: 32px;
  }
  .mail-row-top,
  .mail-meta-box,
  .mail-view-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .mail-search-form {
    width: 100%;
    min-width: 0;
  }
}

/* Notifications */
.notification-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 14px;
  text-align: center;
}
.notification-row { border-bottom: 1px solid var(--border); }
.notification-row:last-child { border-bottom: 0; }
.notification-button {
  width: 100%;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 18px;
  gap: 12px;
  align-items: center;
  padding: 14px 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.notification-button:hover { background: var(--surface-muted); }
.notification-row.unread .notification-button { background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface)); }
.notification-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
}
.notification-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.notification-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.notification-title-row strong,
.notification-message {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notification-message {
  color: var(--text-muted);
  font-size: 13px;
}
body[data-design="dark"] .notification-row.unread .notification-button { background: rgba(56, 189, 248, 0.10); }
@media (max-width: 640px) {
  .notification-button {
    grid-template-columns: 34px minmax(0, 1fr) 14px;
    gap: 9px;
  }
  .notification-title-row { flex-wrap: wrap; }
}

/* Attachments */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.attachment-section {
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}
.attachment-list {
  display: grid;
  gap: 8px;
}
.attachment-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}
.attachment-item:hover {
  border-color: #bfdbfe;
  background: var(--primary-soft);
  color: var(--primary);
}
.attachment-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-item small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}
.chat-attachments {
  display: grid;
  gap: 5px;
  max-width: 360px;
  margin-top: 6px;
}
.chat-attachments .attachment-item {
  grid-template-columns: 16px minmax(0, 1fr);
  min-height: 30px;
  padding: 6px 8px;
  font-size: 12px;
}
.chat-attachments .attachment-item small {
  display: none;
}
.chat-attachments.me .attachment-item {
  border-color: rgba(255,255,255,0.35);
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
}
body[data-design="dark"] .attachment-item {
  background: var(--surface);
  border-color: var(--border);
}

.rich-editor {
  min-height: 280px;
  background: #fff;
}

.rich-editor .ql-editor {
  min-height: 240px;
  font-size: 14px;
  line-height: 1.75;
}

.rich-editor .ql-editor img,
.rich-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.rich-content {
  min-height: 220px;
  font-size: 15px;
  line-height: 1.85;
  word-break: break-word;
}

.rich-content p {
  margin: 0 0 12px;
}

.rich-content ul,
.rich-content ol {
  padding-left: 24px;
  margin: 8px 0 14px;
}

.rich-content blockquote {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--primary);
  background: var(--surface-muted);
  color: var(--text-muted);
}

.rich-content pre {
  overflow-x: auto;
  padding: 12px;
  border-radius: 8px;
  background: #111827;
  color: #f9fafb;
}

.rich-content a {
  color: var(--primary);
  text-decoration: underline;
}

.chat-image-link {
  display: inline-flex;
  max-width: 92px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
}

.chat-image-preview {
  width: 92px;
  height: 68px;
  object-fit: cover;
  display: block;
}

body[data-design="dark"] .rich-editor,
body[data-design="dark"] .ql-toolbar,
body[data-design="dark"] .ql-container {
  background: #111827;
  color: var(--text);
  border-color: var(--border) !important;
}

body[data-design="dark"] .ql-stroke {
  stroke: var(--text);
}

body[data-design="dark"] .ql-fill {
  fill: var(--text);
}

body[data-design="dark"] .ql-picker,
body[data-design="dark"] .ql-picker-options {
  color: var(--text);
  background: #111827;
}

body[data-design="dark"] .chat-image-link {
  background: #111827;
  border-color: var(--border);
}
