:root {
    --sidebar-bg: #1e293b;
    --sidebar-active: #2b3d54;
    --topbar-bg: #ffffff;
    --body-bg: #f8fafc;
    --primary-blue: #0066cc;
    --success-green: #2e7d32;
    --warning-orange: #e67e22;
    --text-dark: #334155;
    --text-light: #64748b;
    --cod-teal: #42e3c2;
}

/* Login landing page */
body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at top left, rgba(0, 102, 204, 0.18), transparent 40%),
        linear-gradient(145deg, #0f172a 0%, #1e293b 45%, #334155 100%);
    color: var(--text-dark);
    padding: 24px;
}

.login-shell {
    width: 100%;
    max-width: 460px;
}

.login-panel {
    background: #ffffff;
    border-radius: 12px;
    padding: 40px 36px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.35);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.login-logo-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #0066cc;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.login-brand-name {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 1px;
    line-height: 1;
    color: #111827;
}

.login-brand-sub {
    margin-top: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--success-green);
    letter-spacing: 0.3px;
}

.login-title {
    font-size: 1.45rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-dark);
}

.login-copy {
    color: var(--text-light);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 28px;
}

.btn-office365 {
    width: 100%;
    background: #2f2f2f;
    color: #ffffff;
    gap: 12px;
    padding: 14px 18px;
    font-size: 1rem;
}

.btn-office365:hover {
    background: #1a1a1a;
    color: #ffffff;
}

.office365-icon {
    display: inline-flex;
    align-items: center;
}

.login-footnote {
    margin-top: 18px;
    font-size: 0.8rem;
    color: var(--text-light);
    text-align: center;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    height: 100%;
}

body.app-shell {
    background-color: var(--body-bg);
    color: var(--text-dark);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

aside.app-sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.logo-box {
    padding: 20px;
    background-color: #111827;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    font-size: 1.1rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: #0066cc;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}

aside.app-sidebar nav {
    flex-grow: 1;
    margin-top: 10px;
}

aside.app-sidebar nav a {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

aside.app-sidebar nav a:hover {
    background-color: var(--sidebar-active);
    color: #ffffff;
}

aside.app-sidebar nav a.active {
    background-color: var(--primary-blue);
    color: #ffffff;
    font-weight: 600;
}

.main-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header.app-header {
    background-color: var(--topbar-bg);
    height: 70px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    flex-shrink: 0;
}

.brand-header-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

.brand-logo-text {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.brand-subtext {
    font-size: 0.85rem;
    color: var(--success-green);
    font-weight: bold;
    border-left: 2px solid #cbd5e1;
    padding-left: 15px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.user-profile a {
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 600;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-dark);
    font-size: 0.85rem;
}

.content-container {
    padding: 30px;
    overflow-y: auto;
    flex-grow: 1;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.btn {
    padding: 10px 18px;
    border-radius: 6px;
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary { background-color: var(--primary-blue); color: white; }
.btn-success { background-color: var(--success-green); color: white; }
.btn-orange { background-color: var(--warning-orange); color: white; }
.btn-danger { background-color: #dc2626; color: white; }
.btn-gray { background-color: #7f8c8d; color: white; }
.btn-secondary { background-color: #e2e8f0; color: var(--text-dark); }

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 4px;
    margin-right: 5px;
}

.action-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
}

.pallet-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.pallet-detail-row {
    display: none;
}

.pallet-detail-row.is-open {
    display: table-row;
}

.load-row.is-expanded td {
    background: #f8fafc;
}

.pallet-detail-row > td {
    padding: 0;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

.pallet-detail-panel {
    padding: 16px 20px 20px;
}

.pallet-detail-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: #334155;
}

.pallet-empty {
    margin: 0;
    color: #64748b;
    font-size: 0.9rem;
}

.pallet-inner-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    font-size: 0.85rem;
}

.pallet-inner-table th,
.pallet-inner-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #e2e8f0;
}

.pallet-inner-table tr:last-child td {
    border-bottom: none;
}

.pallet-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

a.btn:hover { opacity: 0.92; color: inherit; }

.filter-row {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-control {
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 160px;
    background-color: #fff;
}

.table-responsive {
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

th {
    background-color: #f8fafc;
    padding: 14px 20px;
    font-weight: 600;
    color: var(--text-dark);
    border-bottom: 1px solid #e2e8f0;
}

td {
    padding: 14px 20px;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
    vertical-align: middle;
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    display: inline-block;
}

.badge-received { background-color: #fef3c7; color: #d97706; }
.badge-progress { background-color: #dbeafe; color: #2563eb; }
.badge-destroyed { background-color: #ffedd5; color: #ea580c; }
.badge-certified { background-color: #dcfce7; color: #16a34a; }

.form-grid {
    background: white;
    padding: 30px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}

.col-12 { grid-column: span 12; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }
.col-2 { grid-column: span 2; }

.form-grid label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.form-grid .form-control {
    width: 100%;
}

.searchable-select {
    position: relative;
}

.searchable-select-list {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    margin: 0;
    padding: 6px 0;
    list-style: none;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.searchable-select-list [role="option"] {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.searchable-select-list [role="option"]:hover,
.searchable-select-list [role="option"].is-active {
    background: #eff6ff;
}

.searchable-select-list [role="option"].is-selected {
    font-weight: 600;
}

.searchable-select-list [role="option"][hidden] {
    display: none;
}

.form-actions {
    grid-column: span 12;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 10px;
}

.item-builder-box {
    grid-column: span 12;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    padding: 20px;
    border-radius: 6px;
    margin-top: 10px;
}

.cert-container-exact {
    background: white;
    width: 8.5in;
    height: 11in;
    max-width: 8.5in;
    padding: 0.75in;
    margin: 0 auto 25px auto;
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    color: #000000;
    overflow: hidden;
}

@media print {
    .view-header,
    .alert-banner,
    .app-sidebar,
    .app-header {
        display: none !important;
    }

    .content-container {
        padding: 0 !important;
    }

    .cert-container-exact {
        margin: 0;
        box-shadow: none;
        width: 8.5in;
        height: 11in;
    }
}

.cert-exact-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
}

.cert-exact-logo-side {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cert-exact-logo-circle {
    width: 45px;
    height: 45px;
    background: #111827;
    color: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.3rem;
}

.cert-exact-logo-side h3 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 1px;
    line-height: 1;
}

.cert-exact-logo-side span {
    font-size: 0.7rem;
    display: block;
    color: var(--success-green);
    font-weight: bold;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.cert-exact-address-side {
    text-align: right;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #333;
}

.cert-exact-main-title {
    text-align: center;
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin: 10px 0 22px;
    text-transform: uppercase;
}

.cert-disclaimer-top {
    margin: 0 0 28px;
    font-size: 0.82rem;
    line-height: 1.55;
}

.cert-body-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px 48px;
    padding-top: 8px;
}

.cert-body-col {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.cert-meta-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.cert-exact-banner {
    background-color: var(--cod-teal);
    color: white;
    text-align: center;
    padding: 8px;
    font-weight: bold;
    font-size: 1.05rem;
    letter-spacing: 0.5px;
    margin-bottom: 15px;
}

.cert-exact-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 0 10px 25px 10px;
}

.cert-exact-field label {
    display: block;
    font-weight: 700;
    font-size: 0.92rem;
    margin-bottom: 6px;
    color: #000;
}

.cert-exact-field span {
    font-size: 0.92rem;
    color: #222;
    line-height: 1.45;
}

.cert-exact-legal-text {
    font-size: 0.82rem;
    line-height: 1.55;
    color: #111;
    text-align: justify;
    white-space: pre-line;
}

@media (max-width: 768px) {
    .cert-body-grid,
    .cert-meta-row {
        grid-template-columns: 1fr;
        gap: 22px;
    }
}

.pre-line {
    white-space: pre-line;
}

.settings-textarea {
    min-height: 140px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.45;
}

.field-hint {
    margin: 8px 0 0;
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 400;
}

.attachment-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.attachment-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
}

.attachment-card input {
    margin-top: 4px;
}

.attachment-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.attachment-card-body strong {
    color: var(--text-dark);
    font-size: 0.95rem;
}

.attachment-card-body span {
    color: #64748b;
    font-size: 0.82rem;
}

.attachment-thumb {
    margin-top: 6px;
    width: 100%;
    max-height: 140px;
    object-fit: contain;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: #f8fafc;
    cursor: zoom-in;
}

.attachment-thumb:hover {
    border-color: #93c5fd;
}

.attachments-loading {
    padding: 18px 4px;
    color: #64748b;
    font-size: 0.9rem;
}

.image-modal[hidden] {
    display: none !important;
}

.image-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.image-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
}

.image-modal-dialog {
    position: relative;
    z-index: 1;
    max-width: min(960px, 96vw);
    max-height: 92vh;
    background: white;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.image-modal-dialog img {
    display: block;
    max-width: 100%;
    max-height: calc(92vh - 48px);
    object-fit: contain;
    margin: 0 auto;
}

.image-modal-close {
    position: absolute;
    top: 8px;
    right: 12px;
    border: none;
    background: transparent;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    color: #334155;
}

body.modal-open {
    overflow: hidden;
}

.attachment-link {
    color: var(--primary-blue);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    width: fit-content;
}

.attachment-link:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .attachment-options {
        grid-template-columns: 1fr;
    }
}

.email-tag-container {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px;
    min-height: 42px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    background: #fff;
}

.email-tag {
    background: #e2e8f0;
    color: var(--text-dark);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.email-tag span {
    cursor: pointer;
    font-weight: bold;
    color: #ef4444;
}

.alert-banner {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 600;
}

.cod-controls {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    margin-bottom: 25px;
    display: flex;
    gap: 20px;
}

.cod-actions {
    background: white;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-builder-inputs {
    display: grid;
    grid-template-columns: repeat(5, 1fr) auto;
    gap: 10px;
    margin-bottom: 15px;
}

.remove-row {
    color: red;
    cursor: pointer;
    font-weight: bold;
}

@media (max-width: 900px) {
    aside.app-sidebar {
        width: 200px;
    }

    .brand-subtext {
        display: none;
    }

    .col-3, .col-6 {
        grid-column: span 12;
    }

    .item-builder-inputs {
        grid-template-columns: 1fr;
    }

    .cod-controls, .cod-actions {
        flex-direction: column;
    }
}
