/* === Mail Admin Dashboard === */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e3e6eb;
    --text: #1a1f2e;
    --text-muted: #6b7280;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --radius: 10px;
    --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
}
body.centered {
    align-items: center;
    justify-content: center;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0;
    height: 100vh;
    position: sticky;
    top: 0;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 1.25rem 1.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}
.brand .logo {
    width: 32px; height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.sidebar nav {
    flex: 1;
    display: flex; flex-direction: column;
    padding: 0 0.5rem;
}
.sidebar nav a {
    display: flex; align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.75rem;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin: 1px 0;
    font-size: 0.92rem;
}
.sidebar nav a:hover { background: var(--bg); }
.sidebar nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 500;
}
.sidebar nav .ico {
    display: inline-flex;
    width: 20px; height: 20px;
    align-items: center; justify-content: center;
    color: var(--text-muted);
    font-size: 1rem;
}
.sidebar nav a.active .ico { color: var(--primary); }
.sep { height: 1px; background: var(--border); margin: 0.75rem 0.5rem; }

.user {
    padding: 1rem 1.25rem 0;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}
.user-name {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.logout {
    color: var(--danger);
    text-decoration: none;
    font-size: 0.85rem;
}
.logout:hover { text-decoration: underline; }

/* Content */
.content {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1400px;
    width: 100%;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1rem;
}
.page-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}
.page-header p { margin: 0.25rem 0 0; }

.muted { color: var(--text-muted); }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.card h2 {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-weight: 600;
}
.card.no-pad { padding: 0; }
.card.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2.5rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}
.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}
@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
    .sidebar { width: 200px; }
    .content { padding: 1.5rem; }
}

/* Action tiles */
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.action-tile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    transition: all 0.1s;
}
.action-tile:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
}
.action-ico {
    width: 36px; height: 36px;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.action-title {
    font-weight: 500;
    font-size: 0.92rem;
}
.action-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.table thead th {
    text-align: left;
    padding: 0.85rem 1.25rem;
    font-weight: 500;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}
.table tbody td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }
.table.compact thead th, .table.compact tbody td {
    padding: 0.5rem 0.75rem;
}

.row-actions {
    text-align: right;
    white-space: nowrap;
}
.row-actions .btn { margin-left: 0.25rem; }

/* Pills */
.pill {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
}
.pill-ok { background: #d1fae5; color: #065f46; }
.pill-off { background: #fef3c7; color: #92400e; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: all 0.1s;
}
.btn:hover {
    background: var(--bg);
    border-color: #c5cad2;
}
.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}
.btn-danger {
    color: var(--danger);
    border-color: #fee2e2;
}
.btn-danger:hover {
    background: #fee2e2;
    color: var(--danger-hover);
    border-color: #fca5a5;
}
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn-block { display: block; width: 100%; text-align: center; }

/* Forms */
label {
    display: block;
    margin-bottom: 1rem;
}
label > span {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text);
}
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: inherit;
    background: white;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.input-with-btn {
    display: flex; gap: 0.5rem;
}
.input-with-btn input { flex: 1; }

/* Modal (dialog) */
dialog.modal {
    border: none;
    border-radius: var(--radius);
    padding: 1.75rem;
    max-width: 460px;
    width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}
dialog.modal::backdrop {
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
}
dialog.modal h2 {
    margin: 0 0 1rem;
    font-size: 1.15rem;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Login */
.login-card {
    width: 380px;
    padding: 2.25rem;
}
.login-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}
.logo-big {
    width: 56px; height: 56px;
    background: var(--primary);
    color: white;
    border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 0.75rem;
}
.login-brand h1 {
    margin: 0;
    font-size: 1.4rem;
}
.login-brand p {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Flash */
.flash {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}
.flash-ok { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* Filter bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
    background: var(--surface);
    padding: 0.6rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.filter-bar select {
    width: auto;
    padding: 0.35rem 0.6rem;
}
.filter-bar label { margin: 0; font-weight: 500; }

/* Quota bar */
.bar {
    width: 100px;
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    margin-top: 0.3rem;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}
.bar-warn { background: var(--danger); }

/* DNS */
.grid-sidebar {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.25rem;
}
@media (max-width: 800px) {
    .grid-sidebar { grid-template-columns: 1fr; }
}
.list-header {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.list-nav {
    list-style: none;
    margin: 0; padding: 0.5rem;
}
.list-nav a {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}
.list-nav a:hover { background: var(--bg); }
.list-nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 500;
}
.dns-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem;
}
.dns-header h2 { margin: 0; }
.dns-content {
    background: #1a1f2e;
    color: #e2e8f0;
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Edit modal extras */
label.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
label.checkbox input { width: auto; margin: 0; }
label.checkbox span { margin: 0; font-weight: 500; }
.grid-2-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
small.muted {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.78rem;
}
/* === Interactive Extras === */

/* Toast / Flash transitions */
.flash {
    transition: opacity 0.3s, transform 0.3s;
    cursor: pointer;
}
.flash.toast {
    position: fixed;
    top: 1.25rem;
    left: 50%;
    transform: translate(-50%, -10px);
    opacity: 0;
    z-index: 9999;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    min-width: 280px;
    text-align: center;
}
.flash.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: -2px;
    margin-right: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Confirm dialog */
.confirm-dialog {
    text-align: center;
    max-width: 400px;
}
.confirm-dialog h2 { margin-top: 0.5rem; }
.confirm-dialog .modal-actions {
    justify-content: center;
    margin-top: 1.25rem;
}
.confirm-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 0.25rem;
}
.confirm-icon.danger {
    background: #fee2e2;
    color: var(--danger);
}
.btn-danger-solid {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.btn-danger-solid:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
    color: white;
}

/* Modal entrance animation */
dialog.modal[open] {
    animation: modal-pop 0.18s ease-out;
}
dialog.modal[open]::backdrop {
    animation: backdrop-fade 0.18s ease-out;
}
@keyframes modal-pop {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes backdrop-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Sortable columns */
th.sortable-col {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.5rem !important;
}
th.sortable-col:hover { color: var(--text); background: #f3f4f6; }
th.sortable-col::after {
    content: '⇅';
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
    font-size: 0.9rem;
}
th[data-sort-dir=asc]::after { content: '↑'; opacity: 1; color: var(--primary); }
th[data-sort-dir=desc]::after { content: '↓'; opacity: 1; color: var(--primary); }

/* Search input in toolbar */
.search-bar {
    position: relative;
    flex: 1;
    max-width: 320px;
}
.search-bar input {
    padding-left: 2.25rem;
}
.search-bar::before {
    content: '⌕';
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 1rem;
}
.search-bar .kbd {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    pointer-events: none;
}

/* Toolbar (search + filter) */
.toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.toolbar select {
    width: auto;
    padding: 0.5rem 0.65rem;
}

/* Quota bar transition */
.bar-fill {
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Copy button */
[data-copy] { cursor: pointer; }
.btn-ok {
    background: var(--success) !important;
    color: white !important;
    border-color: var(--success) !important;
}

/* Row hover/transition */
.table tbody tr {
    transition: background 0.1s;
}
.table tbody td { transition: opacity 0.2s; }

/* Action tile lift on hover */
.action-tile { transition: all 0.15s; }
.action-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79,70,229,0.12);
}

/* Stat cards */
.stat-card {
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.stat-value { transition: color 0.2s; }

/* Buttons */
.btn { transition: all 0.1s; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Sidebar nav link hover */
.sidebar nav a { transition: background 0.1s, color 0.1s; }

/* Empty state */
.card.empty {
    padding: 3rem 2rem;
}
.empty-ico {
    font-size: 2.5rem;
    color: var(--text-muted);
    opacity: 0.5;
    margin-bottom: 0.75rem;
}

/* DNS pre block - copy hint */
.dns-content { position: relative; }

/* Password input with eye toggle */
.input-pw-wrap {
    position: relative;
}
.input-pw-wrap input {
    padding-right: 2.5rem;
}
.input-pw-wrap .pw-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.05rem;
    color: var(--text-muted);
}

/* Clickable rows */
.table.clickable tbody tr {
    cursor: pointer;
}
.table.clickable tbody tr:hover {
    background: var(--primary-soft);
}
