/* ==================================================================
   Royal CRM - Design system
   Palette: deep navy + teal.  Type: Archivo (display), IBM Plex Sans (text)
   ================================================================== */

:root {
    /* Navy */
    --navy-900: #071A2F;
    --navy-800: #0C2340;
    --navy-700: #113052;
    --navy-600: #16375C;
    --navy-500: #24507F;

    /* Teal */
    --teal-600: #0B7C7B;
    --teal-500: #0E9594;
    --teal-400: #17B3AE;
    --teal-300: #5FCDC7;
    --teal-100: #C9EBE8;
    --teal-050: #E9F6F5;

    /* Neutrals */
    --ink: #16232F;
    --ink-soft: #3B4E60;
    --muted: #6A7C8D;
    --line: #DCE4EC;
    --line-soft: #EAF0F5;
    --surface: #F2F5F8;
    --card: #FFFFFF;

    /* Status */
    --amber: #C87D14;
    --amber-bg: #FDF3E2;
    --rose: #B93B36;
    --rose-bg: #FBECEB;
    --green: #17795E;
    --green-bg: #E5F4EF;
    --violet: #5A4B9E;
    --violet-bg: #EFEDF9;

    /* Type */
    --font-display: 'Archivo', 'Segoe UI', Helvetica, Arial, sans-serif;
    --font-body: 'IBM Plex Sans', 'Segoe UI', Helvetica, Arial, sans-serif;

    /* Shape */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-raise: 0 10px 30px -14px rgba(7, 26, 47, .35);
    --shadow-card: 0 1px 2px rgba(7, 26, 47, .05);

    /* Rhythm */
    --gutter: clamp(1.25rem, 4vw, 3rem);
    --section-y: clamp(3.5rem, 7vw, 6.5rem);
}

/* ------------------------------------------------------------------ */
/* Base                                                                */
/* ------------------------------------------------------------------ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.65;
    color: var(--ink);
    background: var(--surface);
    font-feature-settings: 'tnum' 0;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .display {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.022em;
    line-height: 1.14;
    color: var(--navy-800);
    margin: 0 0 .6rem;
}

h1 { font-size: clamp(2.1rem, 4.6vw, 3.5rem); }
h2 { font-size: clamp(1.65rem, 3.2vw, 2.4rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); }
h4 { font-size: 1.1rem; }

p { margin: 0 0 1rem; }

a {
    color: var(--teal-600);
    text-decoration: none;
    transition: color .15s ease;
}

a:hover { color: var(--teal-500); }

.lead {
    font-size: clamp(1.02rem, 1.5vw, 1.16rem);
    color: var(--ink-soft);
    line-height: 1.7;
    max-width: 62ch;
}

.text-muted-2 { color: var(--muted); }
.measure { max-width: 66ch; }
.num { font-variant-numeric: tabular-nums; }

/* Keyboard focus stays visible everywhere. */
:focus-visible {
    outline: 3px solid var(--teal-400);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ------------------------------------------------------------------ */
/* Layout                                                              */
/* ------------------------------------------------------------------ */
.shell {
    width: 100%;
    max-width: 1220px;
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.section { padding-block: var(--section-y); }
.section-tight { padding-block: clamp(2.25rem, 4vw, 3.5rem); }

.section-head { margin-bottom: clamp(1.75rem, 3vw, 2.75rem); }
.section-head p { margin-bottom: 0; }

.stack-sm > * + * { margin-top: .5rem; }
.stack > * + * { margin-top: 1rem; }

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */
.btn {
    --btn-bg: var(--teal-500);
    --btn-fg: #fff;
    --btn-border: var(--teal-500);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    font-family: var(--font-body);
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.2;
    padding: .78rem 1.4rem;
    border-radius: var(--radius);
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: var(--btn-fg);
    cursor: pointer;
    transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
    text-align: center;
    white-space: nowrap;
}

.btn:hover {
    color: var(--btn-fg);
    transform: translateY(-1px);
}

.btn:active { transform: translateY(0); }

.btn:disabled,
.btn.is-loading {
    opacity: .6;
    pointer-events: none;
}

.btn-primary { --btn-bg: var(--teal-500); --btn-border: var(--teal-500); }
.btn-primary:hover { --btn-bg: var(--teal-600); --btn-border: var(--teal-600); }

.btn-navy { --btn-bg: var(--navy-800); --btn-border: var(--navy-800); }
.btn-navy:hover { --btn-bg: var(--navy-700); --btn-border: var(--navy-700); }

.btn-outline {
    --btn-bg: transparent;
    --btn-fg: var(--navy-800);
    --btn-border: var(--line);
}
.btn-outline:hover {
    --btn-bg: var(--teal-050);
    --btn-fg: var(--teal-600);
    --btn-border: var(--teal-300);
}

.btn-ghost-light {
    --btn-bg: rgba(255, 255, 255, .08);
    --btn-fg: #fff;
    --btn-border: rgba(255, 255, 255, .38);
    backdrop-filter: blur(4px);
}
.btn-ghost-light:hover { --btn-bg: rgba(255, 255, 255, .18); }

.btn-danger { --btn-bg: var(--rose); --btn-border: var(--rose); }
.btn-danger:hover { --btn-bg: #9E312D; --btn-border: #9E312D; }

.btn-sm { padding: .48rem .9rem; font-size: .855rem; border-radius: var(--radius-sm); }
.btn-lg { padding: .95rem 1.85rem; font-size: 1.02rem; }
.btn-block { width: 100%; }

.btn-link-quiet {
    background: none;
    border: 0;
    padding: 0;
    color: var(--muted);
    font-size: .875rem;
    cursor: pointer;
}
.btn-link-quiet:hover { color: var(--teal-600); }

/* ------------------------------------------------------------------ */
/* Cards                                                               */
/* ------------------------------------------------------------------ */
.card-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.card-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.1rem 1.35rem;
    border-bottom: 1px solid var(--line-soft);
}

.card-panel-head h3,
.card-panel-head h2 {
    margin: 0;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.card-panel-body { padding: 1.35rem; }
.card-panel-body.tight { padding: .5rem; }

/* Feature card used across the public site. */
.tile {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.65rem 1.5rem;
    height: 100%;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.tile:hover {
    border-color: var(--teal-300);
    box-shadow: var(--shadow-raise);
}

.tile h3 { font-size: 1.12rem; margin-bottom: .4rem; }
.tile p { color: var(--ink-soft); font-size: .95rem; margin-bottom: 0; }

.tile-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--teal-050);
    color: var(--teal-600);
    font-size: 1.35rem;
    margin-bottom: 1rem;
}

/* ------------------------------------------------------------------ */
/* Forms                                                               */
/* ------------------------------------------------------------------ */
.field { margin-bottom: 1.05rem; }

.field label,
.form-label {
    display: block;
    font-size: .86rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: .38rem;
}

.field .req { color: var(--rose); margin-left: 2px; }

.input,
.form-control,
.form-select,
select.input,
textarea.input {
    width: 100%;
    font-family: var(--font-body);
    font-size: .96rem;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .68rem .85rem;
    transition: border-color .15s ease, box-shadow .15s ease;
    appearance: none;
}

textarea.input { min-height: 110px; resize: vertical; }

.input:focus,
.form-control:focus,
.form-select:focus {
    border-color: var(--teal-400);
    box-shadow: 0 0 0 3px rgba(23, 179, 174, .18);
    outline: none;
}

.input::placeholder { color: #9AA9B7; }

select.input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236A7C8D' d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .9rem center;
    padding-right: 2.4rem;
}

.input.is-invalid,
.form-control.is-invalid { border-color: var(--rose); }

.field-error {
    display: block;
    font-size: .82rem;
    color: var(--rose);
    margin-top: .32rem;
}

.field-hint {
    display: block;
    font-size: .82rem;
    color: var(--muted);
    margin-top: .32rem;
}

.input-with-icon { position: relative; }
.input-with-icon .input { padding-left: 2.6rem; }
.input-with-icon > i {
    position: absolute;
    left: .95rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 1rem;
    pointer-events: none;
}

.password-toggle {
    position: absolute;
    right: .5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 0;
    color: var(--muted);
    padding: .35rem .5rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
}
.password-toggle:hover { color: var(--teal-600); }

/* ------------------------------------------------------------------ */
/* Status badges                                                       */
/* ------------------------------------------------------------------ */
.status {
    display: inline-flex;
    align-items: center;
    gap: .38rem;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1;
    padding: .38rem .68rem;
    border-radius: 100px;
    white-space: nowrap;
}

.status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-new       { background: #EDF2F8; color: var(--navy-500); }
.status-query     { background: var(--amber-bg); color: var(--amber); }
.status-process   { background: var(--violet-bg); color: var(--violet); }
.status-approved  { background: var(--green-bg); color: var(--green); }
.status-rejected  { background: var(--rose-bg); color: var(--rose); }
.status-disbursed { background: var(--teal-050); color: var(--teal-600); }
.status-cancelled { background: #EFF2F5; color: var(--muted); }

/* ------------------------------------------------------------------ */
/* Alerts                                                              */
/* ------------------------------------------------------------------ */
.alert-note {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: .85rem 1.05rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
    font-size: .93rem;
    margin-bottom: 1rem;
}

.alert-note i { font-size: 1.05rem; line-height: 1.5; flex-shrink: 0; }
.alert-note.success { background: var(--green-bg); border-color: #BFE3D6; color: #10553F; }
.alert-note.error   { background: var(--rose-bg); border-color: #F0C9C7; color: #8E2C28; }
.alert-note.warning { background: var(--amber-bg); border-color: #F0DCB6; color: #8A5709; }
.alert-note.info    { background: var(--teal-050); border-color: var(--teal-100); color: #0A5F5E; }

/* ------------------------------------------------------------------ */
/* Tables                                                              */
/* ------------------------------------------------------------------ */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-royal {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .92rem;
}

.table-royal th {
    text-align: left;
    font-weight: 600;
    font-size: .8rem;
    color: var(--muted);
    background: #F7F9FB;
    padding: .72rem 1rem;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table-royal td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

.table-royal tbody tr:last-child td { border-bottom: 0; }
.table-royal tbody tr:hover { background: #FAFCFD; }
.table-royal .amount { font-variant-numeric: tabular-nums; font-weight: 600; }

.empty-state {
    text-align: center;
    padding: 3.25rem 1.5rem;
    color: var(--muted);
}
.empty-state i { font-size: 2.4rem; color: var(--line); display: block; margin-bottom: .75rem; }
.empty-state h4 { color: var(--ink-soft); margin-bottom: .3rem; }
.empty-state p { font-size: .93rem; margin-bottom: 1rem; }

/* ------------------------------------------------------------------ */
/* Avatar                                                              */
/* ------------------------------------------------------------------ */
.avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--teal-050);
    color: var(--teal-600);
    font-weight: 700;
    font-size: .82rem;
    flex-shrink: 0;
    letter-spacing: .02em;
}

.avatar-lg { width: 60px; height: 60px; font-size: 1.15rem; }
.avatar-navy { background: var(--navy-700); color: #fff; }

/* ------------------------------------------------------------------ */
/* Utility                                                             */
/* ------------------------------------------------------------------ */
.hr-soft { height: 1px; background: var(--line-soft); border: 0; margin: 1.5rem 0; }
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--navy-800);
    color: #fff;
    padding: .75rem 1.25rem;
    z-index: 999;
    border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* ------------------------------------------------------------------ */
/* Small grid utilities - so public pages do not need a CSS framework  */
/* ------------------------------------------------------------------ */
.is-hidden { display: none !important; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 1rem;
}

.form-grid .span-2 { grid-column: 1 / -1; }

@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
}
