/* ============================================================
   MISESO  —  COMPONENTS
   Cards, tables, forms, buttons, badges, KPI tiles, tabs, etc.
   ============================================================ */

/* ----------  CARD  ---------- */
.m-card {
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
    overflow: hidden;
}
.m-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--c-line);
    background: #fff;
}
.m-card__head h3, .m-card__head h4 {
    margin: 0;
    font-size: var(--fs-lg);
    color: var(--c-black);
    font-weight: 600;
    font-family: var(--ff-sans);
}
.m-card__head .eyebrow {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--c-gold-2);
    font-weight: 600;
}
.m-card__head .head-icon {
    color: var(--c-gold);
    margin-right: 6px;
}
.m-card__head .head-actions { display: flex; gap: 6px; }
.m-card__body { padding: 16px 18px; }
.m-card__body--flush { padding: 0; }
.m-card__foot {
    padding: 12px 18px;
    border-top: 1px solid var(--c-line);
    background: var(--c-surface-2);
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
}

/* dark card variant */
.m-card--dark {
    background: var(--c-black);
    color: #fff;
    border: 1px solid #000;
}
.m-card--dark .m-card__head {
    background: var(--c-black);
    border-bottom-color: #2a2a30;
}
.m-card--dark .m-card__head h3,
.m-card--dark .m-card__head h4 { color: #fff; }
.m-card--dark .m-card__body { color: #d6d6dc; }
.m-card--dark .m-card__foot { background: var(--c-black-2); border-top-color: #2a2a30; }

/* gold card variant (e.g. dashboard hero) */
.m-card--gold {
    background: linear-gradient(135deg, var(--c-gold) 0%, var(--c-gold-3) 100%);
    color: #fff;
    border: 1px solid var(--c-gold-3);
}
.m-card--gold .m-card__head { background: transparent; border-bottom-color: rgba(255,255,255,.25); }
.m-card--gold .m-card__head h3,
.m-card--gold .m-card__head h4 { color: #fff; }

/* ----------  KPI TILE  ---------- */
.m-kpi {
    background: #fff;
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--sh-1);
}
.m-kpi::before {
    content: "";
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 4px;
    background: var(--c-gold);
}
.m-kpi__icon {
    position: absolute;
    top: 14px; right: 14px;
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--c-gold-soft);
    color: var(--c-gold-2);
    display: grid; place-items: center;
}
.m-kpi__label {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--c-text-3);
    font-weight: 600;
    margin-bottom: 4px;
}
.m-kpi__value {
    font-family: var(--ff-display);
    font-size: 28px;
    color: var(--c-black);
    font-weight: 600;
    line-height: 1.1;
}
.m-kpi__delta {
    margin-top: 6px;
    font-size: var(--fs-sm);
    color: var(--c-success);
    display: flex; align-items: center; gap: 4px;
}
.m-kpi__delta.is-down { color: var(--c-danger); }
.m-kpi__delta.is-neutral { color: var(--c-text-3); }

.m-kpi--dark { background: var(--c-black); color: #fff; border-color: #000; }
.m-kpi--dark::before { background: var(--c-gold); }
.m-kpi--dark .m-kpi__label { color: var(--c-gold); }
.m-kpi--dark .m-kpi__value { color: #fff; }
.m-kpi--dark .m-kpi__icon { background: rgba(255,255,255,.1); color: var(--c-gold); }

/* ----------  BUTTONS  ---------- */
.m-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: var(--fs-md);
    font-weight: 600;
    border: 1px solid transparent;
    transition: all .15s var(--ease);
    background: #fff;
    color: var(--c-text);
    cursor: pointer;
    white-space: nowrap;
}
.m-btn:hover { transform: translateY(-1px); }
.m-btn:active { transform: translateY(0); }
.m-btn .icon { width: 14px; height: 14px; }

.m-btn--primary { background: var(--c-black); color: #fff; border-color: var(--c-black); }
.m-btn--primary:hover { background: var(--c-black-2); }

.m-btn--gold { background: var(--c-gold); color: #fff; border-color: var(--c-gold); }
.m-btn--gold:hover { background: var(--c-gold-2); border-color: var(--c-gold-2); }

.m-btn--ghost { background: transparent; border-color: var(--c-line-2); color: var(--c-text-2); }
.m-btn--ghost:hover { border-color: var(--c-gold); color: var(--c-gold-2); }

.m-btn--danger { background: #fff; color: var(--c-danger); border-color: var(--c-danger); }
.m-btn--danger:hover { background: var(--c-danger); color: #fff; }

.m-btn--sm { padding: 5px 10px; font-size: var(--fs-sm); border-radius: 6px; }
.m-btn--block { width: 100%; justify-content: center; }
.m-btn--icon { padding: 7px; }

/* Make icon + text inside a button align cleanly with a small gap. */
.m-btn .icon { flex: 0 0 auto; vertical-align: -2px; }
.m-btn > span { vertical-align: middle; }
.m-btn > .icon + span,
.m-btn > span + .icon { margin-left: 4px; }

/* Subtle danger variant for ghost buttons: red text, red border on hover. */
.m-btn--danger-text { color: var(--c-danger); border-color: rgba(220, 53, 69, .35); }
.m-btn--danger-text:hover { color: #fff; background: var(--c-danger); border-color: var(--c-danger); }

.m-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ----------  BADGES  ---------- */
.m-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: var(--c-surface-3);
    color: var(--c-text-2);
    border: 1px solid var(--c-line);
    white-space: nowrap;
}
.m-badge--gold { background: var(--c-gold-soft); color: var(--c-gold-3); border-color: var(--c-gold-line); }
.m-badge--success { background: #e7f5ec; color: var(--c-success); border-color: #c2e3cd; }
.m-badge--warning { background: #fdf2dc; color: var(--c-warning); border-color: #f1d99c; }
.m-badge--danger { background: #fbe5e1; color: var(--c-danger); border-color: #f1bdb6; }
.m-badge--info { background: #e1ecf7; color: var(--c-info); border-color: #b9d2eb; }
.m-badge--black { background: var(--c-black); color: #fff; border-color: var(--c-black); }
.m-badge--dot::before {
    content: "";
    width: 6px; height: 6px;
    background: currentColor;
    border-radius: 50%;
}

/* ----------  TABLE  ---------- */
.m-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-md);
}
.m-table thead th {
    background: var(--c-surface-3);
    color: var(--c-text-2);
    text-align: left;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: .12em;
    font-weight: 700;
    padding: 10px 14px;
    border-bottom: 1px solid var(--c-line);
    white-space: nowrap;
}
.m-table thead th:first-child { padding-left: 18px; }
.m-table thead th:last-child { padding-right: 18px; text-align: right; }
.m-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--c-line);
    color: var(--c-text);
    vertical-align: middle;
}
.m-table tbody td:last-child { text-align: right; }
.m-table tbody td:first-child { padding-left: 18px; }
.m-table tbody tr:hover { background: var(--c-surface-2); }
.m-table tbody tr:last-child td { border-bottom: none; }

.m-table--clean thead th { background: transparent; border-bottom: 2px solid var(--c-gold); }
.m-table--compact tbody td { padding: 8px 14px; }

/* Fixed-layout table that wraps long content so no column gets clipped. */
.m-table--wrap { table-layout: fixed; }
.m-table.m-table--wrap th, .m-table.m-table--wrap td {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

/* Horizontal scroll wrapper for wide tables so they stay readable on narrow viewports. */
.m-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
}
.m-table-scroll .m-table { min-width: 900px; }

/* ============================================================
   RESPONSIVE TABLE
   - Desktop (>= 1100px): full table with all columns
   - Tablet  (768-1099px): horizontal scroll + sticky first column
   - Mobile  (< 768px) : table collapses to card stack, each
     row becomes a list of label/value pairs read from data-label.
   ============================================================ */

/* Sticky first column on tablet (when table is scrollable horizontally) */
@media (max-width: 1099px) {
    .m-table--responsive thead th:first-child,
    .m-table--responsive tbody td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: #fff;
        box-shadow: 1px 0 0 var(--c-line);
    }
    .m-table--responsive thead th:first-child {
        background: var(--c-surface-3);
        z-index: 3;
    }
}

/* On mobile, convert table rows to card stacks */
@media (max-width: 767px) {
    .m-table-scroll { overflow-x: visible; }
    .m-table-scroll .m-table { min-width: 0; }

    .m-table--responsive {
        border: 0;
        background: transparent;
    }
    .m-table--responsive thead { display: none; }
    .m-table--responsive tbody,
    .m-table--responsive tr,
    .m-table--responsive td { display: block; width: 100%; }
    .m-table--responsive tr {
        background: #fff;
        border: 1px solid var(--c-line);
        border-radius: 10px;
        padding: 6px 14px;
        margin-bottom: 10px;
        box-shadow: 0 1px 2px rgba(0,0,0,.03);
    }
    .m-table--responsive td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 10px 0;
        border-bottom: 1px dashed var(--c-line-2);
        text-align: right;
    }
    .m-table--responsive td:last-child { border-bottom: 0; }
    .m-table--responsive td::before {
        content: attr(data-label);
        flex: 0 0 42%;
        max-width: 42%;
        text-align: left;
        font-size: var(--fs-sm);
        font-weight: 600;
        color: var(--c-text-2);
        text-transform: uppercase;
        letter-spacing: .04em;
    }
    .m-table--responsive td > * { text-align: right; }
    .m-table--responsive .m-table__actions {
        justify-content: flex-end;
        flex-wrap: wrap;
    }
}

.m-table .row-title { font-weight: 600; color: var(--c-black); }
.m-table .row-sub { font-size: var(--fs-sm); color: var(--c-text-3); margin-top: 2px; }

.m-table__actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.m-table__actions .m-btn { white-space: nowrap; }
.m-table__actions .m-btn--icon { padding: 5px; }

/* ----------  FORMS  ---------- */
.m-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.m-field__label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--c-text);
    display: flex; align-items: center; gap: 4px;
}
.m-field__label .req { color: var(--c-danger); }
.m-field__hint { font-size: var(--fs-xs); color: var(--c-text-3); }
.m-field__error { font-size: var(--fs-xs); color: var(--c-danger); }

.m-input, .m-select, .m-textarea {
    width: 100%;
    background: #fff;
    border: 1px solid var(--c-line-2);
    border-radius: 8px;
    padding: 9px 12px;
    color: var(--c-text);
    font-size: var(--fs-md);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.m-input:focus, .m-select:focus, .m-textarea:focus {
    outline: none;
    border-color: var(--c-gold);
    box-shadow: 0 0 0 3px var(--c-gold-glow);
}
.m-textarea { min-height: 90px; resize: vertical; }
.m-input--gold { border-color: var(--c-gold); }
.m-input::placeholder { color: var(--c-text-muted); }

.m-field--row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.m-field--row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .m-field--row, .m-field--row-3 { grid-template-columns: 1fr; } }

.m-checkbox, .m-radio {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-md);
    color: var(--c-text);
    cursor: pointer;
    user-select: none;
}
.m-checkbox input, .m-radio input {
    appearance: none;
    width: 16px; height: 16px;
    border: 1.5px solid var(--c-line-2);
    background: #fff;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all .15s var(--ease);
}
.m-radio input { border-radius: 50%; }
.m-checkbox input:checked, .m-radio input:checked {
    background: var(--c-gold);
    border-color: var(--c-gold);
}
.m-checkbox input:checked::after {
    content: "✓";
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}
.m-radio input:checked::after {
    content: "";
    width: 6px; height: 6px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

/* ----------  TABS  ---------- */
.m-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--c-line);
    margin-bottom: 16px;
    overflow-x: auto;
}
.m-tab {
    padding: 10px 14px;
    font-size: var(--fs-md);
    color: var(--c-text-2);
    cursor: pointer;
    border: none;
    background: transparent;
    border-bottom: 2px solid transparent;
    font-weight: 600;
    white-space: nowrap;
    transition: color .15s var(--ease), border-color .15s var(--ease);
}
.m-tab:hover { color: var(--c-gold-2); }
.m-tab.is-active { color: var(--c-black); border-bottom-color: var(--c-gold); }
.m-tab__count {
    background: var(--c-gold-soft);
    color: var(--c-gold-3);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    margin-left: 6px;
}

/* ----------  ALERTS / BANNERS  ---------- */
.m-alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: var(--fs-md);
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 3px solid;
    margin-bottom: 12px;
}
.m-alert--info    { background: #e1ecf7; color: #1f4f87; border-color: var(--c-info); }
.m-alert--success { background: #e7f5ec; color: #1e6b3d; border-color: var(--c-success); }
.m-alert--warning { background: #fdf2dc; color: #8a5d0a; border-color: var(--c-warning); }
.m-alert--danger  { background: #fbe5e1; color: #842218; border-color: var(--c-danger); }
.m-alert--gold    { background: var(--c-gold-soft); color: var(--c-gold-3); border-color: var(--c-gold); }

/* ----------  PROGRESS  ---------- */
.m-progress {
    width: 100%;
    height: 8px;
    background: var(--c-surface-3);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}
.m-progress__bar {
    height: 100%;
    background: linear-gradient(90deg, var(--c-gold) 0%, var(--c-gold-2) 100%);
    border-radius: 999px;
    transition: width .3s var(--ease);
}
.m-progress--black .m-progress__bar { background: var(--c-black); }

/* ----------  AVATARS / PILLS  ---------- */
.m-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--c-surface-3);
    color: var(--c-text);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: var(--fs-sm);
    font-weight: 500;
    border: 1px solid var(--c-line);
}
.m-pill__dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--c-gold);
}
.m-pill--gold { background: var(--c-gold-soft); color: var(--c-gold-3); border-color: var(--c-gold-line); }
.m-pill--black { background: var(--c-black); color: #fff; border-color: var(--c-black); }
.m-pill--black .m-pill__dot { background: var(--c-gold); }

/* ----------  LIST  ---------- */
.m-list { list-style: none; padding: 0; margin: 0; }
.m-list__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--c-line);
}
.m-list__item:last-child { border-bottom: none; }
.m-list__item:hover { background: var(--c-surface-2); }
.m-list__title { font-weight: 600; color: var(--c-black); font-size: var(--fs-md); }
.m-list__sub { font-size: var(--fs-sm); color: var(--c-text-3); margin-top: 2px; }

/* ----------  TIMELINE  ---------- */
.m-timeline { position: relative; padding-left: 22px; }
.m-timeline::before {
    content: "";
    position: absolute;
    left: 6px; top: 4px; bottom: 4px;
    width: 2px;
    background: var(--c-line);
}
.m-timeline__item { position: relative; padding-bottom: 14px; }
.m-timeline__item::before {
    content: "";
    position: absolute;
    left: -22px; top: 4px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--c-gold);
}
.m-timeline__item.is-done::before { background: var(--c-gold); }
.m-timeline__title { font-weight: 600; color: var(--c-black); }
.m-timeline__sub { font-size: var(--fs-sm); color: var(--c-text-3); }

/* ----------  KANBAN  ---------- */
.m-kanban {
    display: grid;
    grid-template-columns: repeat(4, minmax(220px, 1fr));
    gap: 12px;
    overflow-x: auto;
}
.m-kanban__col {
    background: var(--c-surface-3);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    padding: 10px;
    min-height: 200px;
}
.m-kanban__col h4 {
    margin: 0 0 10px;
    font-size: var(--fs-sm);
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--c-gold-3);
    display: flex; justify-content: space-between;
    border-bottom: 2px solid var(--c-gold);
    padding-bottom: 6px;
}
.m-kanban__card {
    background: #fff;
    border: 1px solid var(--c-line);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    box-shadow: var(--sh-1);
    cursor: grab;
}
.m-kanban__card .ttl { font-weight: 600; color: var(--c-black); font-size: var(--fs-md); }
.m-kanban__card .sub { font-size: var(--fs-sm); color: var(--c-text-3); margin-top: 4px; }
.m-kanban__card .ft {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 8px;
}

/* ----------  EMPTY STATE  ---------- */
.m-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--c-text-3);
}
.m-empty .icon {
    width: 48px; height: 48px;
    margin: 0 auto 12px;
    color: var(--c-gold);
    opacity: .6;
}
.m-empty h4 { color: var(--c-text); margin: 0 0 4px; font-family: var(--ff-sans); font-size: var(--fs-lg); }

/* ----------  MODAL  ---------- */
.m-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 100;
    display: none;
    align-items: center; justify-content: center;
    padding: 20px;
}
.m-modal-backdrop.is-open { display: flex; }
.m-modal {
    background: #fff;
    border-radius: var(--r-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: var(--sh-3);
}
.m-modal__head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--c-line);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--c-black);
    color: #fff;
}
.m-modal__head h3 { margin: 0; color: #fff; font-family: var(--ff-sans); font-size: var(--fs-lg); }
.m-modal__head .close-btn { color: #fff; background: transparent; border: none; font-size: 18px; opacity: .8; }
.m-modal__head .close-btn:hover { opacity: 1; color: var(--c-gold); }
.m-modal__body { padding: 20px; overflow-y: auto; }
.m-modal__foot {
    padding: 12px 20px;
    border-top: 1px solid var(--c-line);
    display: flex; justify-content: flex-end; gap: 8px;
    background: var(--c-surface-2);
}

/* ----------  TOAST  ---------- */
.m-toast-stack {
    position: fixed;
    bottom: 20px; right: 20px;
    z-index: 200;
    display: flex; flex-direction: column; gap: 8px;
    max-width: 360px;
}
.m-toast {
    background: #fff;
    border: 1px solid var(--c-line);
    border-left: 3px solid var(--c-gold);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: var(--sh-3);
    display: flex; align-items: center; gap: 10px;
    font-size: var(--fs-md);
    animation: m-toast-in .25s var(--ease);
}
.m-toast--success { border-left-color: var(--c-success); }
.m-toast--danger  { border-left-color: var(--c-danger); }
.m-toast--info    { border-left-color: var(--c-info); }
@keyframes m-toast-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ----------  ICON HELPER  ---------- */
.icon { display: inline-block; vertical-align: middle; }
.icon-16 { width: 16px; height: 16px; }
.icon-18 { width: 18px; height: 18px; }
.icon-20 { width: 20px; height: 20px; }
.icon-24 { width: 24px; height: 24px; }
.icon-32 { width: 32px; height: 32px; }

/* ----------  MISC HELPERS  ---------- */
.m-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--c-gold) 50%, transparent 100%);
    margin: 12px 0;
    border: 0;
}
.m-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-text-right { text-align: right; }
.m-text-center { text-align: center; }
.m-mt-0 { margin-top: 0; }
.m-mb-0 { margin-bottom: 0; }
.m-mt-2 { margin-top: 8px; } .m-mt-3 { margin-top: 12px; } .m-mt-4 { margin-top: 16px; }
.m-mb-2 { margin-bottom: 8px; } .m-mb-3 { margin-bottom: 12px; } .m-mb-4 { margin-bottom: 16px; }