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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --error: #dc2626;
    --success: #16a34a;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Nav --- */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    min-height: 56px;
    display: flex;
    align-items: center;
}
.nav-inner {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}
.nav-brand { font-weight: 700; color: var(--primary); text-decoration: none; font-size: 1.1rem; }
.nav-right { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: .9rem; }
.nav-link { color: var(--text-muted); text-decoration: none; transition: color .15s; }
.nav-link:hover { color: var(--primary); }
.lang-toggle a { color: var(--text-muted); text-decoration: none; transition: color .15s; }
.lang-toggle a.active { color: var(--primary); font-weight: 600; }

/* --- Admin sub-nav --- */
.subnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.subnav-inner {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    gap: 4px;
    padding: 0 24px;
}
.subnav a {
    display: inline-block;
    padding: 10px 14px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}
.subnav a:hover { color: var(--text); }
.subnav a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* --- Main --- */
.container {
    flex: 1;
    width: 100%;
    max-width: 960px;
    margin: 24px auto;
    padding: 0 24px;
}

/* --- Forms --- */
.form-wrapper {
    max-width: 400px;
    margin: 64px auto;
    background: var(--surface);
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.form-wrapper h1 { margin-bottom: 24px; font-size: 1.5rem; }
label { display: block; margin-bottom: 4px; font-weight: 600; font-size: .9rem; }
input[type="text"], input[type="password"], input[type="file"],
input[type="datetime-local"], textarea, select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    margin-bottom: 16px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,.2);
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: .95rem;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    font-weight: 500;
    transition: background-color .15s, box-shadow .15s, transform .05s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-submitting {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 12px; font-size: .85rem; }

/* --- Alerts --- */
.alert { padding: 10px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: .9rem; }
.alert-error { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

/* --- Cards / Dashboard --- */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 24px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.card h3 { color: var(--primary); margin-bottom: 4px; font-size: 1.1rem; }

/* --- Tables --- */
.table-scroll {
    overflow-x: auto;
    border-radius: var(--radius);
    -webkit-overflow-scrolling: touch;
}
table {
    width: 100%;
    min-width: 480px;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
th, td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}
th { background: #f1f5f9; font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: .8rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* --- Misc --- */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-1 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; }
.file-list { margin-top: 16px; }
.inline-form { display: inline; }
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: .8rem;
    font-weight: 500;
}
.tag-active { background: #dcfce7; color: #166534; }
.tag-expired { background: #fef3c7; color: #92400e; }
.tag-revoked { background: #fef2f2; color: #991b1b; }

/* --- Small screens --- */
@media (max-width: 640px) {
    .navbar, .subnav-inner { padding-left: 16px; padding-right: 16px; }
    .container { padding: 0 16px; margin: 16px auto; }
    .form-wrapper { margin: 24px auto; padding: 20px; }
    .page-header { flex-wrap: wrap; gap: 12px; }
}
