/* ---- Itm palette (from plan) ----
   menu / primary: #66b032   secondary: #a6d608
   text: #555555   background: #ffffff
*/
:root {
    --itm-primary: #66b032;
    --itm-secondary: #a6d608;
    --itm-text: #555555;
    --itm-bg: #ffffff;
    --itm-menu: #66b032;
    --itm-border: #e3e8df;
    --itm-topbar-h: 56px;
    --itm-actionbar-h: 60px;   /* reserved zone below the navbar for per-page action bars */
    --itm-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    color: var(--itm-text);
    background: var(--itm-bg);
    font-family: var(--itm-font);
    font-size: 15px;
    line-height: 1.5;
}

.itm-shell { min-height: 100vh; }

/* ---- Fixed top bar ---- */
.itm-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--itm-topbar-h);
    background: var(--itm-menu);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 18px;
    z-index: 1000;
    box-shadow: 0 1px 4px rgba(0,0,0,.15);
}

.itm-brand { display: flex; align-items: center; gap: 9px; color: #fff; font-weight: 700; letter-spacing: .4px; }
.itm-mark { width: 18px; height: 18px; border-radius: 4px; background: var(--itm-secondary); display: inline-block; }
.itm-brand-name { font-size: 18px; }

.itm-nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.itm-spacer { flex: 1; }

.itm-link {
    color: #eaf6df;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
}
.itm-link:hover { background: rgba(255,255,255,.15); color: #fff; }
.itm-link.active { background: var(--itm-secondary); color: #2c3d12; }

.itm-user { color: #eaf6df; font-size: 13px; padding: 0 6px; }
.itm-logout { margin: 0; }
.itm-logout-btn { color: #eaf6df; }

/* ---- Nav dropdowns ---- */
.itm-nav-group { position: relative; }
.itm-nav-trigger {
    display: flex; align-items: center; gap: 5px;
    color: #eaf6df; text-decoration: none;
    padding: 8px 12px; border-radius: 6px;
    font-weight: 500; background: none; border: none;
    cursor: pointer; font: inherit;
    white-space: nowrap;
}
.itm-nav-trigger:hover { background: rgba(255,255,255,.15); color: #fff; }
.itm-nav-trigger.open { background: rgba(255,255,255,.15); color: #fff; }
.itm-dropdown {
    display: none; position: absolute; top: calc(100% + 4px); left: 0;
    min-width: 160px; background: #4a8424; border-radius: 8px;
    padding: 4px 0; box-shadow: 0 6px 16px rgba(0,0,0,.22); z-index: 200;
}
.itm-dropdown.open { display: block; }
.itm-dropdown .itm-link { display: block; padding: 10px 16px; border-radius: 0; }
.itm-dropdown .itm-link:first-child { border-radius: 8px 8px 0 0; }
.itm-dropdown .itm-link:last-child  { border-radius: 0 0 8px 8px; }
.itm-dropdown-empty { padding: 10px 16px; color: #c5e09b; font-size: 13px; }

/* ---- Icon-only buttons ---- */
.btn.icon-btn { padding: 5px 8px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn.icon-btn i { font-size: 15px; }

/* ---- Hamburger (mobile) ---- */
.itm-hamburger {
    display: none;
    margin-left: auto;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}
.itm-hamburger span { width: 22px; height: 2px; background: #fff; display: block; }

/* ---- Content: starts below BOTH the top bar and the reserved action-bar zone ---- */
.itm-content {
    margin-top: calc(var(--itm-topbar-h) + var(--itm-actionbar-h));
    width: 100%;
    padding: 24px clamp(16px, 4vw, 48px);
}

/* ---- Fixed per-page action bar (Save / Back / etc.) ---- */
/* Fills the 60 px zone between the nav bar and the page content.
   Pages that don't need one leave the zone intentionally blank. */
.itm-page-actions {
    position: fixed;
    top: var(--itm-topbar-h);
    left: 0;
    right: 0;
    height: var(--itm-actionbar-h);
    z-index: 100;
    background: #fff;
    padding: 0 clamp(16px, 4vw, 48px);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---- Reusable bits ---- */
h1 { font-size: 1.5rem; color: #3f3f3f; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; color: #3f3f3f; }
a { color: var(--itm-primary); }

.btn {
    background: var(--itm-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.btn:hover { background: #58991f; }
.btn.secondary { background: var(--itm-secondary); color: #2c3d12; }
.btn.danger { background: none; color: #c0392b; border: 1px solid var(--itm-border); margin-left: 6px; }
.btn.danger:hover { background: #fce8e6; }
.btn.ghost { background: none; color: var(--itm-primary); border: 1px solid var(--itm-border); }

.itm-table { width: 100%; border-collapse: collapse; background: #fff; }
.itm-table th, .itm-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--itm-border); }
.itm-table th { color: #6f7d63; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

.card { border: 1px solid var(--itm-border); border-radius: 10px; padding: 20px; background: #fff; max-width: 720px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; color: #5a5a5a; }
.field input, .field select, .field textarea {
    padding: 8px 10px; border: 1px solid var(--itm-border); border-radius: 6px; font: inherit;
}
textarea.code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; min-height: 360px; width: 100%; }

.itm-filter { width: 100%; padding: 8px 10px; border: 1px solid var(--itm-border); border-radius: 6px; font: inherit; }

/* ---- Preview modal ---- */
.itm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}
.itm-modal {
    background: #fff;
    border-radius: 12px;
    width: min(92vw, 1060px);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,.32);
    overflow: hidden;
}
.itm-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8fbf5;
    border-bottom: 1px solid var(--itm-border);
    flex-shrink: 0;
}
.itm-modal-title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    color: #3f3f3f;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.itm-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 17px;
    line-height: 1;
    flex-shrink: 0;
}
.itm-modal-close:hover { background: var(--itm-border); color: #333; }
.itm-modal-body {
    overflow: auto;
    padding: 20px 24px;
    flex: 1;
}
.itm-modal-body iframe {
    width: 100%;
    height: calc(88vh - 56px);
    border: none;
    display: block;
}
.itm-modal-body img { max-width: 100%; display: block; margin: auto; }

.notice { padding: 16px; background: #fff7e6; border: 1px solid #f0d98c; border-radius: 8px; }
.error { color: #c0392b; font-size: 13px; }
.muted { color: #8a8a8a; font-size: 13px; }
pre.viewer { background: #f6f8f4; border: 1px solid var(--itm-border); border-radius: 8px; padding: 16px; overflow: auto; }
.markdown-body { line-height: 1.6; }
.markdown-body img { max-width: 100%; }

@media (max-width: 760px) {
    .itm-hamburger { display: flex; }
    .itm-nav {
        position: fixed;
        top: var(--itm-topbar-h); left: 0; right: 0;
        background: var(--itm-menu);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 8px;
        display: none;
        box-shadow: 0 6px 12px rgba(0,0,0,.18);
    }
    .itm-nav.open { display: flex; }
    .itm-spacer { display: none; }
    .itm-link { padding: 12px; }
    .itm-nav-group { width: 100%; }
    .itm-nav-trigger { width: 100%; padding: 12px; }
    .itm-dropdown { position: static; box-shadow: none; background: rgba(0,0,0,.12); border-radius: 6px; margin: 2px 8px; }
    .itm-dropdown .itm-link { padding: 10px 20px; }
}
