* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --line-dark: #d1d5db;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;

    --secondary: #475569;
    --secondary-hover: #334155;

    --danger: #dc2626;
    --danger-hover: #b91c1c;

    --success: #16a34a;
    --success-hover: #15803d;

    --shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.18);
    --radius: 14px;
    --radius-sm: 10px;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.container {
    max-width: 1250px;
    margin: 0 auto;
    padding: 24px;
}

.page-center {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
}

.auth-card {
    width: 100%;
    max-width: 430px;
}

h1,
h2,
h3 {
    margin-top: 0;
    color: #111827;
}

p {
    margin-top: 0;
}

.muted,
.small-meta {
    color: var(--muted);
}

.small-meta {
    font-size: 13px;
}

.stack > * + * {
    margin-top: 14px;
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    color: #111827;
}

input,
select,
textarea,
button {
    width: 100%;
    font: inherit;
}

input,
select,
textarea {
    padding: 11px 12px;
    border: 1px solid var(--line-dark);
    border-radius: var(--radius-sm);
    background: #fff;
    color: #111827;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

textarea {
    resize: vertical;
    min-height: 110px;
}

input::placeholder,
textarea::placeholder {
    color: #9ca3af;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button,
.button-link {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 11px 14px;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

button:hover,
.button-link:hover {
    background: var(--primary-hover);
}

button:active,
.button-link:active {
    transform: translateY(1px);
}

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.secondary-btn,
.button-link.secondary {
    background: var(--secondary);
}

.secondary-btn:hover,
.button-link.secondary:hover {
    background: var(--secondary-hover);
}

.danger-btn {
    background: var(--danger);
}

.danger-btn:hover {
    background: var(--danger-hover);
}

.danger-outline {
    background: #fff;
    color: var(--danger);
    border: 1px solid #fca5a5;
    max-width: 150px;
}

.danger-outline:hover {
    background: #fef2f2;
}

/* Topbar basic */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    gap: 12px;
}

.topbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* App topbar */
.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.app-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-logo {
    text-decoration: none;
    color: #111827;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

.app-topbar-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.app-topbar-nav a {
    text-decoration: none;
    color: #475569;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 10px;
    transition: 0.2s ease;
}

.app-topbar-nav a:hover {
    background: #eff6ff;
    color: var(--primary);
}

.app-topbar-nav a.active {
    background: var(--primary);
    color: #fff;
}

.app-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.app-user-email {
    font-size: 14px;
    color: var(--muted);
    word-break: break-word;
}

.app-logout-btn {
    width: auto;
    min-width: 100px;
    padding: 10px 14px;
}

/* Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}

.grid-main {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 22px;
    align-items: start;
}

.compact-gap {
    gap: 12px;
}

.demo-box {
    margin-top: 18px;
    padding: 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    line-height: 1.6;
}

.feature-list {
    margin: 0;
    padding-left: 20px;
    line-height: 1.9;
}

.row-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.row-actions button {
    width: auto;
    min-width: 130px;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 14px;
    flex-wrap: wrap;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filters input,
.filters select,
.filters button {
    width: auto;
}

.table-wrapper {
    overflow-x: auto;
    margin-top: 18px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    background: #f8fafc;
    color: #111827;
    font-weight: 700;
}

td {
    color: #334155;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.badge.processing {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge.posted {
    background: #dcfce7;
    color: #166534;
}

.badge.failed {
    background: #fee2e2;
    color: #991b1b;
}

/* Old action buttons */
.action-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-group button {
    width: auto;
    padding: 8px 10px;
    border-radius: 8px;
}

/* New page action UI */
.action-icons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 138px;
}

.action-pill {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    padding: 10px 12px;
    border-radius: 12px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    user-select: none;
    line-height: 1.2;
}

.action-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
}

.action-pill.delete-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.action-pill.delete-btn:hover {
    box-shadow: 0 6px 14px rgba(220, 38, 38, 0.35);
}

/* Pagination */
.pagination {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
    align-items: center;
}

.pagination button {
    width: auto;
    min-width: 42px;
    padding: 8px 12px;
    border-radius: 8px;
    background: #fff;
    color: #111827;
    border: 1px solid var(--line-dark);
}

.pagination button:hover {
    background: #f8fafc;
}

.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Notification container */
#notification-container,
.sticky-notices {
    position: fixed;
    top: 16px;
    right: 16px;
    width: min(380px, calc(100% - 24px));
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

/* Supports both .toast and .notice */
.toast,
.notice {
    padding: 14px 16px;
    border-radius: 12px;
    color: #fff;
    box-shadow: var(--shadow-soft);
    animation: slideIn 0.25s ease;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
    pointer-events: auto;
    word-break: break-word;
}

/* Supports both naming styles */
.toast.success,
.notice.success,
.notice-success {
    background: #15803d;
}

.toast.error,
.notice.error,
.notice-error {
    background: #b91c1c;
}

.toast.info,
.notice.info,
.notice-info {
    background: #1d4ed8;
}

@keyframes slideIn {
    from {
        transform: translateX(12px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.empty-state {
    padding: 18px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    margin-top: 16px;
}

/* Utility */
.text-center {
    text-align: center;
}

.w-auto {
    width: auto;
}

code {
    background: #f3f4f6;
    color: #111827;
    padding: 4px 7px;
    border-radius: 6px;
    font-size: 12px;
    word-break: break-all;
}

/* Responsive */
@media (max-width: 980px) {
    .grid-main,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .grid-main {
        gap: 18px;
    }
}

@media (max-width: 900px) {
    .app-topbar {
        align-items: flex-start;
    }

    .app-topbar-left,
    .app-topbar-nav,
    .app-topbar-right {
        width: 100%;
    }

    .app-topbar-nav {
        order: 3;
    }

    .app-topbar-right {
        justify-content: space-between;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 14px;
    }

    .filters input,
    .filters select,
    .filters button,
    .danger-outline {
        width: 100%;
        max-width: none;
    }

    .app-topbar-nav a {
        width: 100%;
        text-align: center;
    }

    .app-topbar-right {
        flex-direction: column;
        align-items: stretch;
    }

    .app-logout-btn {
        width: 100%;
    }

    .row-actions button {
        width: 100%;
    }

    .action-icons {
        min-width: 120px;
    }
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.table-action {
    width: auto;
    min-width: 74px;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.table-action:hover {
    transform: translateY(-1px);
}

.table-action.edit-btn {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.table-action.edit-btn:hover {
    background: #dbeafe;
}

.table-action.delete-btn {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.table-action.delete-btn:hover {
    background: #fee2e2;
}

.notification{
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    min-width: 260px;
    max-width: 360px;
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,.15);
}
.notification.success{
    background: #16a34a;
}
.notification.error{
    background: #dc2626;
}