:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-hover: #fafbfc;
    --text: #181c28;
    --text-secondary: #68708c;
    --text-muted: #949bb5;
    --border: #e8ecf2;
    --border-strong: #d2d8e3;
    --primary: #5b5bd6;
    --primary-dark: #4a4ac4;
    --primary-light: #f0efff;
    --primary-ring: #c4c2f7;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --shadow-xs: 0 1px 2px rgba(24, 28, 40, 0.04);
    --shadow-sm: 0 1px 3px rgba(24, 28, 40, 0.06), 0 1px 2px rgba(24, 28, 40, 0.04);
    --shadow: 0 4px 12px rgba(24, 28, 40, 0.06), 0 2px 4px rgba(24, 28, 40, 0.04);
    --shadow-lg: 0 12px 32px rgba(24, 28, 40, 0.08), 0 4px 8px rgba(24, 28, 40, 0.04);
    --font-display: 'Outfit', sans-serif;
    --font-body: 'Outfit', sans-serif;
    --font-mono: 'Outfit', sans-serif;
}

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

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-dark);
}

/* ── Header ── */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.85);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.header-nav {
    display: flex;
    gap: 0.25rem;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 3px;
}

.nav-link {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.nav-link.active {
    color: #fff;
    background: var(--primary);
    box-shadow: var(--shadow-xs);
}

/* ── Main ── */
.main-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2.5rem 2rem 5rem;
}

@media (max-width: 768px) {
    .main-content {
        padding: 1.5rem 1rem 3rem;
    }
}

/* ── Typography ── */
h1, h2, h3, h4 {
    font-family: var(--font-display);
    margin: 0;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.section-label {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.page-description {
    color: var(--text-secondary);
    margin: 0.35rem 0 0;
    font-size: 0.95rem;
}

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    padding: 1.5rem;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow);
    border-color: var(--border-strong);
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1.25rem 1.5rem;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card.pulse-primary::before { background: var(--primary); }
.stat-card.pulse-success::before { background: var(--success); }
.stat-card.pulse-warning::before { background: var(--warning); }
.stat-card.pulse-danger::before { background: var(--danger); }
.stat-card.pulse-muted::before { background: var(--text-muted); }

.stat-value {
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
    letter-spacing: -0.02em;
}

.stat-label {
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* ── Dashboard Layout ── */
.dashboard-header {
    margin-bottom: 2rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.dashboard-grid > section {
    min-width: 0;
    overflow: hidden;
}

.dashboard-grid .wide {
    grid-column: 1 / -1;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Item Lists ── */
.item-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.item-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.item-row:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.item-row.status-warning {
    background: var(--warning-light);
    border-color: #fcd34d;
    border-left: 3px solid var(--warning);
}

.item-row.status-danger {
    background: var(--danger-light);
    border-color: #fecaca;
    border-left: 3px solid var(--danger);
}

.item-row.status-success {
    background: var(--success-light);
    border-color: #a7f3d0;
    border-left: 3px solid var(--success);
}

.item-main {
    min-width: 0;
    width: 100%;
}

.item-client {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.item-service {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
}

.item-meta {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

.item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    line-height: 1.4;
}

.badge-active {
    background: #d1fae5;
    color: #065f46;
}

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

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

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

.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.badge-pill::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ── Buttons ── */
button,
.btn {
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.4;
    white-space: nowrap;
}

button:hover,
.btn:hover {
    background: var(--bg);
    border-color: var(--text-muted);
}

button:active,
.btn:active {
    transform: scale(0.98);
}

.btn-primary,
.btn-primary:visited,
.btn-primary:link {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.4;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(91, 91, 214, 0.25);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(91, 91, 214, 0.35);
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
    box-shadow: 0 1px 2px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
}

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: var(--primary);
}

.btn-small {
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.inline-form {
    display: inline;
}

/* ── Empty State ── */
.empty-state {
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-muted);
    background: var(--surface);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    font-size: 0.92rem;
}

.empty-state-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

/* ── Tables ── */
.table-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    box-shadow: var(--shadow-xs);
}

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

th, td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    white-space: nowrap;
}

th {
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--bg);
    color: var(--text-muted);
    position: sticky;
    top: 0;
}

/* Allow service name and client name to wrap */
th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
    white-space: normal;
    min-width: 140px;
    max-width: 260px;
}

td .badge {
    margin-right: 0.25rem;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: background 0.1s ease;
}

tbody tr:hover {
    background: var(--surface-hover);
}

td.actions-col {
    text-align: right;
    white-space: nowrap;
    padding-right: 1.25rem;
}

td.actions-col a,
td.actions-col form {
    display: inline-block;
    vertical-align: middle;
}

td.actions-col a + form {
    margin-left: 0.4rem;
}

/* ── Page Header ── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
}

.page-header-actions {
    display: flex;
    gap: 0.6rem;
    flex-shrink: 0;
}

/* ── Forms ── */
.form-card {
    max-width: 600px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.35rem;
}

.form-group:last-of-type {
    margin-bottom: 1.75rem;
}

.form-group label {
    display: block;
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    font-family: var(--font-body);
    font-size: 0.92rem;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="email"]:focus,
.form-group input[type="number"]:focus,
.form-group input[type="date"]:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group select {
    cursor: pointer;
}

.form-group.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.form-group.checkbox-group input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-group.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 0.6rem;
    padding-top: 0.25rem;
}

.form-error {
    background: var(--danger-light);
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    color: #991b1b;
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

/* ── Client Cards Grid ── */
.client-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.client-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    padding: 1.15rem 1.35rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.client-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.client-card-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.client-card-info {
    flex: 1;
    margin: 0 0.85rem;
    min-width: 0;
}

.client-card-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    word-break: break-word;
}

.client-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.client-card-arrow {
    color: var(--text-muted);
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: transform 0.15s ease, color 0.15s ease;
}

.client-card:hover .client-card-arrow {
    transform: translateX(2px);
    color: var(--primary);
}

.link-external {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.link-external::after {
    content: '\2197';
    font-size: 0.7rem;
}

.link-external:hover {
    text-decoration: underline;
}

/* ── Detail Page ── */
.client-detail-header {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.client-avatar-large {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.client-detail-info h1 {
    margin-bottom: 0.25rem;
}

.client-detail-info p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.9rem;
}

/* ── Section Wrapper ── */
.section {
    margin-bottom: 2.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

/* ── Footer ── */
.site-footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    font-family: var(--font-display);
}

/* ── Import Toast ── */
.flash-message {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flash-success {
    background: var(--success-light);
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.flash-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* ── Utility ── */
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-right { text-align: right; }
.flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.min-w-0 { min-width: 0; }

/* ── Search Bar ── */
.search-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-bar input[type="text"] {
    flex: 1;
    min-width: 200px;
    font-family: var(--font-body);
    font-size: 0.92rem;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-bar input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

@media (max-width: 480px) {
    .search-bar {
        flex-wrap: wrap;
    }
    .search-bar input[type="text"] {
        width: 100%;
    }
    .item-actions {
        flex-wrap: wrap;
        gap: 0.35rem;
    }
    .item-actions .btn-small,
    .item-actions button {
        padding: 0.3rem 0.55rem;
        font-size: 0.74rem;
    }
}
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.pagination-info {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.loading-shimmer {
    animation: shimmer 1.5s ease-in-out infinite;
    background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%);
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
