:root {
    --primary: #075f9d;
    --primary-dark: #034978;
    --accent: #0b78c4;
    --surface: #ffffff;
    --background: #f2f5f8;
    --border: #d7e0e7;
    --text: #17202a;
    --muted: #667786;
    --success: #157347;
    --danger: #b42318;
    --warning: #8a5a00;
    --radius: 10px;
    --shadow: 0 8px 24px rgba(23, 32, 42, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: "Noto Sans Bengali", "SolaimanLipi", "Kalpurush", Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    display: flex;
    align-items: center;
    min-height: 64px;
    padding: 0 4vw;
    box-shadow: 0 4px 18px rgba(0,0,0,.12);
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand { font-weight: 700; font-size: 1.15rem; margin-right: auto; }
.brand a { color: #fff; text-decoration: none; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: #fff; padding: 10px 11px; border-radius: 7px; font-size: .95rem; }
.nav a:hover { background: rgba(255,255,255,.13); text-decoration: none; }
.logout-link { border-left: 1px solid rgba(255,255,255,.22); margin-left: 7px; }
.menu-toggle { display: none; background: transparent; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; }

.container { width: min(1180px, 92vw); margin: 30px auto 50px; }
.auth-container { width: min(520px, 92vw); min-height: calc(100vh - 90px); display: grid; place-items: center; }
.site-footer { text-align: center; color: var(--muted); padding: 18px; font-size: .9rem; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.page-header h1 { margin: 0 0 4px; font-size: 1.65rem; }
.page-header p { margin: 0; color: var(--muted); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}
.card h2, .card h3 { margin-top: 0; }
.card-muted { background: #f9fbfc; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat { padding: 20px; border-left: 4px solid var(--accent); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary-dark); }
.stat-label { color: var(--muted); }

.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
label { display: block; font-weight: 650; margin-bottom: 7px; }
.help { color: var(--muted); font-size: .88rem; margin-top: 6px; }
.required { color: var(--danger); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="color"], select, textarea {
    width: 100%;
    border: 1px solid #bfcbd5;
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
    color: var(--text);
}
textarea { min-height: 180px; resize: vertical; }
.richtext-wrapper {
    border: 1px solid #8b9aa8;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(23,32,42,.06);
}
.richtext-wrapper:focus-within { outline: 3px solid rgba(11,120,196,.13); border-color: var(--accent); }
.richtext-toolbar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 8px 10px;
    background: #eef3f6;
    border-bottom: 1px solid #8b9aa8;
}
.richtext-toolbar button {
    border: 1px solid #bfcbd5;
    background: #fff;
    border-radius: 6px;
    padding: 6px 12px;
    font: inherit;
    cursor: pointer;
    color: var(--text);
}
.richtext-toolbar button:hover { background: #e2e9ee; }
.richtext-editor {
    min-height: 380px;
    padding: 14px 16px;
    background: #fff;
    line-height: 1.55;
}
.richtext-editor p, .richtext-editor div { margin: 0 0 10px; }
.richtext-editor ul, .richtext-editor ol { margin: 0 0 10px 22px; padding: 0; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(11,120,196,.13); border-color: var(--accent); }
input[type="file"] { width: 100%; padding: 9px; border: 1px dashed #aebbc5; border-radius: 8px; background: #fafcfd; }
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; }
.radio-option { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 16px;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
    transition: .16s ease;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef3f6; color: var(--text); border-color: var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: #fff1f0; color: var(--danger); border-color: #f3c7c2; }
.btn-small { padding: 7px 10px; font-size: .88rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f5f8fa; color: #3c4b57; font-size: .92rem; }
tr:hover td { background: #fbfdfe; }

.alert { padding: 12px 15px; border-radius: 8px; margin-bottom: 18px; border: 1px solid; transition: opacity .4s; }
.alert.fade { opacity: .35; }
.alert-success { background: #edf8f2; border-color: #abd9c2; color: #0e5e39; }
.alert-danger { background: #fff1f0; border-color: #efc0bc; color: #8e1f16; }
.alert-warning { background: #fff8e5; border-color: #ead49c; color: #6e4b00; }
.alert-info { background: #eef7fd; border-color: #badbf0; color: #07557f; }

.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge-green { background: #e8f6ee; color: #12643d; }
.badge-gray { background: #edf0f2; color: #52616d; }
.badge-blue { background: #e9f4fb; color: #075f9d; }

.preview-image { width: 100%; max-height: 180px; object-fit: contain; background: #f7f7f7; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.signature-preview { max-width: 240px; max-height: 100px; object-fit: contain; border: 1px solid var(--border); background: #fff; padding: 5px; border-radius: 6px; }

.auth-card { width: 100%; }
.auth-title { text-align: center; margin-bottom: 20px; }
.auth-title h1 { margin-bottom: 5px; }
.auth-title p { color: var(--muted); margin-top: 0; }

.pdf-frame { width: 100%; height: 720px; border: 1px solid var(--border); border-radius: 8px; background: #eee; }
.image-gallery { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.image-gallery img { width: 100%; border: 1px solid var(--border); box-shadow: var(--shadow); background: #fff; }

.split-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; }
.sign-box { min-height: 160px; border: 1px dashed #b9c6d0; border-radius: 8px; padding: 14px; }
.sign-box.right { text-align: right; }

.filter-bar { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

@media (max-width: 900px) {
    .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .filter-bar { grid-template-columns: 1fr 1fr; }
    .menu-toggle { display: block; }
    .nav { display: none; position: absolute; left: 0; right: 0; top: 64px; background: var(--primary-dark); flex-direction: column; align-items: stretch; padding: 12px 4vw; }
    .nav-open .nav { display: flex; }
    .logout-link { border-left: 0; margin-left: 0; }
}

@media (max-width: 650px) {
    .grid-4, .grid-3, .grid-2, .form-row, .split-preview, .image-gallery { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
    .filter-bar { grid-template-columns: 1fr; }
    .container { width: 94vw; margin-top: 18px; }
    .card { padding: 17px; }
}
