:root {
    --ipms-primary: #0b3d91;
    --ipms-primary-soft: #e8f0fb;
    --ipms-accent: #1f6feb;
    --ipms-bg: #f5f7fb;
    --ipms-text: #1a2233;
    --ipms-muted: #6b7280;
    --ipms-border: #e5e9f2;
    --ipms-danger: #dc3545;
    --ipms-success: #198754;
}

html, body { height: 100%; }
body { margin-bottom: 0; }

.ipms-body {
    background: var(--ipms-bg);
    color: var(--ipms-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.ipms-shell { display: flex; min-height: 100vh; }

.ipms-sidebar {
    width: 240px;
    background: #ffffff;
    border-right: 1px solid var(--ipms-border);
    padding: 18px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: width .25s ease, margin-left .25s ease, transform .25s ease, opacity .2s ease, padding .25s ease;
}

/* Desktop collapse (only applies when sidebar is sticky) */
@media (min-width: 992px) {
    .ipms-shell.ipms-sidebar-collapsed .ipms-sidebar {
        width: 0;
        margin-left: -1px;
        padding-left: 0;
        padding-right: 0;
        border-right-color: transparent;
        overflow: hidden;
    }
}

.ipms-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px 16px;
    border-bottom: 1px solid var(--ipms-border);
    margin-bottom: 12px;
    text-decoration: none; color: inherit;
}
.ipms-brand:hover { text-decoration: none; }
.ipms-brand:hover .ipms-brand-title { color: var(--ipms-accent); }
.ipms-brand-mark {
    width: 38px; height: 38px; border-radius: 8px;
    background: var(--ipms-primary); color: #fff; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.ipms-brand-title { font-weight: 700; color: var(--ipms-primary); }
.ipms-brand-sub { font-size: 11px; color: var(--ipms-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.ipms-nav { display: flex; flex-direction: column; gap: 2px; }
.ipms-nav-group {
    font-size: 11px; color: var(--ipms-muted);
    text-transform: uppercase; letter-spacing: 0.08em;
    padding: 14px 10px 6px;
}
.ipms-nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 8px;
    color: var(--ipms-text); text-decoration: none; font-size: 14px;
}
.ipms-nav-link i { color: var(--ipms-primary); }
.ipms-nav-link:hover { background: var(--ipms-primary-soft); color: var(--ipms-primary); }

.ipms-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.ipms-topbar {
    background: #fff; border-bottom: 1px solid var(--ipms-border);
    padding: 10px 18px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    position: sticky; top: 0; z-index: 50;
}
.ipms-topbar-left { display: flex; align-items: center; gap: 10px; }
.ipms-topbar-center {
    text-align: center;
    font-weight: 800;
    color: var(--ipms-primary);
    letter-spacing: 0.02em;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.ipms-title-full { display: inline; }
.ipms-title-short { display: none; }
.ipms-topbar-right { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.ipms-topbar-title { font-weight: 600; color: var(--ipms-primary); }

.ipms-icon-btn {
    width: 38px; height: 38px; border-radius: 10px;
    border: 1px solid transparent; background: transparent;
    color: var(--ipms-text);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 18px; cursor: pointer; position: relative;
    transition: background .15s, border-color .15s;
}
.ipms-icon-btn:hover { background: var(--ipms-primary-soft); }
.ipms-icon-btn.ipms-warn { color: #d97706; }
.ipms-icon-btn.ipms-warn:hover { background: #fff4e0; }

.ipms-search {
    position: relative;
    background: #f3f4f8;
    border-radius: 999px;
    padding: 6px 14px 6px 36px;
    width: 200px;
    min-width: 0;
    display: flex; align-items: center;
}
.ipms-search i { position: absolute; left: 14px; color: var(--ipms-muted); }
.ipms-search input {
    background: transparent; border: 0; outline: 0;
    width: 100%; font-size: 14px;
}

.ipms-bell-wrap { position: relative; }
.ipms-bell-badge {
    position: absolute; top: 2px; right: 2px;
    background: var(--ipms-danger); color: #fff;
    font-size: 10px; font-weight: 700;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
}
.ipms-bell-panel {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 340px; max-width: calc(100vw - 24px);
    background: #fff; border: 1px solid var(--ipms-border);
    border-radius: 12px; box-shadow: 0 12px 32px rgba(16,24,40,.12);
    z-index: 100; overflow: hidden;
}
.ipms-bell-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; border-bottom: 1px solid var(--ipms-border);
    font-weight: 700; color: var(--ipms-primary);
}
.ipms-bell-list { max-height: 360px; overflow-y: auto; }
.ipms-bell-item {
    padding: 10px 14px; border-bottom: 1px solid var(--ipms-border);
    font-size: 13px; display: flex; flex-direction: column; gap: 2px;
}
.ipms-bell-item:last-child { border-bottom: 0; }
.ipms-bell-item .meta { color: var(--ipms-muted); font-size: 11px; }
.ipms-bell-item.unread { background: #f0f6ff; }

.ipms-user { display: flex; align-items: center; gap: 10px; padding-left: 6px; }
.ipms-user-meta { text-align: right; line-height: 1.1; }
.ipms-user-name { font-weight: 600; font-size: 13px; }
.ipms-user-role { font-size: 10px; color: var(--ipms-muted); letter-spacing: 0.08em; }
.ipms-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: #1a2233; color: #fff; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}

.ipms-sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}
.ipms-shell.ipms-sidebar-open .ipms-sidebar-backdrop {
    opacity: 1;
    visibility: visible;
}

.ipms-content { padding: 24px; }

.ipms-auth {
    min-height: 100vh;
    display: block;
    background: #f5f7fb;
    padding: 0;
}
.ipms-auth-card {
    background: #fff; border-radius: 14px; padding: 36px;
    width: 100%; max-width: 420px;
    box-shadow: 0 18px 50px rgba(0,0,0,.15);
}

/* ---------- Login split-panel ---------- */
.ipms-login {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.ipms-login-side {
    background: linear-gradient(135deg, #0b3d91 0%, #1f3a8a 45%, #6b1f5a 100%);
    color: #fff;
    padding: 56px 64px;
    position: relative;
    display: flex;
    align-items: flex-start;
}
.ipms-login-side-inner {
    width: 100%;
    max-width: 480px;
}
.ipms-login-brand {
    display: flex; align-items: center; gap: 14px; margin-bottom: 56px;
}
.ipms-login-logo {
    width: 56px; height: 56px; border-radius: 14px;
    background: rgba(255,255,255,0.18);
    color: #fff; font-weight: 800; font-size: 20px;
    display: inline-flex; align-items: center; justify-content: center;
    letter-spacing: 0.04em;
}
.ipms-login-brand-title {
    font-size: 26px; font-weight: 800; line-height: 1;
}
.ipms-login-brand-sub {
    font-size: 11px; opacity: 0.75;
    letter-spacing: 0.14em; text-transform: uppercase; margin-top: 4px;
}
.ipms-login-tagline {
    font-size: 15px; line-height: 1.55;
    color: rgba(255,255,255,0.85);
    margin-bottom: 32px;
}
.ipms-login-features {
    list-style: none; padding: 0; margin: 0 0 40px;
    display: flex; flex-direction: column; gap: 14px;
}
.ipms-login-features li {
    display: flex; align-items: center; gap: 14px;
    color: rgba(255,255,255,0.95); font-size: 15px;
}
.ipms-login-features .ico {
    width: 36px; height: 36px; border-radius: 10px;
    background: rgba(255,255,255,0.15);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.ipms-login-foot {
    position: absolute; bottom: 32px; left: 64px;
    color: rgba(255,255,255,0.7); font-size: 13px;
    display: flex; align-items: center; gap: 8px;
}

.ipms-login-form-wrap {
    background: #f8fafc;
    display: flex; align-items: center; justify-content: center;
    padding: 56px 32px;
}
.ipms-login-form {
    width: 100%; max-width: 420px;
}
.ipms-login-heading {
    color: #1a2233; font-weight: 700; font-size: 28px; margin-bottom: 6px;
}
.ipms-login-subheading {
    color: var(--ipms-muted); font-size: 14px; margin-bottom: 28px;
}
.ipms-login-form .form-control-lg {
    border-radius: 10px; border-color: #e3e7ef;
    background: #fff; padding: 12px 14px; font-size: 15px;
}
.ipms-login-form .form-control-lg:focus {
    border-color: var(--ipms-primary);
    box-shadow: 0 0 0 3px rgba(11,61,145,.12);
}
.ipms-pwd-wrap { position: relative; }
.ipms-pwd-toggle {
    position: absolute; right: 10px; top: 50%;
    transform: translateY(-50%);
    background: transparent; border: 0;
    color: var(--ipms-muted); cursor: pointer;
    width: 32px; height: 32px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
}
.ipms-pwd-toggle:hover { background: #eef2f7; color: var(--ipms-primary); }
.ipms-login-btn {
    background: var(--ipms-primary); color: #fff;
    border: 0; border-radius: 10px;
    padding: 12px 16px; font-weight: 600; font-size: 15px;
    margin-top: 6px;
}
.ipms-login-btn:hover { background: #082c6a; color: #fff; }
.ipms-login-forgot {
    color: var(--ipms-muted); font-size: 14px; text-decoration: none;
}
.ipms-login-forgot:hover { color: var(--ipms-primary); text-decoration: underline; }

.ipms-login-alert {
    display: flex; align-items: flex-start; gap: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 18px;
    line-height: 1.35;
}
.ipms-login-alert i {
    font-size: 18px; color: #dc2626; flex-shrink: 0; margin-top: 1px;
}
.ipms-field-error {
    display: block;
    color: #dc2626;
    font-size: 12.5px;
    margin-top: 4px;
}
.ipms-login-form .input-validation-error {
    border-color: #fca5a5 !important;
    background: #fff5f5;
}
.ipms-login-form .input-validation-error:focus {
    box-shadow: 0 0 0 3px rgba(220,38,38,.12) !important;
    border-color: #ef4444 !important;
}

@media (max-width: 991.98px) {
    .ipms-login { grid-template-columns: 1fr; }
    .ipms-login-side { padding: 32px 28px 80px; }
    .ipms-login-foot { left: 28px; bottom: 20px; }
    .ipms-login-form-wrap { padding: 32px 20px 48px; }
}
@media (max-width: 575.98px) {
    .ipms-login-brand { margin-bottom: 28px; }
    .ipms-login-features { margin-bottom: 24px; }
    .ipms-login-heading { font-size: 24px; }
}

.ipms-tile {
    background: #fff; border-radius: 12px;
    border: 1px solid var(--ipms-border);
    padding: 20px; height: 100%;
    box-shadow: 0 1px 2px rgba(16,24,40,0.04);
}
.ipms-tile-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.ipms-tile-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--ipms-primary-soft); color: var(--ipms-primary); font-size: 18px;
}
.ipms-tile-icon.bg-danger-soft { background: #fdecec; color: var(--ipms-danger); }
.ipms-tile-icon.bg-design { background: #eaf5ff; color: #1f6feb; }
.ipms-tile-icon.bg-patent { background: #eef2ff; color: #4338ca; }
.ipms-tile-title { color: var(--ipms-primary); font-weight: 700; font-size: 18px; }
.ipms-tile-sub { color: var(--ipms-muted); font-size: 13px; margin-bottom: 14px; }
.ipms-stat-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; background: var(--ipms-primary-soft);
    border-radius: 8px; margin-bottom: 6px;
    font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
    color: #2a3956; font-weight: 600;
}
.ipms-stat-row .val { color: var(--ipms-text); font-size: 15px; }

.ipms-section-title {
    display: flex; align-items: center; gap: 8px;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--ipms-primary); font-size: 12px; font-weight: 700;
    margin: 26px 0 12px;
}
.ipms-section-title::after { content: ""; flex: 1; height: 1px; background: var(--ipms-border); }

.ipms-quick {
    background: #fff; border: 1px solid var(--ipms-border);
    border-radius: 12px; padding: 18px;
    display: flex; align-items: flex-start; gap: 14px;
    height: 100%; transition: box-shadow .15s; text-decoration: none; color: inherit;
}
.ipms-quick:hover { box-shadow: 0 6px 18px rgba(11,61,145,.08); text-decoration: none; }
.ipms-quick-icon {
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--ipms-primary-soft); color: var(--ipms-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}
.ipms-quick-title { color: var(--ipms-primary); font-weight: 700; }
.ipms-quick-desc { font-size: 13px; color: var(--ipms-muted); }

.ipms-activity-head {
    display: flex; justify-content: space-between; align-items: center;
    margin: 26px 0 10px;
}
.ipms-activity-viewall {
    color: var(--ipms-primary); font-size: 13px; text-decoration: none; font-weight: 600;
}
.ipms-activity-viewall:hover { text-decoration: underline; }
.ipms-activity {
    background: #fff; border: 1px solid var(--ipms-border);
    border-radius: 12px; padding: 6px 0; margin-top: 0;
}
.ipms-activity-empty { padding: 16px 18px; }
.ipms-activity-row {
    display: flex; gap: 14px; padding: 14px 18px;
    border-bottom: 1px solid var(--ipms-border); align-items: center;
    font-size: 13px; flex-wrap: wrap;
}
.ipms-activity-row:last-child { border-bottom: 0; }
.ipms-activity-row .time { color: var(--ipms-muted); width: 170px; }
.ipms-activity-row .user { font-weight: 700; min-width: 60px; }
.ipms-activity-row .target { font-size: 12px; }
.ipms-activity-row .action {
    background: var(--ipms-primary-soft); color: var(--ipms-primary);
    padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
}

.ipms-card {
    background: #fff; border: 1px solid var(--ipms-border);
    border-radius: 12px; padding: 18px;
}
.table { margin-bottom: 0; }
.table thead th {
    background: var(--ipms-primary-soft); color: var(--ipms-primary);
    font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; border: 0;
}
.btn-primary { background: var(--ipms-primary); border-color: var(--ipms-primary); }
.btn-primary:hover { background: #082c6a; border-color: #082c6a; }
.btn-outline-primary { color: var(--ipms-primary); border-color: var(--ipms-primary); }
.btn-outline-primary:hover { background: var(--ipms-primary); }

/* ---------- Responsive ---------- */
@media (max-width: 1399.98px) {
    .ipms-topbar-center { font-size: 14px; letter-spacing: 0; }
    .ipms-search { width: 160px; }
}

@media (max-width: 1199.98px) {
    .ipms-topbar-center { font-size: 13px; }
    .ipms-search { width: 140px; }
    .ipms-user-meta { display: none; }
}

@media (max-width: 1023.98px) {
    .ipms-title-full { display: none; }
    .ipms-title-short { display: inline; font-size: 16px; letter-spacing: 0.04em; }
}

@media (max-width: 991.98px) {
    .ipms-sidebar {
        position: fixed; top: 0; left: 0;
        height: 100vh; width: 260px;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 0 12px 32px rgba(0,0,0,.12);
    }
    .ipms-shell.ipms-sidebar-open .ipms-sidebar { transform: translateX(0); }
    .ipms-topbar { padding: 8px 12px; gap: 8px; }
    .ipms-topbar-center {
        font-size: 13px; letter-spacing: 0.02em;
    }
    .ipms-search { min-width: 140px; }
}

@media (max-width: 767.98px) {
    .ipms-topbar {
        grid-template-columns: auto auto 1fr;
        grid-template-areas: "left center right";
        row-gap: 0;
        gap: 8px;
    }
    .ipms-topbar-left { grid-area: left; }
    .ipms-topbar-center { grid-area: center; }
    .ipms-topbar-right { grid-area: right; gap: 4px; flex-wrap: nowrap; min-width: 0; }
    .ipms-topbar-center {
        font-size: 14px;
        white-space: nowrap;
    }
    .ipms-title-full { display: none; }
    .ipms-title-short { display: inline; }
    .ipms-search {
        min-width: 0; flex: 1 1 auto;
        padding: 6px 12px 6px 32px;
    }
    .ipms-search i { left: 12px; }
    .ipms-content { padding: 16px; }
    .ipms-bell-panel { right: -40px; }
    .ipms-activity-row { gap: 8px 12px; }
    .ipms-activity-row .time { width: 100%; }
}

@media (max-width: 575.98px) {
    .ipms-topbar { padding: 8px; }
    .ipms-icon-btn { width: 34px; height: 34px; font-size: 16px; }
    .ipms-avatar { width: 32px; height: 32px; font-size: 13px; }
    .ipms-topbar-center { font-size: 11px; font-weight: 700; }
    .ipms-search { padding: 5px 10px 5px 28px; font-size: 13px; }
    .ipms-search i { left: 10px; font-size: 13px; }
    .ipms-content { padding: 12px; }
    .ipms-tile { padding: 14px; }
    .ipms-quick { padding: 14px; }
    .ipms-bell-panel { width: calc(100vw - 24px); right: -8px; }
}

/* ---------- Companies page ---------- */
.ipms-companies-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
}
.ipms-search-pill,
.ipms-attorney-filter {
    position: relative;
    background: #fff;
    border: 1px solid var(--ipms-border);
    border-radius: 10px;
    padding: 8px 12px 8px 36px;
    display: inline-flex; align-items: center;
    min-width: 240px;
}
.ipms-search-pill i,
.ipms-attorney-filter i {
    position: absolute; left: 12px; color: var(--ipms-muted);
}
.ipms-search-pill input,
.ipms-attorney-filter select {
    border: 0; background: transparent; outline: 0;
    width: 100%; font-size: 14px;
}
.ipms-attorney-filter { min-width: 220px; padding-right: 28px; }
.ipms-btn-pill { border-radius: 10px; padding: 8px 16px; font-weight: 500; }
.ipms-btn-pill i { margin-right: 4px; }

.ipms-empty-state {
    text-align: center; color: var(--ipms-muted);
    padding: 64px 16px; font-size: 15px;
}
.ipms-empty-state .btn-link { color: var(--ipms-primary); font-weight: 600; }

/* Modal */
.ipms-modal { border: 0; border-radius: 14px; }
.ipms-modal .modal-header { border-bottom: 0; padding: 20px 24px 8px; }
.ipms-modal .modal-title { font-weight: 700; }
.ipms-modal .modal-body {
    padding: 8px 24px 16px;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}
.ipms-modal .modal-footer { border-top: 1px solid var(--ipms-border); padding: 14px 24px; }
.ipms-field-label {
    display: block;
    font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
    color: #475569; text-transform: uppercase; margin-bottom: 4px;
}
.ipms-modal .form-control,
.ipms-modal .form-select {
    border-radius: 8px; padding: 10px 12px; font-size: 14px;
}

/* Attorney radios */
.ipms-attorney-section {
    background: #f8fafc;
    border: 1px solid var(--ipms-border);
    border-radius: 10px; padding: 12px 14px;
}
.ipms-radio-row { display: flex; gap: 24px; align-items: center; }
.ipms-radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.ipms-radio input { accent-color: var(--ipms-primary); width: 16px; height: 16px; }

/* Combo (attorney picker) */
.ipms-combo { position: relative; }
.ipms-combo-input {
    border: 1px solid var(--ipms-primary);
    background: #fff;
    border-radius: 8px;
    padding: 10px 36px 10px 36px;
    display: flex; align-items: center; cursor: pointer; position: relative;
    box-shadow: 0 0 0 3px rgba(11, 61, 145, 0.08);
}
.ipms-combo-input > i.bi-search { position: absolute; left: 12px; color: var(--ipms-muted); }
.ipms-combo-caret { position: absolute; right: 12px; color: var(--ipms-muted); }
.ipms-combo-text { color: var(--ipms-muted); font-size: 14px; }
.ipms-combo-panel {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px);
    background: #fff; border: 1px solid var(--ipms-border);
    border-radius: 8px; box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    z-index: 20; max-height: 260px; overflow: auto;
}
.ipms-combo-head {
    padding: 10px 14px; background: #eef2ff; color: #1e293b;
    font-size: 13px; font-weight: 500;
}
.ipms-combo-list:empty + .ipms-combo-create { border-top: 0; }
.ipms-combo-item {
    padding: 10px 14px; cursor: pointer; font-size: 14px;
}
.ipms-combo-item:hover { background: var(--ipms-primary-soft); }
.ipms-combo-create {
    padding: 12px 14px; cursor: pointer;
    border-top: 1px solid var(--ipms-border);
    font-size: 14px;
}
.ipms-combo-create:hover { background: #eef2ff; }
.ipms-combo-create i { color: var(--ipms-primary); margin-right: 4px; }

.ipms-new-attorney .form-control { background: #fff; }

@media (max-width: 575.98px) {
    .ipms-companies-toolbar > * { flex: 1 1 100%; }
}

/* ---------- Bulk Import page ---------- */
.ipms-tabs {
    display: inline-flex; gap: 8px;
    background: transparent;
}
.ipms-tab {
    border: 1px solid var(--ipms-border);
    background: #fff;
    color: var(--ipms-text);
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 500;
    display: inline-flex; align-items: center; gap: 8px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.ipms-tab:hover { background: #f3f4f8; }
.ipms-tab.active {
    background: #0f172a; color: #fff; border-color: #0f172a;
}
.ipms-sheet-table thead th {
    background: #f1f5f9; color: #475569;
    font-size: 11px; letter-spacing: 0.06em;
    text-transform: uppercase; font-weight: 700;
}
.ipms-sheet-table td { padding: 6px; }
.ipms-sheet-table .form-control,
.ipms-sheet-table .form-select { font-size: 14px; }

/* Active filters chip + unlinked-active button */
.ipms-active-filters {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    font-size: 14px;
}
.ipms-filter-chip {
    display: inline-flex; align-items: center;
    background: #fef3c7; color: #92400e;
    border: 1px solid #fde68a;
    padding: 4px 10px; border-radius: 999px;
    font-size: 13px; font-weight: 600;
}
.ipms-clear-all { color: #dc2626; font-weight: 600; text-decoration: none; }
.ipms-clear-all:hover { color: #991b1b; text-decoration: underline; }

.ipms-btn-unlinked-active {
    background: #fff;
    color: #b45309;
    border: 1px solid #f59e0b;
}
.ipms-btn-unlinked-active:hover {
    background: #fffbeb;
    color: #b45309;
    border-color: #f59e0b;
}

/* ---------- Activity log page ---------- */
.ipms-activity-page .ipms-activity-head-row {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 16px; flex-wrap: wrap;
}
.ipms-activity-page .ipms-activity-actions {
    display: flex; gap: 16px; align-items: center;
}
.ipms-link { color: var(--ipms-primary); font-weight: 500; text-decoration: none; }
.ipms-link:hover { text-decoration: underline; }

.ipms-activity-table thead th {
    background: #f8fafc; color: #475569;
    font-size: 13px; font-weight: 600; letter-spacing: 0;
    text-transform: none;
    padding: 14px 16px;
    border-bottom: 1px solid var(--ipms-border);
}
.ipms-activity-table td {
    padding: 16px;
    vertical-align: top;
    border-top: 1px solid var(--ipms-border);
    font-size: 14px;
}
.ipms-activity-table tbody tr:first-child td { border-top: 0; }

.ipms-action-badge {
    color: var(--ipms-primary);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.06em;
}
.ipms-meta-chip {
    display: inline-block;
    border: 1px solid var(--ipms-border);
    border-radius: 6px;
    padding: 4px 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px; color: #1f2937;
    background: #fff;
}
.ipms-meta-toggle {
    display: block; margin-top: 6px;
    color: var(--ipms-primary); font-size: 13px;
    text-decoration: none;
}
.ipms-meta-toggle:hover { text-decoration: underline; }
.ipms-meta-json {
    margin-top: 8px;
    background: #0f172a; color: #e2e8f0;
    padding: 10px 12px; border-radius: 6px;
    font-size: 12px; max-width: 360px; overflow: auto;
}
.ipms-activity-foot {
    padding: 12px 18px;
    color: var(--ipms-muted);
    font-size: 13px;
    border-top: 1px solid var(--ipms-border);
    background: #fafbfc;
    border-radius: 0 0 12px 12px;
}

/* Activity log pagination */
.ipms-activity-foot {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 8px;
}
.ipms-pager {
    display: inline-flex; align-items: center; gap: 4px;
}
.ipms-pager-btn,
.ipms-pager-num {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 32px; height: 32px;
    padding: 0 10px;
    border: 1px solid var(--ipms-border);
    background: #fff;
    color: var(--ipms-text);
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    gap: 4px;
}
.ipms-pager-btn:hover,
.ipms-pager-num:hover { background: var(--ipms-primary-soft); color: var(--ipms-primary); }
.ipms-pager-btn.disabled {
    color: #94a3b8; background: #f8fafc; cursor: default;
}
.ipms-pager-num.active {
    background: var(--ipms-primary); color: #fff; border-color: var(--ipms-primary);
}
.ipms-pager-ellipsis { padding: 0 4px; color: var(--ipms-muted); }

/* Attorneys page */
.ipms-page-toolbar-right .ipms-firm-select { min-width: 140px; }
.ipms-search-row label { white-space: nowrap; }
.ipms-attorney-table thead th {
    background: #f8fafc;
    font-size: 12px;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 600;
    letter-spacing: .03em;
    border-bottom: 1px solid #e2e8f0;
}
.ipms-attorney-table tbody td { border-top: 1px solid #f1f5f9; }
.ipms-sort-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.ipms-sort-link:hover { color: var(--ipms-primary); }
.ipms-sort-link i { font-size: 12px; }

/* CSV import */
.ipms-import-format-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
}
.ipms-import-format-box code {
    background: transparent;
    color: #0f172a;
    padding: 0;
}
.ipms-choose-csv { cursor: pointer; display: block; }
.ipms-choose-csv-inner {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 28px 16px;
    text-align: center;
    color: #475569;
    transition: border-color .15s, background .15s;
}
.ipms-choose-csv:hover .ipms-choose-csv-inner {
    border-color: var(--ipms-primary);
    background: var(--ipms-primary-soft);
}

/* Patent application form */
.ipms-patent-form .ipms-intake-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.ipms-field-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 6px;
}
.ipms-supporting-files { display: flex; flex-direction: column; gap: 8px; }
.ipms-support-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
}
.ipms-support-label { font-weight: 500; color: #334155; }
.ipms-support-add {
    color: var(--ipms-primary); text-decoration: none; font-weight: 600; font-size: 14px;
}
.ipms-support-add:hover { text-decoration: underline; }

.ipms-company-combo { position: relative; }
.ipms-company-results {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px);
    background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15,23,42,.08);
    max-height: 240px; overflow-y: auto; z-index: 30;
}
.ipms-company-result { padding: 8px 12px; cursor: pointer; }
.ipms-company-result:hover { background: var(--ipms-primary-soft); color: var(--ipms-primary); }

.ipms-create-link {
    color: var(--ipms-primary);
    text-decoration: none;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: .04em;
    font-size: 11px;
}
.ipms-create-link:hover { text-decoration: underline; }

/* Quick-create company modal */
.ipms-qcc-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 12vh; z-index: 1080;
}
.ipms-qcc-modal {
    background: #fff; border-radius: 10px; box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
    width: 100%; max-width: 460px; padding: 22px 22px 20px; position: relative;
}
.ipms-qcc-close {
    position: absolute; top: 10px; right: 12px; background: none; border: 0;
    font-size: 22px; line-height: 1; color: #94a3b8; cursor: pointer;
}
.ipms-qcc-close:hover { color: #475569; }
.ipms-qcc-title { font-weight: 600; }

.ipms-form-footer { border-top: 1px solid #e2e8f0; padding-top: 16px; }

/* Patents index */
.ipms-patent-toolbar .ipms-appno { width: 130px; }
.ipms-patent-toolbar .ipms-appno-wide { width: 320px; max-width: 100%; }

.ipms-results-bar {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
    padding: 10px 16px;
}
.ipms-filter-btn { position: relative; }
.ipms-filter-badge {
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: 6px; min-width: 18px; height: 18px; padding: 0 6px;
    border-radius: 999px; background: #0f172a; color: #fff;
    font-size: 11px; font-weight: 600;
}
.ipms-closed-on { background: var(--ipms-primary) !important; color: #fff !important; border-color: var(--ipms-primary) !important; }

.ipms-pfilter-title { color: var(--ipms-primary); letter-spacing: .05em; }
.ipms-pfilter-chip {
    border: 0;
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 999px;
    padding: 6px 16px;
    font-weight: 500;
    font-size: 14px;
    transition: background .15s, color .15s;
}
.ipms-pfilter-chip:hover { background: #fecaca; }
.ipms-pfilter-active { background: #dc2626; color: #fff; }
.ipms-pfilter-active:hover { background: #b91c1c; }

.ipms-active-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 500;
    border: 1px solid transparent;
}
.ipms-chip-green { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.ipms-chip-blue { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.ipms-chip-red { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.ipms-chip-x {
    border: 0; background: transparent; color: inherit; font-size: 16px;
    line-height: 1; padding: 0; cursor: pointer;
}

/* Filters popover (anchored under Filters button, tabbed) */
.ipms-filters-anchor { position: relative; display: inline-block; }
.ipms-filters-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 520px;
    max-width: 92vw;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
    z-index: 1060;
    overflow: hidden;
}
.ipms-filters-popover[hidden] { display: none; }
.ipms-filters-grid {
    display: grid;
    grid-template-columns: 170px 1fr;
    min-height: 320px;
}
.ipms-filters-nav {
    border-right: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 10px 0;
    margin: 0;
    list-style: none;
    overflow-y: auto;
}
.ipms-filters-nav li { list-style: none; }
.ipms-fnav-link {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    padding: 9px 16px;
    color: #334155;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.ipms-fnav-link:hover { background: #eef2f7; }
.ipms-fnav-link.active {
    background: #fff;
    color: var(--ipms-primary);
    border-left-color: var(--ipms-primary);
    font-weight: 600;
}
.ipms-filters-panes { padding: 18px 20px; overflow-y: auto; max-height: 360px; }
.ipms-fpane { display: none; }
.ipms-fpane.active { display: block; }
.ipms-fpane code {
    background: #f1f5f9; color: #334155; padding: 1px 6px; border-radius: 4px;
    font-size: 12px;
}
.ipms-filters-footer {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 10px 14px;
}

@media (max-width: 640px) {
    .ipms-filters-popover { width: 92vw; right: auto; left: 0; }
    .ipms-filters-grid { grid-template-columns: 130px 1fr; min-height: 280px; }
    .ipms-filters-panes { padding: 14px; max-height: 320px; }
}


/* Module chips (Matters page) */
.ipms-module-chips { gap: 8px; }
.ipms-module-chip {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background .12s ease, color .12s ease;
}
.ipms-module-chip:hover { background: #dbeafe; color: #1d4ed8; }
.ipms-module-chip.ipms-module-active {
    background: #1d4ed8;
    color: #fff;
}

/* === Trademark Form preview modal === */
.ipms-preview-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
    display: flex; align-items: stretch; justify-content: center;
    z-index: 1080; padding: 24px;
}
.ipms-preview-overlay[hidden] { display: none; }
.ipms-preview-modal {
    background: #fff; border-radius: 12px; width: 100%; max-width: 1100px;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.ipms-preview-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid #e2e8f0;
}
.ipms-preview-note {
    background: #fff7ed; color: #92400e; padding: 8px 16px;
    font-size: .82rem; border-bottom: 1px solid #fcd34d;
}
.ipms-preview-body {
    flex: 1; overflow: auto; padding: 24px; background: #f1f5f9;
}
.ipms-doc-paper {
    background: #fff; max-width: 820px; margin: 0 auto;
    padding: 56px 64px; min-height: 1000px;
    box-shadow: 0 4px 14px rgba(0,0,0,.08);
    font-family: "Times New Roman", Georgia, serif; color: #111; line-height: 1.55;
}
.ipms-doc-title {
    text-align: center; text-decoration: underline; font-weight: 700;
    font-size: 1.1rem; margin: 0 0 24px;
}
.ipms-doc-to { margin: 0 0 16px; }
.ipms-doc-field { margin: 14px 0; }
.ipms-doc-label { font-weight: 600; margin-bottom: 6px; }
.ipms-doc-box {
    border: 1px solid #111; min-height: 48px; padding: 8px 12px;
}
.ipms-doc-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.ipms-doc-table th, .ipms-doc-table td {
    border: 1px solid #111; padding: 6px 10px; font-size: .92rem; text-align: left;
}
.ipms-doc-table th { background: #f8fafc; }
.ipms-doc-sign { padding: 8px 0; }
.ipms-doc-print { background: #fff; margin: 0; padding: 24px; }
@media print {
    .ipms-doc-paper { box-shadow: none; padding: 0; }
}

/* Global back / breadcrumb bar */
.ipms-breadcrumb-bar { display: flex; align-items: center; }
.ipms-back-btn { color: #475569; font-weight: 500; }
.ipms-back-btn:hover { color: #1d4ed8; }

/* Dashboard Recent Activity: clickable rows + footer link */
.ipms-activity-link { color: inherit; text-decoration: none; display: grid; }
.ipms-activity-link:hover { background: #f1f5f9; color: inherit; }
.ipms-activity-footer {
    display: block; text-align: right; padding: 10px 12px; font-weight: 600;
    color: #1d4ed8; text-decoration: none; border-top: 1px solid #e2e8f0;
}
.ipms-activity-footer:hover { background: #eff6ff; }
