/* Admin panel. Builds on site.css. Sidebar is off-canvas below 1000px. */
.admin-body { padding-bottom: 0; background: #f2f4f7; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; background: #101828; color: #d0d5dd;
    display: flex; flex-direction: column; transform: translateX(-100%); transition: transform .2s;
}
.sidebar.open { transform: none; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 40; }
.sidebar.open + .sidebar-backdrop { display: block; }
.sidebar-brand { display: flex; align-items: center; gap: 8px; padding: 18px 20px; font-weight: 800; color: #fff; }
.sidebar-brand svg { width: 26px; height: 26px; fill: #5eead4; flex: none; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: #d0d5dd; font-weight: 500; text-decoration: none; }
.sidebar-nav a:hover { background: #1d2939; }
.sidebar-nav a.active { background: #0f766e; color: #fff; }
.sidebar-nav .badge { margin-left: auto; background: #ef4444; }
.nav-icon { width: 22px; text-align: center; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid #344054; }
.sidebar-foot a { color: #98a2b3; }

.admin-main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; background: #fff; border-bottom: 1px solid var(--line); padding: 8px 16px; min-height: 60px; }
.topbar-title { font-size: 1.15rem; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-name { display: none; font-weight: 600; }
.user-name small { color: var(--muted); font-weight: 500; }
.admin-toggle { display: flex; }
.admin-content { padding: 16px; max-width: 1280px; }
.admin-content > .alert { margin: 0 0 16px; }

@media (min-width: 1000px) {
    .sidebar { transform: none; }
    .sidebar-backdrop, .sidebar.open + .sidebar-backdrop { display: none; }
    .admin-main { margin-left: 260px; }
    .admin-toggle { display: none; }
    .user-name { display: inline; }
    .admin-content { padding: 24px; }
}

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .stats { grid-template-columns: repeat(6, 1fr); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--text); text-decoration: none !important; }
.stat strong { display: block; font-size: 1.6rem; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.red strong { color: var(--red); }
.stat.green strong { color: var(--green); }

/* Toolbars and tabs */
.admin-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.admin-toolbar form { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.admin-toolbar input, .admin-toolbar select { width: auto; flex: 1 1 160px; min-height: 40px; padding: 8px 10px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.tabs a { padding: 7px 14px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--text); white-space: nowrap; text-decoration: none; font-weight: 500; }
.tabs a.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Tables become cards on phones */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #f9fafb; }
.table tr:last-child td { border-bottom: 0; }
.table a.row-link { font-weight: 600; }
@media (max-width: 799px) {
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
    .table td { border: 0; padding: 4px 14px; }
    .table td[data-label]::before { content: attr(data-label); display: block; font-size: .75rem; color: var(--muted); }
}
.thumb { width: 64px; height: 48px; border-radius: 6px; object-fit: cover; background: #eef1f4; }
.thumb .placeholder svg { width: 50%; }

/* Detail pages */
.two-col { display: grid; gap: 16px; }
@media (min-width: 1000px) { .two-col { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; } }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0; }
@media (min-width: 640px) { .kv { grid-template-columns: repeat(3, 1fr); } }
.kv dt { font-size: .78rem; color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.private { border-left: 4px solid #f59e0b; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photo { position: relative; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; }
.photo .actions { display: flex; gap: 4px; margin-top: 4px; }
.photo .actions .btn { flex: 1; min-height: 30px; padding: 2px 6px; font-size: .78rem; }
.cover-tag { position: absolute; top: 6px; left: 6px; background: var(--brand); color: #fff; font-size: .7rem; padding: 1px 8px; border-radius: 99px; }
.list-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline-form .field { flex: 1 1 180px; margin: 0; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.form-section { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.form-section h2 { font-size: 1rem; margin-bottom: 12px; }
.form-section .help { color: var(--muted); font-size: .85rem; margin-top: -6px; margin-bottom: 12px; }
.grid-3 { display: grid; gap: 0 12px; }
@media (min-width: 640px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.agent-picks { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.agent-picks label { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.agent-picks input { width: auto; min-height: 0; }
.danger { color: var(--red) !important; border-color: var(--red) !important; }

/* Chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 160px); min-height: 420px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: #f8fafb; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line); align-self: flex-start; white-space: pre-line; word-break: break-word; }
.bubble.mine { align-self: flex-end; background: var(--brand); border-color: var(--brand); color: #fff; }
.bubble small { display: block; font-size: .7rem; opacity: .7; margin-top: 2px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form textarea { min-height: 44px; max-height: 120px; }
.inbox a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.inbox a:last-child { border-bottom: 0; }
.inbox a:hover { background: #f9fafb; }
.inbox .preview { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
