/* =================================================================
   IFS — Design System
   Colors per product spec (PDF):
     · background gradient   #0f5b73 → #1581a3
     · cards / buttons bg    #093442
     · text on dark          white
     · forms & tables        dark text on white
   ================================================================= */

:root {
    --ifs-bg-start: #0f5b73;
    --ifs-bg-end:   #1581a3;
    --ifs-surface:  #093442;
    --ifs-surface-2: #0c4053;
    --ifs-surface-hover: #0e4b62;
    --ifs-accent:   #00b4d8;
    --ifs-accent-soft: rgba(0, 180, 216, 0.18);
    --ifs-border:   rgba(255, 255, 255, 0.12);
    --ifs-border-strong: rgba(255, 255, 255, 0.25);
    --ifs-text:     #ffffff;
    --ifs-text-dim: rgba(255, 255, 255, 0.72);
    --ifs-text-mute: rgba(255, 255, 255, 0.55);

    --ifs-danger:   #ef4444;
    --ifs-warn:     #f59e0b;
    --ifs-ok:       #22c55e;

    --ifs-radius-lg: 18px;
    --ifs-radius-md: 12px;
    --ifs-radius-sm: 8px;

    --ifs-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
    --ifs-shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.22);

    --ifs-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
                Roboto, Helvetica, Arial, sans-serif;
}

/* --------------------------------------------------- reset */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: var(--ifs-font);
    color: var(--ifs-text);
    background: linear-gradient(135deg,
        var(--ifs-bg-start) 0%, var(--ifs-bg-end) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.55;
}

a { color: var(--ifs-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5 { margin: 0 0 .6rem; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 .8rem; }

/* --------------------------------------------------- top bar */
.ifs-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .9rem 1.5rem;
    background: rgba(9, 52, 66, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--ifs-border);
}
.ifs-brand {
    display: flex; align-items: center; gap: .6rem;
    font-weight: 800; font-size: 1.1rem; letter-spacing: .5px;
}
.ifs-brand-logo {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--ifs-accent), #0077b6);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.ifs-nav {
    display: flex; align-items: center; gap: .25rem; margin-left: auto;
    flex-wrap: wrap;
}
.ifs-nav a {
    color: var(--ifs-text-dim);
    padding: .5rem .9rem;
    border-radius: var(--ifs-radius-sm);
    font-size: .92rem;
    font-weight: 500;
    display: inline-flex; align-items: center; gap: .4rem;
    transition: all .15s ease;
    text-decoration: none;
}
.ifs-nav a:hover { color: var(--ifs-text); background: rgba(255,255,255,.06); }
.ifs-nav a.active {
    color: var(--ifs-text);
    background: var(--ifs-accent-soft);
    border: 1px solid rgba(0, 180, 216, 0.35);
}
.ifs-user-chip {
    display: flex; align-items: center; gap: .6rem;
    padding: .4rem .8rem;
    border: 1px solid var(--ifs-border);
    border-radius: 30px;
    font-size: .85rem;
}
.ifs-user-chip .dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--ifs-ok);
}
.ifs-logout-btn {
    border: none; background: transparent;
    color: var(--ifs-text-dim);
    cursor: pointer; font-size: .85rem;
    padding: .4rem .7rem;
    border-radius: var(--ifs-radius-sm);
    transition: color .15s;
}
.ifs-logout-btn:hover { color: var(--ifs-text); background: rgba(255,255,255,.06); }

/* --------------------------------------------------- layout */
.ifs-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 6rem; /* 6rem bottom reserved for FAB */
}
.ifs-page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}
.ifs-page-title { display: flex; align-items: center; gap: .7rem; }
.ifs-page-title .icon {
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--ifs-surface); border: 1px solid var(--ifs-border);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}

/* --------------------------------------------------- cards */
.ifs-card {
    background: var(--ifs-surface);
    border: 1px solid var(--ifs-border);
    border-radius: var(--ifs-radius-lg);
    padding: 1.3rem;
    box-shadow: var(--ifs-shadow-sm);
}
.ifs-card.tight { padding: 1rem; }
.ifs-card h3 { margin: 0 0 .9rem; font-size: 1rem; color: var(--ifs-text); }

/* Grid helpers */
.ifs-grid { display: grid; gap: 1.1rem; }
.ifs-grid-2 { grid-template-columns: repeat(2, 1fr); }
.ifs-grid-3 { grid-template-columns: repeat(3, 1fr); }
.ifs-grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 960px) {
    .ifs-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .ifs-grid-3 { grid-template-columns: 1fr; }
    .ifs-grid-2 { grid-template-columns: 1fr; }
}

/* KPI metric cards */
.ifs-kpi {
    background: var(--ifs-surface);
    border: 1px solid var(--ifs-border);
    border-radius: var(--ifs-radius-md);
    padding: 1.1rem;
    position: relative;
    overflow: hidden;
}
.ifs-kpi::before {
    content: "";
    position: absolute; top: 0; left: 0; width: 4px; height: 100%;
    background: var(--ifs-accent);
}
.ifs-kpi .label {
    color: var(--ifs-text-dim);
    font-size: .82rem;
    text-transform: uppercase; letter-spacing: .5px;
    margin-bottom: .3rem;
}
.ifs-kpi .value {
    font-size: 1.55rem; font-weight: 700; line-height: 1.2;
}
.ifs-kpi .delta {
    color: var(--ifs-text-mute); font-size: .8rem; margin-top: .3rem;
}
.ifs-kpi.warn::before { background: var(--ifs-warn); }
.ifs-kpi.danger::before { background: var(--ifs-danger); }
.ifs-kpi.ok::before { background: var(--ifs-ok); }

/* --------------------------------------------------- buttons */
.btn {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .6rem 1.1rem;
    background: var(--ifs-surface);
    border: 1px solid var(--ifs-border-strong);
    border-radius: var(--ifs-radius-sm);
    color: var(--ifs-text);
    font-family: inherit; font-size: .92rem; font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
    text-decoration: none;
}
.btn:hover { background: var(--ifs-surface-hover); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary {
    background: linear-gradient(135deg, #0077b6, var(--ifs-accent));
    border-color: transparent;
    font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--ifs-danger); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { padding: .35rem .7rem; font-size: .82rem; }

/* --------------------------------------------------- forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block; font-size: .85rem; font-weight: 600;
    color: var(--ifs-text-dim); margin-bottom: .35rem;
}
.form-control {
    width: 100%;
    padding: .7rem .9rem;
    background: rgba(255, 255, 255, 0.95); /* dark text on white per spec */
    color: #0d1b2a;
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: var(--ifs-radius-sm);
    font-family: inherit; font-size: .95rem;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--ifs-accent);
    box-shadow: 0 0 0 3px rgba(0, 180, 216, .25);
}
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%230d1b2a' d='M5 7l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .7rem center;
    background-size: 1.15rem;
    padding-right: 2.2rem;
}

.form-row { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.form-row .form-group { flex: 1; margin-bottom: 0; min-width: 170px; }

/* Alerts / flash messages */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--ifs-radius-sm);
    border: 1px solid transparent;
    margin-bottom: 1rem;
    font-size: .92rem;
}
.alert.error   { background: rgba(239, 68, 68, .13); border-color: rgba(239, 68, 68, .4); }
.alert.warning { background: rgba(245, 158, 11, .13); border-color: rgba(245, 158, 11, .4); }
.alert.info    { background: rgba(0, 180, 216, .13); border-color: rgba(0, 180, 216, .4); }
.alert.success { background: rgba(34, 197, 94, .13); border-color: rgba(34, 197, 94, .4); }

/* --------------------------------------------------- tables */
.ifs-table-wrap {
    background: #ffffff;
    color: #0d1b2a;
    border-radius: var(--ifs-radius-md);
    overflow: hidden;
    box-shadow: var(--ifs-shadow-sm);
}
.ifs-table {
    width: 100%; border-collapse: collapse;
    font-size: .88rem;
}
.ifs-table thead th {
    background: #e9eef4;
    color: #1e293b;
    text-align: left;
    padding: .7rem .9rem;
    font-weight: 600;
    border-bottom: 1px solid #d5dde7;
    position: sticky; top: 0;
}
.ifs-table tbody td {
    padding: .6rem .9rem;
    border-bottom: 1px solid #eef2f7;
    color: #0d1b2a;
}
.ifs-table tbody tr:hover { background: #f5f8fc; }
.ifs-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ifs-table .pill {
    display: inline-block; padding: .15rem .55rem;
    border-radius: 999px; font-size: .75rem; font-weight: 600;
}
.ifs-table .pill.paid    { background: rgba(34,197,94,.15); color: #065f46; }
.ifs-table .pill.pending { background: rgba(245,158,11,.18); color: #7c2d12; }

.table-overflow { max-height: 480px; overflow: auto; }

/* Pagination */
.ifs-pager {
    display: flex; align-items: center; justify-content: space-between;
    padding: .7rem 1rem; background: #f5f8fc; color: #1e293b;
    border-top: 1px solid #d5dde7;
    font-size: .85rem;
}
.ifs-pager .btns { display: flex; gap: .4rem; }
.ifs-pager button {
    padding: .3rem .7rem; font-size: .82rem;
    border: 1px solid #cbd5e1; background: #fff; color: #1e293b;
    border-radius: 6px; cursor: pointer;
}
.ifs-pager button:disabled { opacity: .4; cursor: not-allowed; }

/* --------------------------------------------------- badges / tags */
.tag {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .2rem .6rem; border-radius: 999px;
    font-size: .78rem; font-weight: 600;
}
.tag.low    { background: rgba(34,197,94,.18); color: #d1fae5; }
.tag.medium { background: rgba(245,158,11,.22); color: #fef3c7; }
.tag.high   { background: rgba(239,68,68,.22); color: #fecaca; }

.progress {
    height: 8px; width: 100%;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px; overflow: hidden;
}
.progress > .bar {
    height: 100%; background: var(--ifs-accent); transition: width .5s ease;
}
.progress > .bar.warn { background: var(--ifs-warn); }
.progress > .bar.danger { background: var(--ifs-danger); }

/* --------------------------------------------------- loaders */
.spinner {
    display: inline-block; width: 1em; height: 1em;
    border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; animation: ifs-spin .7s linear infinite;
}
@keyframes ifs-spin { to { transform: rotate(360deg); } }
.skeleton {
    background: linear-gradient(90deg,
        rgba(255,255,255,.06), rgba(255,255,255,.14), rgba(255,255,255,.06));
    background-size: 200% 100%;
    animation: sk 1.2s infinite linear;
    border-radius: 8px;
}
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* --------------------------------------------------- misc */
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 200px; }

.muted { color: var(--ifs-text-mute); }
.dim   { color: var(--ifs-text-dim); }
.right { text-align: right; }
.mb-0 { margin-bottom: 0 !important; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.hidden { display: none !important; }
