* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f5f5f5; color: #1a1a1a; display: flex; min-height: 100vh; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Sidebar */
.sidebar { width: 220px; background: #1e293b; color: #e2e8f0; padding: 20px 0; flex-shrink: 0; }
.sidebar h2 { padding: 0 20px 20px; font-size: 15px; color: #94a3b8; border-bottom: 1px solid #334155; margin-bottom: 10px; }
.sidebar a { display: block; padding: 10px 20px; color: #cbd5e1; font-size: 14px; }
.sidebar a:hover, .sidebar a.active { background: #334155; color: #fff; text-decoration: none; }
.sidebar .logout { margin-top: auto; border-top: 1px solid #334155; padding-top: 10px; }

/* Main */
.main { flex: 1; padding: 24px 32px; max-width: 1200px; }
.main h1 { font-size: 22px; margin-bottom: 20px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.card .label { font-size: 12px; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; }
.card .value { font-size: 28px; font-weight: 700; margin-top: 4px; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 20px; }
th { background: #f8fafc; text-align: left; padding: 10px 14px; font-size: 12px; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #e2e8f0; }
td { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
tr:hover td { background: #f8fafc; }
tr.clickable { cursor: pointer; }

/* Status badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 9999px; font-size: 12px; font-weight: 500; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-expired { background: #fee2e2; color: #991b1b; }
.badge-closed { background: #e2e8f0; color: #475569; }
.badge-replacement { background: #ede9fe; color: #5b21b6; }
/* Chat reachability */
.badge-chat-active { background: #d1fae5; color: #065f46; }
.badge-chat-unknown { background: #e2e8f0; color: #475569; }
.badge-chat-blocked { background: #fee2e2; color: #991b1b; }
.badge-chat-deactivated { background: #f3e8ff; color: #6b21a8; }
.badge-chat-unreachable { background: #fef3c7; color: #92400e; }

/* Forms */
input, select, textarea { padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.1); }
textarea { min-height: 100px; resize: vertical; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 500; color: #374151; }

/* Buttons */
.btn { display: inline-block; padding: 8px 16px; border-radius: 6px; font-size: 14px; font-weight: 500; cursor: pointer; border: none; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; text-decoration: none; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: #7c3aed; color: #fff; }
.btn-warning:hover { background: #6d28d9; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Progress bars */
.progress-wrap { margin-bottom: 8px; }
.progress-label { font-size: 13px; display: flex; justify-content: space-between; margin-bottom: 2px; }
.progress-bar { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: #2563eb; border-radius: 4px; }

/* Chart */
.chart-wrap { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 24px; }

/* Pagination */
.pagination { display: flex; gap: 4px; margin-bottom: 20px; }
.pagination a, .pagination span { padding: 6px 12px; border-radius: 4px; font-size: 13px; }
.pagination a { background: #fff; border: 1px solid #d1d5db; }
.pagination a:hover { background: #f1f5f9; text-decoration: none; }
.pagination .current { background: #2563eb; color: #fff; }

/* Filters */
.filters { display: flex; gap: 12px; margin-bottom: 16px; align-items: end; flex-wrap: wrap; }
.filters .form-group { margin-bottom: 0; }
.filters input, .filters select { width: auto; min-width: 140px; }

/* Flash */
.flash { padding: 10px 16px; background: #d1fae5; color: #065f46; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }

/* Inline edit */
.inline-edit { cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.inline-edit:hover { background: #e2e8f0; }

/* Login pages */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; width: 100%; background: #f5f5f5; }
.login-box { background: #fff; padding: 40px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); width: 360px; }
.login-box h1 { font-size: 20px; margin-bottom: 20px; text-align: center; }
.login-box .error { color: #ef4444; font-size: 13px; margin-bottom: 12px; }

/* Broadcasts */
.bc-muted { color: #64748b; font-size: 13px; }
.bc-alert { padding: 10px 16px; background: #fee2e2; color: #991b1b; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.bc-panel { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); padding: 16px 20px; margin: 16px 0; }
.bc-panel h3 { font-size: 15px; margin-bottom: 10px; }
.bc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.bc-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.bc-toolbar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.bc-toolbar button { padding: 4px 10px; border: 1px solid #d1d5db; background: #fff; border-radius: 4px; cursor: pointer; font-size: 13px; }
.bc-toolbar button:hover { background: #f1f5f9; }
.bc-textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; min-height: 220px; }
.bc-text { white-space: pre-wrap; word-break: break-word; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 12px; font-size: 14px; max-height: 360px; overflow: auto; }
.bc-small td, .bc-small th { padding: 6px 10px; font-size: 13px; }
.bc-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: #e2e8f0; }
.bc-bar .seg { height: 100%; width: 0; transition: width .4s; }
.seg-delivered { background: #10b981; } .seg-failed { background: #ef4444; } .seg-unknown { background: #f59e0b; }
.seg-pending { background: #94a3b8; } .seg-skipped { background: #cbd5e1; }
.bc-st-draft, .bc-st-cancelled, .bc-st-missed { background: #e2e8f0; color: #475569; }
.bc-st-scheduled, .bc-st-queued { background: #dbeafe; color: #1e40af; }
.bc-st-running { background: #d1fae5; color: #065f46; }
.bc-st-paused { background: #fef3c7; color: #92400e; }
.bc-st-completed { background: #d1fae5; color: #065f46; }
.bc-st-failed { background: #fee2e2; color: #991b1b; }
.bc-rs-sent { background: #d1fae5; color: #065f46; }
.bc-rs-blocked, .bc-rs-deactivated, .bc-rs-unreachable, .bc-rs-failed { background: #fee2e2; color: #991b1b; }
.bc-rs-unknown { background: #fef3c7; color: #92400e; }
.bc-rs-pending, .bc-rs-sending, .bc-rs-cancelled, .bc-rs-skipped { background: #e2e8f0; color: #475569; }

/* Stock folders (account types) */
.folder-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.folder-tab { padding: 8px 16px; border-radius: 6px 6px 0 0; border: 1px solid #e2e8f0; border-bottom: 2px solid transparent; background: #f8fafc; color: #334155; font-size: 14px; text-decoration: none; }
.folder-tab:hover { background: #f1f5f9; text-decoration: none; }
.folder-tab.active { background: #fff; border-bottom-color: #2563eb; color: #1d4ed8; font-weight: 600; }
.folder-count { display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px; border-radius: 9999px; background: #e2e8f0; font-size: 12px; text-align: center; }
.folder-tab.active .folder-count { background: #dbeafe; }
