/* ── Typography ─────────────────────────────────────────── */
body, input, select, textarea, button {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    background-color: #f5f5f5;
}

h1, h2, h3 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ── Content area ───────────────────────────────────────── */
#content_div {
    background-color: transparent;
    box-shadow: none;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    padding: 24px 25px 100px 25px;
}

/* ── Cards ──────────────────────────────────────────────── */
.modern-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 16px;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary,
.btn-primary[type="submit"],
.btn-primary[type="button"] {
    background-color: #ff6b00;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 8px 20px;
    font-size: 14px;
    cursor: pointer;
    -webkit-appearance: none;
}

.btn-primary:hover {
    background-color: #e05e00;
}

.btn-primary:disabled,
.btn-primary[disabled] {
    background-color: #fff;
    color: #ffb07a;
    border: 2px solid #ffb07a;
    cursor: not-allowed;
}

.btn-secondary,
.btn-secondary[type="submit"],
.btn-secondary[type="button"] {
    background-color: #fff;
    color: #111;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 20px;
    font-size: 14px;
    cursor: pointer;
    -webkit-appearance: none;
}

.btn-secondary:hover {
    background-color: #f5f5f5;
}

/* ── Form elements ──────────────────────────────────────── */
.modern-card input[type="text"],
.modern-card input[type="email"],
.modern-card input[type="password"],
.modern-card input[type="number"],
.modern-card textarea,
.modern-card select,
.modern-form input[type="text"],
.modern-form input[type="email"],
.modern-form input[type="number"],
.modern-form input[type="file"],
.modern-form select {
    border-radius: 4px;
    border: 1px solid #ddd;
    padding: 8px;
    margin: 4px 0;
}

.modern-card input[type="text"]:focus,
.modern-card input[type="email"]:focus,
.modern-card input[type="number"]:focus,
.modern-card textarea:focus,
.modern-card select:focus,
.modern-form input[type="text"]:focus,
.modern-form input[type="email"]:focus,
.modern-form input[type="number"]:focus,
.modern-form select:focus {
    outline: 2px solid #ff6b00;
    border-color: #ff6b00;
}

.modern-card input:read-only:not(.btn-primary):not(.btn-secondary),
.modern-form input:read-only:not(.btn-primary):not(.btn-secondary) {
    background-color: #f5f5f5;
}

/* ── Status badges ──────────────────────────────────────── */
.badge {
    display: inline-block;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    line-height: 1;
}

.badge-approved  { background: #e8f5e9; color: #2e7d32; }
.badge-pending   { background: #fff3e0; color: #e65100; }
.badge-cancelled { background: #ffebee; color: #c62828; }
.badge-draft     { background: #f5f5f5; color: #757575; border: 1px solid #e0e0e0; }
.badge-transit   { background: #e3f2fd; color: #1565c0; }

/* ── Modern callout (PPAP block) ────────────────────────── */
.modern-callout {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #ff6b00;
    border-radius: 4px;
    padding: 16px;
    font-size: 12px;
    line-height: 1.6;
    margin: 16px 0;
}

.modern-callout.unsigned {
    background: #fff8f8;
    border-left-color: #c62828;
}

.modern-callout .accepted-text {
    color: #2e7d32;
    font-weight: bold;
}

/* ── Header nav active state + logout ───────────────────── */
#menu li.nav-active > a {
    color: #ff6b00;
    border-bottom: 2px solid #ff6b00;
    padding-bottom: 3px;
}
#menu_container {
    display: flex;
    align-items: center;
}
a.nav-logout {
    margin-left: 20px;
    font-size: 13px;
    color: #ff6b00;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity 0.15s;
}
a.nav-logout:hover {
    opacity: 0.75;
}

/* ── Dashboard ──────────────────────────────────────────── */
.modern-dashboard {
    max-width: 900px;
    margin: 0 auto;
    padding-top: 8px;
}

.hero-banner {
    position: relative;
    background-image: url('/images/brawley_header_2.jpg');
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    overflow: hidden;
    padding: 48px 40px;
    margin-bottom: 20px;
    text-align: left;
}

.hero-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 0;
}

.hero-banner > * {
    position: relative;
    z-index: 1;
}

.hero-banner h2 {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 8px;
    text-align: left;
}

.hero-banner h2::after {
    content: '';
    display: block;
    width: 40px;
    height: 3px;
    background: #ff6b00;
    margin-top: 8px;
}

.hero-banner p {
    color: rgba(255, 255, 255, 0.75);
    font-size: 14px;
    margin: 0;
}

.modern-card-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.modern-action-card {
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.modern-action-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.modern-action-card .card-icon {
    font-size: 28px;
    color: #ff6b00;
    margin-bottom: 12px;
}

.modern-action-card .card-title {
    font-size: 18px;
    font-weight: bold;
    color: #111;
    margin-bottom: 6px;
}

.modern-action-card .card-desc {
    font-size: 13px;
    color: #62696c;
    margin-bottom: 16px;
    line-height: 1.5;
}

.modern-action-card .card-link {
    color: #ff6b00;
    text-decoration: none;
    font-weight: bold;
    font-size: 14px;
}

.modern-action-card .card-link:hover {
    text-decoration: underline;
}

/* ── PO List ─────────────────────────────────────────────── */
.modern-page-title {
    font-size: 22px;
    font-weight: bold;
    color: #111;
    margin: 0 0 16px 0;
    text-align: left;
}

.modern-search-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.modern-search-row label {
    display: block;
    font-size: 12px;
    color: #62696c;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.modern-search-row input[type="text"],
.modern-search-row select {
    border-radius: 4px;
    border: 1px solid #ddd;
    padding: 8px 10px;
    font-size: 14px;
    min-width: 140px;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.modern-table th {
    background: #f5f5f5;
    color: #62696c;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid #e0e0e0;
}

.modern-table td {
    padding: 11px 12px;
    border-bottom: 1px solid #f0f0f0;
    color: #111;
    vertical-align: middle;
}

.modern-table tr:nth-child(even) td {
    background: #fafafa;
}

.modern-table tr.record {
    cursor: pointer;
    transition: background 0.1s;
}

.modern-table tr.record:hover td {
    background: #fff7f2;
}

.modern-table tr.record:hover td:first-child {
    box-shadow: inset 3px 0 0 #ff6b00;
}

.modern-table tr.row-late td {
    background: #fff8f8 !important;
}

.modern-table tr.row-late:hover td:first-child {
    box-shadow: inset 3px 0 0 #c62828;
}

.modern-table .col-right {
    text-align: right;
}

.modern-table .col-center {
    text-align: center;
}

.modern-table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 4px 0;
    font-size: 13px;
    color: #62696c;
    flex-wrap: wrap;
    gap: 8px;
}

/* ── PO Detail ──────────────────────────────────────────── */
.page-breadcrumb {
    font-size: 13px;
    color: #62696c;
    margin-bottom: 8px;
}

.page-breadcrumb a {
    color: #ff6b00;
    text-decoration: none;
}

.page-breadcrumb a:hover {
    text-decoration: underline;
}

.page-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 8px;
}

.page-title-row h2 {
    margin: 0;
    font-size: 22px;
    color: #111;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
}

.po-info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.po-info-grid .modern-card {
    margin-bottom: 0;
}

.po-info-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.po-info-card-header .po-info-card-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.po-info-card-title {
    font-size: 11px;
    font-weight: 700;
    color: #62696c;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.po-info-card-body {
    font-size: 13px;
    line-height: 1.6;
    color: #333;
}

.conv-chip {
    display: inline-block;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    color: #111;
    cursor: pointer;
    margin: 2px 2px 2px 0;
    text-decoration: none;
}

.conv-chip:hover {
    background: #e8e8e8;
}

.modern-table .total-row td {
    font-weight: bold;
    font-size: 16px;
    color: #ff6b00;
    border-top: 2px solid #e0e0e0;
    border-bottom: none;
}

.modern-table .subtotal-row td,
.modern-table .shipping-row td,
.modern-table .tax-row td {
    background: #fff !important;
    color: #555;
    font-size: 13px;
    border-bottom: 1px solid #f5f5f5;
}

.action-panel {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.action-panel-section {
    flex: 1;
    min-width: 250px;
}

.action-panel-section h4 {
    font-size: 12px;
    font-weight: 700;
    color: #62696c;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.action-panel-section table td {
    padding: 4px 8px 4px 0;
    font-size: 13px;
    color: #555;
    vertical-align: middle;
}

.upload-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.upload-row > * {
    flex: 1;
}

.invoice-upload-box {
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 14px;
    background: #fafafa;
    transition: border-color 0.2s, background 0.2s;
}

.invoice-upload-box.upload-required {
    border-color: #c62828;
    background: #fff8f8;
}

.invoice-upload-box.file-selected {
    border-color: #2e7d32;
    background: #f0faf0;
}

.invoice-upload-box label {
    display: block;
    font-size: 12px;
    color: #62696c;
    font-weight: 600;
    margin-bottom: 4px;
}

.approve-btn-wrap {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
    text-align: right;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
    .po-info-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 840px) {
    .modern-card-row {
        grid-template-columns: 1fr;
    }
    .action-panel {
        flex-direction: column;
    }
    .modern-search-row {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 480px) {
    .po-info-grid {
        grid-template-columns: 1fr;
    }
}

/* ── KPI Cards ───────────────────────────────────────────── */
.kpi-row {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.kpi-card {
    flex: 1;
    text-align: center;
    padding: 16px 12px;
}

a.kpi-card.kpi-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: box-shadow 0.15s;
}

a.kpi-card.kpi-link:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.kpi-icon {
    font-size: 18px;
    color: #ff6b00;
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: #111;
    line-height: 1;
    margin-bottom: 4px;
}

.kpi-label {
    font-size: 11px;
    color: #62696c;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ── Tabs ────────────────────────────────────────────────── */
.tab-nav {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e0e0e0;
    margin: -16px -16px 16px;
    padding: 0 16px;
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #62696c;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.15s;
}

.tab-btn:hover {
    color: #111;
}

.tab-btn.active {
    color: #ff6b00;
    border-bottom-color: #ff6b00;
}

.tab-badge {
    background: #ff6b00;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.4;
}

.tab-panel {
    padding-top: 4px;
}

/* ── Additional Logins Page ──────────────────────────────── */
.logins-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.logins-table thead th {
    background: #f5f5f5;
    color: #62696c;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.logins-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
}

.logins-table tbody tr:last-child {
    border-bottom: none;
}

.logins-table tbody td {
    padding: 10px 12px;
    color: #111;
}

.logins-empty {
    color: #62696c;
    font-size: 14px;
    margin: 0;
    padding: 8px 0;
}

/* ── Clickable table rows ────────────────────────────────── */
.clickable-table tbody tr {
    cursor: pointer;
}
.clickable-table tbody tr:hover {
    background: #fff8f2;
}

/* ── Conversations list ──────────────────────────────────── */

/* ── Conversation detail ─────────────────────────────────── */
.conv-participant {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    background: #f5f5f5;
    font-size: 13px;
}
.conv-participant-me {
    background: #fff3e0;
    border: 1px solid #ffcc80;
}
.conv-participant-info {
    display: flex;
    flex-direction: column;
}
.conv-participant-name {
    font-weight: 600;
    color: #111;
}
.conv-participant-sub {
    font-size: 11px;
    color: #62696c;
    margin-top: 1px;
}
.conv-participant-type {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #62696c;
    background: #e0e0e0;
    padding: 2px 6px;
    border-radius: 10px;
}
.conv-participant-me .conv-participant-type {
    background: #ff6b00;
    color: #fff;
}

.conv-card {
    padding: 0;
    overflow: hidden;
}
.conv-messages {
    height: 420px;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
}
.conv-msg-wrap {
    display: flex;
    flex-direction: column;
    max-width: 72%;
}
.conv-msg-me {
    align-self: flex-end;
    align-items: flex-end;
}
.conv-msg-other {
    align-self: flex-start;
    align-items: flex-start;
}
.conv-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
}
.conv-bubble-me {
    background: #ff6b00;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.conv-bubble-other {
    background: #e8e8e8;
    color: #111;
    border-bottom-left-radius: 4px;
}
.conv-meta {
    margin-top: 3px;
    font-size: 11px;
    color: #999;
}
.conv-sender {
    font-weight: 600;
}
.conv-time {
    color: #aaa;
}
.conv-translated-hint {
    font-size: 11px;
    color: #aaa;
    margin: 2px 4px 4px;
}
.conv-translate-toggle {
    color: #ff6b00;
    cursor: pointer;
    text-decoration: none;
    background: none;
    border: none;
    font-size: 11px;
    padding: 0;
}
.conv-translate-toggle:hover { text-decoration: underline; }
.conv-compose {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}
.conv-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 38px;
    max-height: 160px;
    overflow-y: hidden;
    line-height: 1.45;
    outline: none;
    transition: border-color 0.15s;
}
.conv-input:focus {
    border-color: #ff6b00;
}
.conv-send-btn {
    flex-shrink: 0;
    padding: 8px 20px;
    border-radius: 20px;
}
.conv-attach {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
}
.conv-file-input {
    font-size: 13px;
    flex: 1;
}
.conv-attach-hint {
    font-size: 11px;
    color: #aaa;
}

/* ── Part Modal ──────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 9000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open {
    display: flex;
}
.modal-container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.22);
    width: 92%;
    max-width: 780px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
}
.modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #111;
}
.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: #62696c;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
.modal-close:hover { color: #111; }
.modal-body {
    overflow-y: auto;
    padding: 20px;
    flex: 1;
}
.modal-loading {
    text-align: center;
    padding: 40px;
    color: #62696c;
    font-size: 14px;
}
.modal-section {
    margin-bottom: 20px;
}
.modal-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #62696c;
    margin-bottom: 10px;
}
.modal-details-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.modal-details-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
}
.modal-details-table td:first-child {
    color: #62696c;
    width: 38%;
    font-size: 12px;
}
.modal-images {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.modal-img {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    transition: box-shadow 0.15s;
}
.modal-img:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.18); }
.modal-doc-link {
    display: block;
    margin-bottom: 4px;
    color: #ff6b00;
    font-size: 14px;
    text-decoration: none;
}
.modal-doc-link:hover { text-decoration: underline; }

/* ── Part thumbnail in line items ────────────────────────── */
.part-thumb {
    width: 52px;
    height: 40px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    display: block;
}
.part-thumb-placeholder {
    width: 52px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    border: 1px solid #e8e8e8;
    background: #f5f5f5;
    color: #ccc;
    font-size: 18px;
    cursor: pointer;
}
.part-thumb-cell {
    width: 62px;
    text-align: center;
    vertical-align: middle;
}

/* ── Language switcher ──────────────────────────────────── */
.lang-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
}
.lang-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
    transition: box-shadow 0.15s;
}
.lang-btn:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}
.lang-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 148px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.13);
    z-index: 1000;
    overflow: hidden;
}
.lang-dropdown.open { display: block; }
.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}
.lang-option:hover { background: #f5f5f5; }
.lang-option.active {
    border-left: 3px solid #ff6b00;
    padding-left: 11px;
    font-weight: 600;
}
.lang-flag-img { width: 22px; height: 22px; display: block; object-fit: cover; border-radius: 2px; }
.lang-btn .lang-flag-img,
.mobile-lang-flag-btn .lang-flag-img { width: 100%; height: 100%; border-radius: 0; }
.mobile-lang-row {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
}
.mobile-lang-flag-btn {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}
.mobile-lang-flag-btn.active { border-color: #ff6b00; box-shadow: 0 0 0 2px #ff6b0033; }
