@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-subtle: rgba(99,102,241,0.1);
    --accent-ring: rgba(99,102,241,0.25);
    --success: #22c55e;
    --success-bg: rgba(34,197,94,0.1);
    --success-text: #16a34a;
    --warning: #f59e0b;
    --warning-bg: rgba(245,158,11,0.1);
    --warning-text: #d97706;
    --danger: #ef4444;
    --danger-bg: rgba(239,68,68,0.1);
    --danger-text: #dc2626;
    --sidebar-bg: #0f0f11;
    --sidebar-hover: rgba(255,255,255,0.04);
    --sidebar-active-bg: rgba(99,102,241,0.12);
    --sidebar-text: rgba(255,255,255,0.45);
    --sidebar-text-hover: rgba(255,255,255,0.85);
    --sidebar-text-active: #fff;
    --sidebar-border: rgba(255,255,255,0.06);
    --sidebar-width: 240px;
    --bg: #f5f5f7;
    --card-bg: #ffffff;
    --surface-hover: #f8f8fa;
    --text: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --border: rgba(0,0,0,0.08);
    --border-light: rgba(0,0,0,0.04);
    --shadow: 0px 0px 0px 1px rgba(0,0,0,0.08);
    --shadow-card: 0px 0px 0px 1px rgba(0,0,0,0.06), 0px 1px 3px rgba(0,0,0,0.04);
    --shadow-elevated: 0px 0px 0px 1px rgba(0,0,0,0.06), 0px 4px 16px rgba(0,0,0,0.06);
    --shadow-dialog: 0px 0px 0px 1px rgba(0,0,0,0.08), 0px 8px 32px rgba(0,0,0,0.12);
    --radius: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 9999px;
}

body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); position: relative; }
.login-page::before { content: ''; position: fixed; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(ellipse at 30% 20%, rgba(99,102,241,0.06) 0%, transparent 50%), radial-gradient(ellipse at 70% 80%, rgba(99,102,241,0.04) 0%, transparent 50%); pointer-events: none; }
.login-container { background: var(--card-bg); border-radius: var(--radius-lg); padding: 40px 36px 32px; width: 400px; max-width: 92vw; box-shadow: var(--shadow-card); position: relative; z-index: 1; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 1.35rem; font-weight: 600; color: var(--text); margin-top: 14px; letter-spacing: -0.02em; }
.login-logo p { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }
.login-form .form-group { margin-bottom: 18px; }
.login-form .form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 0.82rem; color: var(--text); }
.login-form .form-control { width: 100%; padding: 10px 14px; border: 1.5px solid #e4e4e7; border-radius: var(--radius); font-size: 0.92rem; transition: all 0.15s; background: #fafafa; font-family: var(--font); height: 44px; color: var(--text); }
.login-form .form-control:hover { border-color: #d4d4d8; background: #fff; }
.login-form .form-control:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-ring); }
.login-form .btn { margin-top: 2px; height: 46px; font-size: 0.92rem; font-weight: 500; border-radius: var(--radius); }
.login-footer { text-align: center; margin-top: 20px; font-size: 0.75rem; color: var(--text-muted); }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-width); background: var(--sidebar-bg); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; overflow: hidden; }
.sidebar-header { padding: 16px 18px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--sidebar-border); flex-shrink: 0; }
.sidebar-title { font-size: 1rem; font-weight: 600; color: rgba(255,255,255,0.9); letter-spacing: -0.02em; }
.sidebar-nav { flex: 1; padding: 6px 0; overflow-y: auto; }
.nav-section { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.25); padding: 14px 18px 5px; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 18px; margin: 1px 10px 1px 0; color: var(--sidebar-text); text-decoration: none; font-size: 0.82rem; font-weight: 500; transition: all 0.12s; border-radius: 0 var(--radius) var(--radius) 0; position: relative; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-hover); }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-text-active); }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 4px; bottom: 4px; width: 2px; background: var(--accent); border-radius: 0 2px 2px 0; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.active .nav-icon svg { stroke: var(--accent); }
.sidebar-footer { padding: 10px 14px; border-top: 1px solid var(--sidebar-border); flex-shrink: 0; }
.user-badge { display: flex; align-items: center; gap: 8px; color: var(--sidebar-text); font-size: 0.78rem; padding: 4px 4px; }
.user-avatar { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: white; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 600; flex-shrink: 0; }
.user-name { flex: 1; font-weight: 500; color: rgba(255,255,255,0.6); }
.logout-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px; margin-top: 4px; color: rgba(248,113,113,0.6) !important; font-size: 0.78rem; text-decoration: none; border-radius: var(--radius); transition: all .12s; font-weight: 500; }
.logout-item:hover { color: #ef4444 !important; background: rgba(239,68,68,0.08) !important; text-decoration: none; }

/* Main */
.main-content { margin-left: var(--sidebar-width); flex: 1; padding: 28px 36px; min-height: 100vh; max-width: 1280px; }
.content-header { margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.content-header h1 { font-size: 1.3rem; font-weight: 600; color: var(--text); letter-spacing: -0.02em; }

/* Cards */
.card { background: var(--card-bg); border-radius: var(--radius-md); box-shadow: var(--shadow-card); margin-bottom: 20px; }
.card-header { padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-header h3, .card-header h4 { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.card-body { padding: 16px 20px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 18px 20px; border: none; transition: all 0.15s; }
.stat-card:hover { box-shadow: var(--shadow-elevated); }
.stat-card .stat-icon { font-size: 1.3rem; margin-bottom: 6px; display: block; color: var(--accent); }
.stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.stat-value { font-size: 1.5rem; font-weight: 600; color: var(--text); letter-spacing: -0.03em; }
.stat-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 3px; }
.card-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.card-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* Tables */
.table-wrapper { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border-light); font-size: 0.84rem; }
.table th { font-weight: 500; color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; background: transparent; padding-top: 6px; padding-bottom: 6px; }
.table tr:hover { background: var(--surface-hover); }
.table tr:last-child td { border-bottom: none; }
.action-cell { white-space: nowrap; text-align: right; }
.action-cell .btn + .btn { margin-left: 6px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--radius-pill); font-size: 0.72rem; font-weight: 500; line-height: 1.6; }
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-primary { background: var(--accent-subtle); color: var(--accent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 16px; border-radius: var(--radius); font-size: 0.82rem; font-weight: 500; font-family: var(--font); text-decoration: none; cursor: pointer; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); transition: all 0.12s; line-height: 1.4; white-space: nowrap; user-select: none; }
.btn:hover { background: var(--surface-hover); border-color: #c4c4c7; text-decoration: none; box-shadow: var(--shadow); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover { background: #16a34a; border-color: #16a34a; }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; border-radius: 4px; }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn-lg { padding: 10px 24px; font-size: 0.9rem; }

/* Forms */
.form { max-width: 620px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 0.82rem; color: var(--text); }
.form-control { width: 100%; padding: 9px 13px; border: 1.5px solid #e4e4e7; border-radius: var(--radius); font-size: 0.88rem; font-family: var(--font); transition: all 0.15s; background: #fafafa; color: var(--text); height: 42px; }
.form-control:hover { border-color: #d4d4d8; background: #fff; }
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background: #fff; }
.form-control::placeholder { color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-fieldset { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px 20px; margin-bottom: 16px; }
.form-fieldset legend { font-weight: 500; font-size: 0.84rem; padding: 0 8px; color: var(--text); }
.checkbox-group { display: flex; align-items: center; gap: 8px; }
.checkbox-group label { margin: 0; display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
textarea.form-control { min-height: 90px; line-height: 1.5; height: auto; resize: vertical; }
textarea.code-editor { font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.5; min-height: 180px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius) 0 0 var(--radius); }
.input-group-text { padding: 9px 13px; background: #f4f4f5; border: 1.5px solid #e4e4e7; border-left: none; border-radius: 0 var(--radius) var(--radius) 0; font-size: 0.84rem; color: var(--text-muted); display: flex; align-items: center; }
.switch-label { display: flex; align-items: center; gap: 12px; cursor: pointer; position: relative; padding-left: 0; }
.switch-label input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-slider { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; background: #d4d4d8; border-radius: 11px; transition: all 0.2s; }
.switch-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: white; border-radius: 50%; transition: all 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.switch-label input:checked + .switch-slider { background: var(--accent); }
.switch-label input:checked + .switch-slider::before { transform: translateX(18px); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-md); margin-bottom: 14px; font-size: 0.84rem; display: flex; align-items: center; gap: 8px; line-height: 1.4; }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error { background: var(--danger-bg); color: var(--danger-text); }
.alert-info { background: var(--accent-subtle); color: var(--accent); }

/* Utilities */
.toolbar { margin-bottom: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.code-font { font-family: var(--font-mono); font-size: 0.82rem; }
code { background: #f4f4f5; padding: 2px 7px; border-radius: 4px; font-size: 0.82rem; font-family: var(--font-mono); border: 1px solid var(--border-light); }
pre { background: #fafafa; padding: 14px; border-radius: var(--radius); overflow-x: auto; border: 1px solid var(--border-light); font-family: var(--font-mono); font-size: 0.82rem; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border-light); margin-bottom: 20px; }
.tab { padding: 9px 18px; font-size: 0.84rem; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--text-muted); transition: all 0.12s; background: none; border-top: none; border-left: none; border-right: none; font-family: var(--font); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }
.progress-bar { height: 6px; background: #f4f4f5; border-radius: 3px; overflow: hidden; margin-bottom: 5px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; min-width: 3px; }
.progress-fill-warning { background: var(--warning); }
.progress-fill-danger { background: var(--danger); }
.service-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border-light); font-size: 0.84rem; }
.service-row:last-child { border-bottom: none; }
.service-row .service-name { display: flex; align-items: center; gap: 8px; }
.service-row .service-name .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.service-row .service-name .dot.active { background: var(--success); }
.service-row .service-name .dot.inactive { background: var(--warning); }
.service-row .service-name .dot.error { background: var(--danger); }
.compose-preview { border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 20px; min-height: 120px; background: var(--card-bg); margin-top: 10px; }
.sender-card { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--surface-hover); border: 1px solid var(--border-light); border-radius: var(--radius); margin-bottom: 6px; transition: all 0.12s; }
.sender-card:hover { border-color: var(--accent); background: var(--accent-subtle); }
.sender-card .sender-info { display: flex; flex-direction: column; gap: 2px; }
.sender-card .sender-name { font-weight: 600; font-size: 0.85rem; }
.sender-card .sender-email { font-size: 0.8rem; color: var(--text-muted); }
.sender-default { font-size: 0.68rem; background: var(--accent-subtle); color: var(--accent); padding: 2px 10px; border-radius: var(--radius-pill); font-weight: 500; }
.dual-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; min-height: 360px; }
.dual-editor .editor-pane, .dual-editor .preview-pane { display: flex; flex-direction: column; }
.dual-editor .pane-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.dual-editor textarea { flex: 1; min-height: 300px; resize: vertical; margin: 0; border-radius: var(--radius); border: 1.5px solid #e4e4e7; padding: 12px; font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.5; }
.dual-editor .rendered-preview { flex: 1; border: 1.5px solid #e4e4e7; border-radius: var(--radius); padding: 16px; overflow-y: auto; background: var(--card-bg); min-height: 300px; font-size: 0.85rem; }
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(4px); }
.modal { background: var(--card-bg); border-radius: var(--radius-lg); padding: 24px; max-width: 480px; width: 90vw; box-shadow: var(--shadow-dialog); }
.modal h3 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.fm-layout { display: flex; gap: 0; background: var(--card-bg); border-radius: var(--radius-md); border: none; overflow: hidden; box-shadow: var(--shadow-card); }
.fm-tree { width: 200px; min-width: 160px; border-right: 1px solid var(--border-light); background: #fafafa; padding: 6px 0; overflow-y: auto; max-height: 560px; }
.fm-tree-item { padding: 5px 12px; font-size: 0.8rem; cursor: pointer; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-tree-item:hover { background: #f0f0f2; }
.fm-tree-item.active { background: var(--accent-subtle); color: var(--accent); font-weight: 500; }
.fm-tree-item .indent { display: inline-block; width: 14px; }
.fm-main { flex: 1; }
.fm-toolbar { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border-light); flex-wrap: wrap; background: #fafafa; align-items: center; }
.fm-toolbar .btn { font-size: 0.76rem; padding: 4px 9px; }
.fm-breadcrumb { padding: 6px 12px; font-size: 0.8rem; border-bottom: 1px solid var(--border-light); background: var(--card-bg); display: flex; gap: 3px; align-items: center; flex-wrap: wrap; }
.fm-breadcrumb a { color: var(--accent); text-decoration: none; }
.domain-card:hover { border-color: var(--accent) !important; transform: translateY(-2px); box-shadow: var(--shadow-elevated); }

/* Responsive */
@media (min-width: 1200px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 992px) { .card-grid { grid-template-columns: 1fr; } .card-grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 768px) {
    .sidebar { width: 56px; }
    .sidebar-header { padding: 12px; justify-content: center; }
    .sidebar-title, .sidebar-nav .nav-item span:not(.nav-icon), .user-name, .nav-section { display: none; }
    .sidebar-footer { padding: 8px; }
    .user-badge { justify-content: center; }
    .user-avatar { width: 22px; height: 22px; font-size: 0.6rem; }
    .logout-item { justify-content: center; padding: 6px; }
    .logout-item span { display: none; }
    .nav-item { padding: 10px; justify-content: center; margin-right: 0; }
    .nav-item.active::before { display: none; }
    .nav-item.active { background: var(--sidebar-active-bg); }
    .main-content { margin-left: 56px; padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .card-grid-3 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .dual-editor { grid-template-columns: 1fr; }
    .content-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr; } .login-container { padding: 28px 20px; } .main-content { padding: 12px; } }
