:root {
    --navy: #102b45;
    --navy-2: #173b5d;
    --blue: #2f5597;
    --blue-2: #1876bd;
    --cyan: #29a6d8;
    --green: #43a856;
    --green-soft: #e7f5ea;
    --ink: #17283d;
    --muted: #667a91;
    --line: #dbe5ef;
    --soft: #f1f5f9;
    --white: #fff;
    --danger: #c43d4b;
    --warning: #b96b0a;
    --shadow: 0 12px 32px rgba(24, 53, 83, .10);
    --radius: 14px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #edf2f7; font-size: 16px; }
body { margin: 0; min-height: 100%; color: var(--ink); font-family: Inter, "Noto Sans Arabic", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.6; }
body.ap-modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(41,166,216,.27); outline-offset: 2px; }

.ap-primary-button, .ap-secondary-button, .ap-danger-button {
    display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 17px;
    border-radius: 9px; border: 1px solid transparent; font-size: 13px; font-weight: 800; transition: .18s ease;
}
.ap-primary-button { color: #fff; background: var(--blue); box-shadow: 0 6px 16px rgba(47,85,151,.20); }
.ap-primary-button:hover { background: #24487f; transform: translateY(-1px); }
.ap-secondary-button { color: var(--blue); background: #fff; border-color: #cdd9e6; }
.ap-secondary-button:hover { border-color: var(--blue); background: #f5f8fc; }
.ap-danger-button { color: #fff; background: var(--danger); }
.ap-icon-button { width: 39px; height: 39px; border: 1px solid var(--line); border-radius: 9px; color: #536a82; background: #fff; font-size: 19px; }
.ap-icon-button:hover { color: var(--blue); border-color: #9fb6ce; }
.ap-link-button { padding: 0; border: 0; color: var(--blue-2); background: transparent; font-size: 12px; font-weight: 800; }
.ap-link-button:hover { text-decoration: underline; }

/* Login */
.ap-login-body { background: #edf2f7; }
.ap-login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr); }
.ap-login-story {
    position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: clamp(48px, 8vw, 110px);
    color: #fff; background: radial-gradient(circle at 77% 20%, rgba(41,166,216,.30), transparent 28%), linear-gradient(145deg, #0c2944, #173f61 62%, #164663);
}
.ap-login-story::before, .ap-login-story::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.09); }
.ap-login-story::before { width: 520px; height: 520px; right: -210px; bottom: -170px; }
.ap-login-story::after { width: 340px; height: 340px; right: -120px; bottom: -80px; }
.ap-back-link { position: absolute; top: 34px; left: clamp(34px, 6vw, 84px); color: #d8ecfa; text-decoration: none; font-size: 12px; font-weight: 800; }
.ap-back-link:hover { color: #fff; }
.ap-login-eyebrow { display: flex; align-items: center; gap: 10px; color: #9fd8f0; font-size: 11px; font-weight: 900; letter-spacing: .18em; text-transform: uppercase; }
.ap-login-eyebrow span { width: 34px; height: 2px; background: var(--green); }
.ap-login-story h1 { max-width: 760px; margin: 22px 0 22px; font-size: clamp(42px, 5.2vw, 78px); line-height: .98; letter-spacing: -.045em; }
.ap-login-story h1 strong { color: #6ed17a; font-weight: 900; }
.ap-login-story > p { max-width: 650px; margin: 0; color: #d5e4f0; font-size: 16px; line-height: 1.75; }
.ap-login-feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 720px; margin-top: 42px; }
.ap-login-feature-grid article { min-height: 104px; padding: 16px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); backdrop-filter: blur(8px); }
.ap-login-feature-grid b { display: block; color: #78d3f3; font-size: 11px; letter-spacing: .12em; }
.ap-login-feature-grid span { display: block; margin-top: 17px; font-size: 12px; font-weight: 800; line-height: 1.45; }
.ap-login-story .ap-made-by { position: relative; z-index: 1; margin-top: 30px; color: #a9bfd0; font-size: 11px; }
.ap-login-story .ap-made-by strong { color: #fff; }
.ap-login-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(36px, 6vw, 90px); background: #fff; }
.ap-logo-ribbon { display: flex; align-items: center; gap: 7px; min-width: 0; }
.ap-logo-ribbon > div { display: flex; align-items: center; justify-content: center; width: 112px; height: 48px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.ap-logo-ribbon img { display: block; max-width: 88%; max-height: 37px; object-fit: contain; }
.ap-logo-ribbon-login { width: 100%; gap: 10px; margin-bottom: 36px; }
.ap-logo-ribbon-login > div { flex: 1; height: 70px; }
.ap-logo-ribbon-login img { max-height: 54px; }
.ap-login-heading { display: flex; gap: 13px; align-items: flex-start; }
.ap-secure-dot { flex: 0 0 auto; width: 11px; height: 11px; margin-top: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 6px var(--green-soft); }
.ap-login-heading h2 { margin: 0; font-size: 25px; }
.ap-login-heading p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.ap-alert { margin-top: 20px; padding: 12px 14px; border-radius: 9px; font-size: 12px; font-weight: 700; }
.ap-alert-error { color: #8c2732; border: 1px solid #f2c4ca; background: #fff1f2; }
.ap-alert-success { color: #246c32; border: 1px solid #bfe4c6; background: #effaf1; }
.ap-login-form { display: grid; gap: 18px; margin-top: 28px; }
.ap-login-form label, .ap-field { display: grid; gap: 7px; }
.ap-login-form label > span, .ap-field > span, .ap-cart-notes > span { color: #425a73; font-size: 11px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.ap-login-form input, .ap-login-form select, .ap-field input, .ap-field select, .ap-field textarea, .ap-cart-notes textarea {
    width: 100%; min-height: 47px; padding: 10px 12px; border: 1px solid #cdd9e6; border-radius: 9px; color: var(--ink); background: #fff;
}
.ap-login-form input:focus, .ap-login-form select:focus, .ap-field input:focus, .ap-field select:focus, .ap-field textarea:focus { border-color: var(--blue-2); }
.ap-login-form small { color: var(--danger); }
.ap-login-button { min-height: 50px; justify-content: space-between; margin-top: 3px; }
.ap-login-security { display: flex; gap: 9px; margin-top: 23px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.5; }
.ap-login-security span { color: var(--green); }

/* App shell */
.ap-app-body { overflow: hidden; background: #eef3f8; }
.ap-shell { display: grid; grid-template-columns: 246px minmax(0, 1fr); min-height: 100vh; }
.ap-sidebar { position: relative; z-index: 30; display: flex; flex-direction: column; min-height: 100vh; padding: 22px 16px; color: #dce8f2; background: linear-gradient(180deg, #102b45, #0d243a); box-shadow: 6px 0 22px rgba(16,43,69,.12); }
.ap-sidebar-brand { display: flex; align-items: center; gap: 12px; min-height: 55px; padding: 0 7px 21px; border-bottom: 1px solid rgba(255,255,255,.09); }
.ap-sidebar-mark { display: grid; width: 43px; height: 43px; place-items: center; border-radius: 10px; color: #fff; background: linear-gradient(145deg, var(--blue-2), var(--cyan)); font-size: 15px; font-weight: 900; box-shadow: 0 7px 18px rgba(16,118,189,.35); }
.ap-sidebar-brand strong, .ap-sidebar-brand small { display: block; }
.ap-sidebar-brand strong { color: #fff; font-size: 14px; }
.ap-sidebar-brand small { margin-top: 3px; color: #8eabc2; font-size: 10px; text-transform: uppercase; letter-spacing: .11em; }
.ap-nav { display: grid; gap: 5px; margin-top: 24px; }
.ap-nav button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 45px; padding: 0 13px; border: 0; border-radius: 8px; color: #b9cbda; background: transparent; text-align: left; font-size: 12px; font-weight: 700; transition: .16s; }
.ap-nav button span { width: 20px; color: #84acc7; text-align: center; font-size: 18px; }
.ap-nav button:hover { color: #fff; background: rgba(255,255,255,.07); }
.ap-nav button.is-active { color: #fff; background: var(--blue-2); box-shadow: 0 6px 15px rgba(0,0,0,.16); }
.ap-nav button.is-active span { color: #fff; }
.ap-sidebar-source { display: grid; gap: 5px; margin-top: auto; padding: 14px; border: 1px solid rgba(122,209,243,.18); border-radius: 10px; background: rgba(41,166,216,.08); }
.ap-sidebar-source small { color: #74c9e8; text-transform: uppercase; letter-spacing: .12em; font-size: 8px; font-weight: 900; }
.ap-sidebar-source strong { color: #fff; font-size: 11px; line-height: 1.45; }
.ap-sidebar-source span { color: #91aabc; font-size: 9px; }
.ap-sidebar-footer { display: grid; gap: 3px; margin-top: 13px; padding: 13px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.ap-sidebar-footer strong { color: #d9e5ef; font-size: 10px; }
.ap-sidebar-footer span { color: #7f9bb1; font-size: 9px; }
.ap-sidebar-footer a { margin-top: 8px; color: #78cce9; font-size: 9px; font-weight: 800; text-decoration: none; }
.ap-workspace { min-width: 0; height: 100vh; overflow: auto; }
.ap-topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 74px; padding: 11px 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.ap-topbar-actions { display: flex; align-items: center; gap: 9px; }
.ap-mobile-menu { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.ap-cart-button { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 13px; border: 1px solid #cdd9e6; border-radius: 8px; color: var(--blue); background: #fff; font-size: 11px; font-weight: 900; }
.ap-cart-button span { display: grid; min-width: 21px; height: 21px; place-items: center; border-radius: 11px; color: #fff; background: var(--green); font-size: 10px; }
.ap-user-chip { display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 4px 9px 4px 4px; border: 1px solid var(--line); border-radius: 9px; background: #fff; text-align: left; }
.ap-user-chip > span { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 7px; color: #fff; background: var(--blue); font-size: 12px; font-weight: 900; }
.ap-user-chip strong, .ap-user-chip small { display: block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-user-chip strong { font-size: 10px; }
.ap-user-chip small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.ap-password-banner { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 10px 24px; color: #6c4306; border-bottom: 1px solid #f1d39c; background: #fff6e5; font-size: 11px; font-weight: 700; }
.ap-password-banner button { border: 0; color: #7f4c00; background: transparent; font-size: 10px; font-weight: 900; text-decoration: underline; }
.ap-content { max-width: 1720px; min-height: calc(100vh - 74px); margin: 0 auto; padding: 25px; }

/* Content */
.ap-loading-state { display: grid; min-height: 430px; place-items: center; align-content: center; gap: 13px; color: var(--muted); font-size: 12px; }
.ap-loading-state span { width: 35px; height: 35px; border: 4px solid #d9e5ef; border-top-color: var(--blue-2); border-radius: 50%; animation: ap-spin .75s linear infinite; }
@keyframes ap-spin { to { transform: rotate(360deg); } }
.ap-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.ap-page-header small { color: var(--blue-2); font-size: 9px; font-weight: 900; letter-spacing: .15em; text-transform: uppercase; }
.ap-page-header h1 { margin: 5px 0 0; color: #14283e; font-size: clamp(23px, 2.4vw, 34px); letter-spacing: -.025em; }
.ap-page-header p { max-width: 670px; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.ap-filter-bar { display: grid; grid-template-columns: 1.2fr 1fr 1fr minmax(250px, 2fr) auto; gap: 10px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.ap-filter-bar label { display: grid; gap: 5px; }
.ap-filter-bar label span { color: #5c7187; font-size: 8px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.ap-filter-bar select, .ap-filter-bar input { width: 100%; height: 39px; padding: 0 10px; border: 1px solid #cfdbe7; border-radius: 7px; color: var(--ink); background: #fff; font-size: 11px; }
.ap-filter-bar button { align-self: end; min-height: 39px; }
.ap-metric-grid { display: grid; grid-template-columns: repeat(6, minmax(125px, 1fr)); gap: 11px; margin: 17px 0; }
.ap-metric-card { position: relative; overflow: hidden; min-height: 105px; padding: 15px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: 0 6px 18px rgba(24,53,83,.06); }
.ap-metric-card::after { content: ""; position: absolute; right: -18px; bottom: -29px; width: 70px; height: 70px; border-radius: 50%; background: rgba(47,85,151,.06); }
.ap-metric-card small { display: block; color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.ap-metric-card strong { display: block; margin-top: 15px; color: var(--navy); font-size: 27px; line-height: 1; }
.ap-metric-card span { display: block; margin-top: 8px; color: #7b8ea1; font-size: 8px; }
.ap-metric-card.is-green { border-top: 4px solid var(--green); }
.ap-metric-card.is-blue { border-top: 4px solid var(--blue-2); }
.ap-metric-card.is-cyan { border-top: 4px solid var(--cyan); }
.ap-metric-card.is-navy { border-top: 4px solid var(--navy); }
.ap-dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(310px, .5fr); gap: 14px; }
.ap-panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.ap-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 55px; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.ap-panel-header h2 { margin: 0; font-size: 14px; }
.ap-panel-header p { margin: 4px 0 0; color: var(--muted); font-size: 9px; }
.ap-panel-body { padding: 15px; }
.ap-coverage { display: grid; grid-template-columns: 128px 1fr; gap: 20px; align-items: center; }
.ap-donut { --coverage: 0; display: grid; width: 120px; height: 120px; place-items: center; border-radius: 50%; background: conic-gradient(var(--green) calc(var(--coverage) * 1%), #e5edf4 0); }
.ap-donut::before { content: ""; grid-area: 1/1; width: 82px; height: 82px; border-radius: 50%; background: #fff; }
.ap-donut strong, .ap-donut span { position: relative; z-index: 1; grid-area: 1/1; text-align: center; }
.ap-donut strong { margin-top: -11px; font-size: 21px; }
.ap-donut span { margin-top: 26px; color: var(--muted); font-size: 8px; font-weight: 800; }
.ap-bar-list { display: grid; gap: 12px; }
.ap-bar-row { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(130px, 3fr) 34px; gap: 8px; align-items: center; font-size: 9px; }
.ap-bar-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.ap-bar-track { height: 8px; overflow: hidden; border-radius: 4px; background: #e8eef4; }
.ap-bar-track i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.ap-bar-row b { color: var(--muted); text-align: right; }
.ap-table-wrap { width: 100%; overflow: auto; }
.ap-data-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.ap-data-table th { padding: 10px 11px; color: #60758a; border-bottom: 1px solid var(--line); background: #f5f8fb; text-align: left; font-size: 8px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
.ap-data-table td { padding: 11px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
.ap-data-table tbody tr:hover td { background: #f7fafd; }
.ap-data-table tr:last-child td { border-bottom: 0; }
.ap-table-primary { display: block; color: var(--ink); font-size: 10px; font-weight: 900; }
.ap-table-secondary { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.ap-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 11px; color: #415971; background: #eaf0f5; font-size: 8px; font-weight: 900; text-transform: uppercase; }
.ap-badge.is-success, .ap-badge.is-approved, .ap-badge.is-fulfilled { color: #226d31; background: #e1f4e4; }
.ap-badge.is-warning, .ap-badge.is-submitted, .ap-badge.is-reviewed { color: #8a5505; background: #fff0d5; }
.ap-badge.is-ordered { color: #235f91; background: #e2f1fc; }
.ap-badge.is-rejected { color: #922f3a; background: #ffe7ea; }
.ap-empty-state { display: grid; min-height: 210px; place-items: center; align-content: center; padding: 26px; color: var(--muted); text-align: center; }
.ap-empty-state b { color: var(--ink); font-size: 14px; }
.ap-empty-state p { max-width: 430px; margin: 8px 0 0; font-size: 10px; line-height: 1.55; }

/* Explorer */
.ap-explorer-grid { display: grid; grid-template-columns: minmax(280px, .42fr) minmax(0, 1.58fr); gap: 14px; }
.ap-unit-list { max-height: calc(100vh - 220px); overflow: auto; }
.ap-unit-card { display: grid; width: 100%; gap: 4px; padding: 12px 14px; border: 0; border-bottom: 1px solid #e7edf3; background: #fff; text-align: left; }
.ap-unit-card:hover { background: #f3f8fc; }
.ap-unit-card.is-active { border-left: 4px solid var(--blue-2); background: #edf6fc; }
.ap-unit-card strong { color: #16324e; font-size: 11px; }
.ap-unit-card span { color: var(--muted); font-size: 9px; }
.ap-unit-card small { display: flex; gap: 7px; margin-top: 4px; color: #57738c; font-size: 8px; }
.ap-explorer-main { min-width: 0; }
.ap-unit-hero { display: flex; justify-content: space-between; gap: 20px; padding: 16px; border-bottom: 1px solid var(--line); background: linear-gradient(100deg, #f4f9fd, #fff); }
.ap-unit-hero small { color: var(--blue-2); font-size: 8px; font-weight: 900; text-transform: uppercase; }
.ap-unit-hero h2 { margin: 4px 0 0; font-size: 20px; }
.ap-unit-hero p { margin: 5px 0 0; color: var(--muted); font-size: 9px; }
.ap-unit-facts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ap-unit-facts span { min-width: 85px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.ap-unit-facts b, .ap-unit-facts small { display: block; }
.ap-unit-facts b { margin-top: 3px; color: var(--ink); font-size: 9px; }
.ap-unit-tabs { display: flex; gap: 4px; overflow: auto; padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fff; }
.ap-unit-tabs button { min-height: 32px; padding: 0 12px; border: 1px solid #d5e0ea; border-radius: 7px; color: #536c83; background: #fff; font-size: 9px; font-weight: 800; white-space: nowrap; }
.ap-unit-tabs button.is-active { color: #fff; border-color: var(--blue); background: var(--blue); }
.ap-diagram-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .55fr); min-height: 590px; }
.ap-diagram-column { min-width: 0; border-right: 1px solid var(--line); background: #e5ebf0; }
.ap-diagram-toolbar { display: flex; justify-content: space-between; gap: 10px; min-height: 43px; padding: 7px 10px; border-bottom: 1px solid #ced8e2; background: #f7fafc; }
.ap-diagram-toolbar span { align-self: center; color: #5e7388; font-size: 9px; font-weight: 800; }
.ap-diagram-toolbar div { display: flex; gap: 5px; }
.ap-diagram-toolbar button { min-width: 32px; height: 29px; border: 1px solid #cbd7e2; border-radius: 6px; background: #fff; font-size: 11px; font-weight: 800; }
.ap-diagram-scroll { height: 545px; overflow: auto; padding: 14px; }
.ap-diagram-stage { position: relative; width: max(100%, 900px); transform-origin: top left; background: #fff; box-shadow: 0 8px 24px rgba(23,50,77,.16); }
.ap-diagram-stage img { display: block; width: 100%; height: auto; user-select: none; }
.ap-hotspot { position: absolute; display: grid; min-width: 22px; height: 22px; padding: 0 5px; transform: translate(-50%, -50%); place-items: center; border: 2px solid #fff; border-radius: 12px; color: #fff; background: rgba(47,85,151,.88); box-shadow: 0 2px 7px rgba(16,43,69,.35); font-size: 8px; font-weight: 900; }
.ap-hotspot:hover, .ap-hotspot.is-active { z-index: 3; background: var(--green); transform: translate(-50%, -50%) scale(1.22); }
.ap-parts-panel { min-width: 0; background: #fff; }
.ap-part-search { padding: 10px; border-bottom: 1px solid var(--line); }
.ap-part-search input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid #ccd9e5; border-radius: 7px; font-size: 10px; }
.ap-parts-list { max-height: 497px; overflow: auto; }
.ap-part-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 10px; border-bottom: 1px solid #edf1f5; }
.ap-part-row.is-active { border-left: 4px solid var(--green); background: #eff9f1; }
.ap-part-item-no { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 7px; color: var(--blue); background: #eaf2fb; font-size: 9px; font-weight: 900; }
.ap-part-row strong, .ap-part-row span, .ap-part-row small { display: block; }
.ap-part-row strong { font-size: 9px; }
.ap-part-row span { margin-top: 3px; color: #38536e; font-size: 9px; line-height: 1.35; }
.ap-part-row small { margin-top: 4px; color: var(--muted); font-size: 8px; }
.ap-add-part { width: 30px; height: 30px; border: 1px solid #b8d7c0; border-radius: 7px; color: #28783a; background: #ebf8ee; font-size: 18px; }
.ap-add-part:hover { color: #fff; background: var(--green); }

/* Drawer, modal, toast */
.ap-cart-drawer { position: fixed; z-index: 70; top: 0; right: 0; display: flex; flex-direction: column; width: min(450px, 94vw); height: 100vh; transform: translateX(105%); border-left: 1px solid var(--line); background: #fff; box-shadow: -18px 0 45px rgba(13,36,58,.22); transition: transform .23s ease; }
.ap-cart-drawer.is-open { transform: translateX(0); }
.ap-drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 19px; color: #fff; background: var(--navy); }
.ap-drawer-header small { color: #8fd2ea; font-size: 8px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.ap-drawer-header h2 { margin: 3px 0 0; font-size: 18px; }
.ap-drawer-header .ap-icon-button { color: #fff; border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.08); }
.ap-drawer-unit { padding: 11px 18px; color: #48627b; border-bottom: 1px solid var(--line); background: #f5f8fb; font-size: 10px; font-weight: 800; }
.ap-cart-lines { flex: 1; overflow: auto; padding: 12px 17px; }
.ap-cart-line { display: grid; grid-template-columns: minmax(0,1fr) 70px 28px; gap: 8px; align-items: center; padding: 11px 0; border-bottom: 1px solid #e7edf3; }
.ap-cart-line strong, .ap-cart-line span { display: block; }
.ap-cart-line strong { font-size: 9px; }
.ap-cart-line span { margin-top: 4px; color: var(--muted); font-size: 8px; }
.ap-cart-line input { width: 100%; height: 32px; padding: 0 7px; border: 1px solid #cbd8e4; border-radius: 6px; text-align: center; font-size: 9px; }
.ap-cart-line button { width: 27px; height: 27px; border: 0; border-radius: 6px; color: var(--danger); background: #fff0f2; }
.ap-cart-notes { display: grid; gap: 7px; padding: 12px 17px; border-top: 1px solid var(--line); }
.ap-cart-notes textarea { min-height: 70px; resize: vertical; font-size: 10px; }
.ap-drawer-footer { display: grid; grid-template-columns: .7fr 1.3fr; gap: 8px; padding: 14px 17px; border-top: 1px solid var(--line); }
.ap-overlay { position: fixed; z-index: 60; inset: 0; background: rgba(8,27,44,.54); backdrop-filter: blur(2px); }
.ap-modal-root { position: fixed; z-index: 90; inset: 0; display: none; align-items: center; justify-content: center; padding: clamp(8px, 2vw, 20px); pointer-events: none; }
.ap-modal-root.is-open { display: flex; pointer-events: auto; }
.ap-modal { display: flex; width: min(680px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 28px 70px rgba(9,31,50,.35); }
.ap-modal.is-wide { width: min(1120px, calc(100vw - 32px)); }
.ap-modal.is-document { width: min(1500px, calc(100vw - 24px)); height: calc(100dvh - 24px); max-height: calc(100dvh - 24px); }
.ap-modal-header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; padding: 16px 22px; border-bottom: 1px solid var(--line); background: #fff; }
.ap-modal-header h2 { margin: 0; font-size: 18px; font-weight: 700; }
.ap-modal-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.ap-modal-header small { display: block; margin-bottom: 3px; color: var(--blue-2); font-size: 11px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.ap-window-header-actions { display: flex; align-items: center; gap: 9px; }
.ap-modal-body { min-width: 0; min-height: 0; flex: 1 1 auto; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: 22px; }
.ap-modal-body.ap-modal-body-flush { padding: 0; }
.ap-modal-actions { display: flex; flex: 0 0 auto; justify-content: flex-end; gap: 9px; padding: 13px 22px; border-top: 1px solid var(--line); background: #f7fafc; }
.ap-modal.is-document .ap-explorer-grid { height: 100%; grid-template-columns: minmax(290px, .35fr) minmax(0, 1.65fr); gap: 0; }
.ap-modal.is-document .ap-explorer-grid > .ap-panel { height: 100%; overflow: hidden; border-width: 0 1px 0 0; border-radius: 0; box-shadow: none; }
.ap-modal.is-document .ap-explorer-main { overflow: auto; border: 0; }
.ap-modal.is-document .ap-unit-list { max-height: calc(100dvh - 295px); }
.ap-report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ap-report-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; min-height: 270px; padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(145deg, #fff, #f5f9fc); }
.ap-report-card > div { min-width: 0; }
.ap-report-icon { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 10px; color: #fff; background: var(--blue); font-size: 24px; box-shadow: 0 8px 20px rgba(47,85,151,.2); }
.ap-report-icon.is-green { background: var(--green); }
.ap-report-card small { color: var(--blue-2); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.ap-report-card h3 { margin: 5px 0 8px; font-size: 19px; }
.ap-report-card p { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.ap-report-card .ap-field { margin-top: 13px; }
.ap-report-actions { grid-column: 1 / -1; display: flex; align-self: end; justify-content: flex-end; gap: 9px; padding-top: 14px; border-top: 1px solid var(--line); }
.ap-report-actions a { text-decoration: none; }
.ap-report-note { display: grid; gap: 3px; margin-top: 16px; padding: 14px 16px; border-left: 4px solid var(--green); background: #eef8f0; font-size: 13px; }
.ap-report-note span { color: var(--muted); }
.ap-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.ap-form-grid .is-full { grid-column: 1 / -1; }
.ap-field textarea { min-height: 86px; resize: vertical; }
.ap-toast-root { position: fixed; z-index: 110; right: 19px; bottom: 19px; display: grid; gap: 8px; width: min(360px, calc(100vw - 38px)); }
.ap-toast { padding: 13px 15px; color: #fff; border-radius: 9px; background: var(--navy); box-shadow: 0 10px 28px rgba(10,31,49,.28); font-size: 10px; font-weight: 800; animation: ap-toast-in .2s ease; }
.ap-toast.is-error { background: #9f3340; }
.ap-toast.is-success { background: #28793a; }
@keyframes ap-toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Match the established SDN application typography and readable sizing. */
.ap-workspace { font-size: 14px; }
.ap-nav button { font-size: 14px; }
.ap-sidebar-brand strong { font-size: 15px; }
.ap-sidebar-brand small, .ap-sidebar-footer strong { font-size: 11px; }
.ap-sidebar-source small, .ap-sidebar-footer span, .ap-sidebar-footer a { font-size: 10px; }
.ap-sidebar-source strong { font-size: 12px; }
.ap-user-chip strong { font-size: 13px; }
.ap-user-chip small { font-size: 11px; }
.ap-password-banner { font-size: 13px; }
.ap-password-banner button { font-size: 12px; }
.ap-page-header small { font-size: 11px; }
.ap-page-header h1 { font-size: clamp(28px, 2.4vw, 36px); }
.ap-page-header p { font-size: 14px; }
.ap-filter-bar label span, .ap-metric-card small { font-size: 12px; }
.ap-filter-bar select, .ap-filter-bar input { font-size: 13px; }
.ap-metric-card strong { font-size: 30px; }
.ap-metric-card span { font-size: 11px; }
.ap-panel-header h2 { font-size: 16px; }
.ap-panel-header p { font-size: 12px; }
.ap-donut span { font-size: 11px; }
.ap-bar-row { font-size: 12px; }
.ap-data-table { font-size: 13px; }
.ap-data-table th { font-size: 11px; }
.ap-table-primary { font-size: 13px; }
.ap-table-secondary { font-size: 11px; }
.ap-badge { min-height: 24px; font-size: 11px; }
.ap-empty-state b { font-size: 16px; }
.ap-empty-state p { font-size: 13px; }
.ap-unit-card strong { font-size: 14px; }
.ap-unit-card span { font-size: 12px; }
.ap-unit-card small { font-size: 11px; }
.ap-unit-hero small { font-size: 10px; }
.ap-unit-hero h2 { font-size: 22px; }
.ap-unit-hero p, .ap-unit-facts b, .ap-unit-tabs button, .ap-diagram-toolbar span { font-size: 12px; }
.ap-part-search input { font-size: 13px; }
.ap-part-search > div { font-size: 11px !important; }
.ap-part-row strong, .ap-part-row span { font-size: 12px; }
.ap-part-row small { font-size: 10px; }
.ap-part-item-no { font-size: 11px; }
.ap-cart-line strong { font-size: 13px; }
.ap-cart-line span, .ap-drawer-unit { font-size: 12px; }
.ap-cart-line input, .ap-cart-notes textarea { font-size: 13px; }
.ap-login-form label > span, .ap-field > span, .ap-cart-notes > span { font-size: 12px; }
.ap-login-form input, .ap-login-form select, .ap-field input, .ap-field select, .ap-field textarea { font-size: 13px; }
.ap-toast { font-size: 13px; }

@media (max-width: 1250px) {
    .ap-metric-grid { grid-template-columns: repeat(3, 1fr); }
    .ap-filter-bar { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .ap-filter-bar label:last-of-type { grid-column: 1 / -1; }
    .ap-filter-bar button { grid-column: 1 / -1; }
    .ap-diagram-layout { grid-template-columns: 1fr; }
    .ap-diagram-column { border-right: 0; border-bottom: 1px solid var(--line); }
    .ap-diagram-scroll { height: 480px; }
    .ap-parts-list { max-height: 380px; }
}

@media (max-width: 900px) {
    .ap-login-layout { grid-template-columns: 1fr; }
    .ap-login-story { min-height: 580px; padding: 70px 34px 46px; }
    .ap-login-panel { padding: 45px 28px; }
    .ap-shell { grid-template-columns: 1fr; }
    .ap-sidebar { position: fixed; inset: 0 auto 0 0; width: 246px; transform: translateX(-105%); transition: transform .2s; }
    .ap-sidebar.is-open { transform: translateX(0); }
    .ap-mobile-menu { display: block; }
    .ap-topbar { padding: 10px 14px; }
    .ap-topbar .ap-logo-ribbon { display: none; }
    .ap-content { padding: 16px; }
    .ap-dashboard-grid, .ap-explorer-grid { grid-template-columns: 1fr; }
    .ap-unit-list { max-height: 310px; }
    .ap-user-chip div { display: none; }
}

@media (max-width: 620px) {
    .ap-login-story h1 { font-size: 43px; }
    .ap-login-feature-grid { grid-template-columns: 1fr; }
    .ap-login-feature-grid article { min-height: 76px; }
    .ap-logo-ribbon-login { align-items: stretch; }
    .ap-logo-ribbon-login > div { height: 56px; }
    .ap-topbar-actions { gap: 5px; }
    .ap-cart-button { padding: 0 8px; }
    .ap-page-header { align-items: flex-start; flex-direction: column; }
    .ap-filter-bar { grid-template-columns: 1fr; }
    .ap-filter-bar label:last-of-type, .ap-filter-bar button { grid-column: auto; }
    .ap-metric-grid { grid-template-columns: repeat(2, 1fr); }
    .ap-dashboard-grid { gap: 10px; }
    .ap-coverage { grid-template-columns: 1fr; justify-items: center; }
    .ap-form-grid { grid-template-columns: 1fr; }
    .ap-form-grid .is-full { grid-column: auto; }
    .ap-unit-hero { flex-direction: column; }
    .ap-unit-facts { justify-content: flex-start; }
    .ap-diagram-stage { width: 850px; }
    .ap-modal-root { align-items: stretch; padding: 0; }
    .ap-modal, .ap-modal.is-wide, .ap-modal.is-document { width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
    .ap-modal-header, .ap-modal-body { padding: 16px; }
    .ap-modal-body.ap-modal-body-flush { padding: 0; }
    .ap-modal-actions { display: grid; grid-template-columns: 1fr 1fr; padding: 10px; }
    .ap-modal-actions > * { width: 100%; }
    .ap-window-header-actions .ap-secondary-button { display: none; }
    .ap-modal.is-document .ap-explorer-grid { grid-template-columns: 1fr; overflow: auto; }
    .ap-modal.is-document .ap-explorer-grid > .ap-panel { height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .ap-modal.is-document .ap-unit-list { max-height: 280px; }
    .ap-report-grid { grid-template-columns: 1fr; }
}

@media print {
    .ap-sidebar, .ap-topbar, .ap-filter-bar, .ap-password-banner, .ap-cart-drawer, .ap-overlay { display: none !important; }
    .ap-shell { display: block; }
    .ap-workspace { height: auto; overflow: visible; }
    .ap-content { max-width: none; padding: 0; }
    .ap-panel { box-shadow: none; }
}
