/* === Base / layout === */
:root
{
    --brand:   #1a4f8a;     /* navy blue */
    --brand-2: #2e6db4;
    --ink:     #111;
    --ink-2:   #333;
    --bg:      #fff;
    --muted:   #f5f5f7;

    --title:  24px;
    --text:   18px;
    --small:  15px;
    --pad:      12px;
    --gap:      14px;
    --radius:   10px;
    --pageLeft: 20px;
}

html, body
{
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Calibri, Arial, Helvetica, sans-serif;
    font-size: var(--text);
    line-height: 1.4;
}

.page  { padding: 0; }

.content { padding: 20px var(--pad) 80px var(--pageLeft); }

.page-title
{
    font-family: sans-serif;
    font-size: 26px;
    font-weight: bold;
    color: var(--brand);
    padding: 14px var(--pageLeft) 14px;
    position: sticky;
    top: 48px;
    background: var(--bg);
    z-index: 10;
}

/* === Page title + back link row === */
.page-title-row { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.page-title-row .page-title { padding-left: 0; padding-right: 0; position: static; }

/* === Auto-rendered title bar with optional back link (pagetop.php) === */
.page-title-bar { display: flex; align-items: flex-end;
                  padding: 14px var(--pad) 14px var(--pageLeft);
                  position: sticky; top: 48px; background: var(--bg); z-index: 10;
                  box-sizing: border-box; }
.page-title-bar .page-title { position: static; padding: 0; }
.page-title-bar .back-link  { margin-left: auto; }
.page-title-bar-right { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.page-title-bar-right .back-link { margin-left: 0; }
.back-link { font-family: sans-serif; font-size: 14px; color: #999; text-decoration: none;
             margin-left: auto; white-space: nowrap; padding-bottom: 2px; }
.back-link:hover { color: var(--brand); text-decoration: underline; }

/* === Navbar === */
.navbar
{
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 12px 0 0;
    min-height: 48px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.navbar-brand
{
    background: #fff;
    color: var(--brand);
    border: 1px solid var(--brand);
    padding: 0 20px 0 16px;
    font-weight: bold;
    font-size: 22px;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.navbar a
{
    color: #fff;
    text-decoration: none;
    padding: 6px 10px;
    font-size: 16px;
    display: flex;
    align-items: center;
    align-self: center;
}

.navbar a:hover { background: rgba(255,255,255,0.15); }

.navbar-user
{
    margin-left: auto;
    font-size: 16px;
    color: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
}

.navbar-user a
{
    color: rgba(255,255,255,0.85);
    text-decoration: none;
}

.navbar-user a:hover { text-decoration: underline; }

/* === Buttons === */
.btn
{
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn:hover         { background: var(--brand-2); }
.btn.gray          { background: #888; }
.btn.gray:hover    { background: #666; }
.btn.danger        { background: #c00; }
.btn.danger:hover  { background: #a00; }

.form-buttons { margin-top: 16px; }

/* === Tables === */
table { border-collapse: collapse; }
th, td { padding: 6px 12px; text-align: left; }
th { border-bottom: 2px solid #ccc; }

/* === Modal === */
.modal
{
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding-top: 60px;
    box-sizing: border-box;
}
.modal.open { display: flex; }
.modal-dialog { background: #fff; border-radius: 6px; padding: 24px 28px; max-width: 480px; width: 90%; }
.modal-header { margin-bottom: 12px; }
.modal-title  { margin: 0; font-size: 18px; }
.modal-footer { margin-top: 16px; text-align: right; }

/* === Admin link cards === */
.link-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 8px; }
.link-card { background: var(--bg); border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.12); padding: 18px 20px; text-decoration: none; color: inherit; display: flex; align-items: center; gap: 14px; transition: box-shadow 0.15s; font-family: sans-serif; }
.link-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.18); }
.link-icon { font-size: 28px; }
.link-card h3 { font-size: 16px; font-weight: bold; margin-bottom: 3px; color: var(--brand); }
.link-card p  { font-size: 13px; color: #888; }

/* === Module columns (admin col-heading + links pattern) === */
.module-cols { display: grid; grid-template-columns: repeat(auto-fill, 290px); gap: 24px; align-items: start; width: fit-content; }
.col-heading { font-family: sans-serif; font-size: 17px; font-weight: 700; color: var(--brand); border-bottom: 2px solid var(--brand); padding-bottom: 8px; margin-bottom: 12px; }
.module-links { list-style: none; margin: 0; padding: 0 4px; }
.module-links li { border-bottom: 1px solid #eee; }
.module-links li a { display: block; padding: 10px 12px; color: var(--brand-2); text-decoration: none; font-family: sans-serif; font-size: 15px; }
.module-links li a:hover { background: #f5f5f7; }

/* === Utilities === */
.right   { text-align: right; }
.bold    { font-weight: bold; }
.muted   { color: #888; font-style: italic; }
