/* =========================================================
   MILLIMON UI HIERARCHY
   Reusable visual hierarchy for manager/OD CRUD pages.
   ========================================================= */

.content-stack {
    display: grid;
    gap: 18px;
}

.page-back {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 14px;
    color: var(--purple);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.page-back:hover {
    color: var(--purple-dark);
}

.page-eyebrow {
    display: block;
    margin-bottom: 5px;
    color: var(--purple);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.section-card {
    padding: 20px;
}

.section-card.is-soft-purple {
    border-color: #ded0ef;
    background: #fbf8fe;
}

.section-card.is-soft-yellow {
    border-color: #eee0a1;
    background: #fffdf1;
}

.section-card.is-soft-red {
    border-color: #efc5d0;
    background: #fff8fa;
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.section-head:last-child {
    margin-bottom: 0;
}

.section-title {
    margin: 0;
    font-size: 17px;
    line-height: 1.3;
}

.section-subtitle {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.section-actions,
.action-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--line);
}

.info-item {
    min-width: 0;
    padding: 14px 15px;
    background: var(--surface);
}

.info-item > span,
.info-label {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.info-item > strong,
.info-value {
    display: block;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.info-item.is-accent {
    background: var(--purple-soft);
}

.info-item.is-accent > span,
.info-item.is-accent .info-label {
    color: #766287;
}

.info-item.is-accent > strong,
.info-item.is-accent .info-value {
    color: var(--purple-dark);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.kpi-card {
    position: relative;
    overflow: hidden;
    padding: 18px;
}

.kpi-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--purple);
}

.kpi-card.is-yellow::before {
    background: var(--yellow);
}

.kpi-card.is-danger::before {
    background: var(--danger);
}

.kpi-card.is-success::before {
    background: var(--success);
}

.kpi-label {
    display: block;
    margin-bottom: 9px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.kpi-value {
    display: block;
    font-size: 27px;
    font-weight: 700;
    line-height: 1;
}

.entity-list {
    display: grid;
    gap: 10px;
}

.entity-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.entity-row:hover {
    border-color: #d9cce7;
    background: #fdfbff;
}

.entity-main {
    min-width: 0;
}

.entity-title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
}

.entity-title a {
    color: var(--text);
    text-decoration: none;
}

.entity-title a:hover {
    color: var(--purple);
}

.entity-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 14px;
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
}

.entity-meta strong {
    color: #5d5662;
    font-weight: 600;
}

.entity-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 7px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 27px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #f0edf2;
    color: #625c67;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.status-pill.is-active,
.status-pill.is-completed,
.status-pill.is-delivered,
.status-pill.is-success {
    background: #e9f6ee;
    color: var(--success);
}

.status-pill.is-paused,
.status-pill.is-rescheduled,
.status-pill.is-warning {
    background: var(--yellow-soft);
    color: #75631f;
}

.status-pill.is-scheduled,
.status-pill.is-info,
.status-pill.is-submitted {
    background: #edf3ff;
    color: var(--info);
}

.status-pill.is-cancelled,
.status-pill.is-closed,
.status-pill.is-danger,
.status-pill.is-overdue {
    background: #fae7ec;
    color: var(--danger);
}

.note-box {
    padding: 15px 16px;
    border-left: 4px solid var(--purple);
    border-radius: 0 12px 12px 0;
    background: #faf7fd;
    color: #48404d;
    font-size: 13px;
    line-height: 1.6;
}

.note-box.is-yellow {
    border-left-color: #e1bd2d;
    background: var(--yellow-soft);
}

.note-box.is-danger {
    border-left-color: var(--danger);
    background: #fff4f6;
}

.note-box.is-success {
    border-left-color: var(--success);
    background: #f1faf5;
}

.note-box strong:first-child {
    color: var(--text);
}

.form-card {
    padding: 20px;
}

.ui-form {
    display: grid;
    gap: 15px;
}

.ui-form > p,
.form-card form > p,
.form-section > p {
    display: grid;
    gap: 6px;
    margin: 0;
}

.ui-form label,
.form-card form > p > label,
.form-section > p > label,
.field-label {
    color: #5f5864;
    font-size: 11px;
    font-weight: 600;
}

.ui-form .helptext,
.form-card .helptext {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.45;
}

.ui-form ul.errorlist,
.form-card ul.errorlist,
.form-error-list {
    margin: 0;
    padding: 10px 12px;
    list-style: none;
    border-radius: 9px;
    background: #fff0f4;
    color: var(--danger);
    font-size: 11px;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 4px;
    padding-top: 15px;
    border-top: 1px solid var(--line);
}

.form-section {
    display: grid;
    gap: 13px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fcfbfd;
}

.form-section-title {
    margin: 0;
    color: var(--purple-dark);
    font-size: 13px;
    font-weight: 700;
}

.inline-form {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-form > label,
.inline-field {
    display: grid;
    gap: 5px;
    min-width: 150px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
}

.table-shell {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
}

.ui-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.ui-table th,
.ui-table td {
    padding: 12px 13px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.ui-table th {
    background: #f8f6fa;
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.ui-table tbody tr:last-child td {
    border-bottom: 0;
}

.ui-table tbody tr:hover td {
    background: #fdfbff;
}

.ui-table a {
    color: var(--purple);
    font-weight: 600;
    text-decoration: none;
}

.ui-table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 10px;
}

.ui-table-actions a.is-danger {
    color: var(--danger);
}

.empty-state {
    padding: 30px 22px;
    border: 1px dashed #d9d2de;
    border-radius: 13px;
    background: #fcfbfd;
    text-align: center;
}

.empty-state strong {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
}

.empty-state p {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

.subpanel {
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fcfbfd;
}

.subpanel + .subpanel {
    margin-top: 10px;
}

.subpanel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.subpanel-title {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
}

.divider {
    height: 1px;
    margin: 16px 0;
    background: var(--line);
}

.muted {
    color: var(--muted);
}

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--success);
}

.link-action {
    color: var(--purple);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.link-action:hover {
    color: var(--purple-dark);
}

.link-danger {
    color: var(--danger);
}

.btn-sm {
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 11px;
}

.btn-link {
    min-height: auto;
    padding: 0;
    background: transparent;
    color: var(--purple);
}

.btn-link:hover {
    transform: none;
    color: var(--purple-dark);
}

@media (max-width: 980px) {
    .info-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .section-card,
    .form-card {
        padding: 16px;
    }

    .section-head,
    .entity-row,
    .subpanel-head {
        flex-direction: column;
        align-items: stretch;
    }

    .info-grid,
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .entity-actions,
    .form-actions {
        justify-content: stretch;
    }

    .entity-actions .btn,
    .form-actions .btn {
        width: 100%;
        text-align: center;
    }

    .inline-form {
        display: grid;
        grid-template-columns: 1fr;
    }

    .inline-form > label,
    .inline-field {
        min-width: 0;
    }
}

.info-item.is-flush {
    padding: 0;
}

.info-item.span-2 {
    grid-column: span 2;
}

.mt-10 {
    margin-top: 10px;
}

.my-10-16 {
    margin: 10px 0 16px;
}

@media (max-width: 980px) {
    .info-item.span-2 {
        grid-column: span 1;
    }
}
