* { box-sizing: border-box; }
html, body.owa-body { height: 100%; margin: 0; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: #f5f5f5;
    color: #242424;
}

/* —— Outlook shell —— */
.owa-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
}

.owa-header {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 48px;
    padding: 0 16px;
    background: #0f6cbd;
    color: #fff;
    flex-shrink: 0;
}

.owa-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 120px;
}

.owa-logo {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: linear-gradient(135deg, #0078d4, #00bcf2);
    display: inline-block;
}

.owa-logo-text {
    font-weight: 600;
    font-size: 15px;
}

.owa-search {
    flex: 1;
    max-width: 560px;
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid transparent;
}
.owa-search:focus-within {
    border-color: #92c5f7;
    box-shadow: 0 0 0 1px #92c5f7;
}
.owa-search input[type="search"] {
    flex: 1;
    border: none;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
    min-width: 0;
}
.owa-search-btn {
    border: none;
    background: #f0f0f0;
    color: #242424;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
}
.owa-search-btn:hover { background: #e0e0e0; }

.owa-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.owa-icon-btn {
    color: #fff;
    text-decoration: none;
    font-size: 18px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.owa-icon-btn:hover, .owa-icon-btn.active {
    background: rgba(255,255,255,.15);
}

.owa-account-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
    padding: 4px 8px 4px 4px;
    border-radius: 4px;
}
.owa-account-chip:hover { background: rgba(255,255,255,.12); }
.owa-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #004578;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}
.owa-account-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    font-size: 12px;
}
.owa-account-meta strong { font-size: 13px; font-weight: 600; }

.owa-main {
    display: flex;
    flex: 1;
    min-height: 0;
}

.owa-nav {
    width: 220px;
    flex-shrink: 0;
    background: #f0f0f0;
    border-right: 1px solid #e0e0e0;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.owa-new-mail {
    display: block;
    text-align: center;
    padding: 8px 12px;
    margin: 4px 8px 8px;
    background: #0f6cbd;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
}
.owa-new-mail:hover { background: #115ea3; }

.owa-folders {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.owa-folder {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 4px;
    color: #242424;
    text-decoration: none;
    font-size: 14px;
}
.owa-folder:hover { background: #e8e8e8; }
.owa-folder.is-active {
    background: #cce4f7;
    font-weight: 600;
}

.owa-folder-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: .85;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.icon-inbox { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%230f6cbd' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h16v2H4V4zm2 4h12l2 4v8H4v-8l2-4zm0 2.2L4.8 12h14.4L18 10.2H6z'/%3E%3C/svg%3E"); }
.icon-junk { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23a4262c' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l1.5 4.5H18l-3.8 2.8 1.5 4.5L12 11 8.3 13.8l1.5-4.5L6 6.5h4.5L12 2z'/%3E%3C/svg%3E"); }
.icon-archive { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23605e5c' viewBox='0 0 24 24'%3E%3Cpath d='M4 5h16v3H4V5zm2 5h12v9H6v-9zm2 2v5h8v-5H8z'/%3E%3C/svg%3E"); }
.icon-drafts { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%230078d4' viewBox='0 0 24 24'%3E%3Cpath d='M5 4h11l5 5v11H5V4zm11 1.5V9h4.5L16 5.5z'/%3E%3C/svg%3E"); }
.icon-sent { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23107810' viewBox='0 0 24 24'%3E%3Cpath d='M2 21l21-9L2 3v7l15 2-15 2v7z'/%3E%3C/svg%3E"); }
.icon-deleted { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23605e5c' viewBox='0 0 24 24'%3E%3Cpath d='M9 3h6l1 2h5v2H3V5h5l1-2zm1 6h2v9h-2V9zm4 0h2v9h-2V9zM7 9h2v9H7V9z'/%3E%3C/svg%3E"); }
.icon-onedrive { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%230078d4' viewBox='0 0 24 24'%3E%3Cpath d='M10 16l-1.5-2H4a4 4 0 118.1-2.2A3.5 3.5 0 1118 14h-5.6L10 16z'/%3E%3C/svg%3E"); }
.owa-folder-app { margin-top: 12px; border-top: 1px solid #e0e0e0; padding-top: 8px; }
.onedrive-wrap { padding: 0 0 24px; }

.owa-folder-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.owa-folder-unread {
    font-size: 12px;
    font-weight: 600;
    color: #0f6cbd;
    min-width: 20px;
    text-align: right;
}

.owa-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
    overflow: auto;
}

/* Toolbar di atas daftar pesan */
.owa-list-toolbar {
    padding: 12px 20px;
    border-bottom: 1px solid #edebe9;
    display: flex;
    align-items: center;
    gap: 12px;
}
.owa-list-toolbar h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    flex: 1;
}

/* Daftar pesan seperti Outlook */
.owa-message-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.owa-message-row {
    display: grid;
    grid-template-columns: minmax(120px, 22%) minmax(0, 1fr) 72px;
    gap: 12px;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}
.owa-message-row:hover { background: #f5f5f5; }
.owa-message-row.unread { background: #f0f6fc; font-weight: 600; }
.owa-message-row.unread:hover { background: #e8f2fb; }

.owa-msg-from {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}
.owa-msg-subject-wrap {
    min-width: 0;
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-size: 14px;
}
.owa-msg-subject {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
    max-width: 45%;
}
.owa-msg-preview {
    color: #616161;
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    font-size: 13px;
}
.owa-message-row.unread .owa-msg-preview { color: #424242; }
.owa-msg-date {
    text-align: right;
    font-size: 13px;
    color: #616161;
    font-weight: 400;
}
.owa-attach { font-size: 12px; opacity: .8; }

.owa-empty {
    padding: 48px 24px;
    text-align: center;
    color: #616161;
}

/* Read pane */
.owa-read {
    padding: 20px 28px 40px;
    max-width: 960px;
}
.owa-read h1 {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 12px;
}
.owa-read-meta {
    font-size: 14px;
    color: #616161;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #edebe9;
}
.owa-read-actions {
    margin-bottom: 16px;
}
.owa-read-actions a {
    color: #0f6cbd;
    text-decoration: none;
    font-size: 14px;
}
.owa-read-actions a:hover { text-decoration: underline; }
.msg-body {
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
}

/* Compose */
.owa-compose {
    padding: 20px 28px 40px;
    max-width: 900px;
}
.owa-compose h1 {
    font-size: 20px;
    margin: 0 0 16px;
}

/* Settings */
.owa-settings {
    padding: 24px 28px 40px;
    max-width: 720px;
}
.owa-settings-wide { max-width: 960px; }
.owa-settings h1 {
    font-size: 20px;
    margin: 0 0 8px;
}
.owa-settings .intro {
    color: #616161;
    font-size: 14px;
    margin-bottom: 24px;
}

.settings-section {
    border: 1px solid #edebe9;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
    background: #fafafa;
}
.settings-section h2 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
}

.settings-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid #edebe9;
}
.settings-tab {
    padding: 10px 16px;
    text-decoration: none;
    color: #424242;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.settings-tab:hover { color: #0f6cbd; }
.settings-tab.is-active {
    color: #0f6cbd;
    font-weight: 600;
    border-bottom-color: #0f6cbd;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
}

.rules-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.rules-table th,
.rules-table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid #edebe9;
    vertical-align: top;
}
.rules-table tr.rule-disabled { opacity: .65; }
.rules-actions {
    white-space: nowrap;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}
.inline-form { display: inline; margin: 0; }
.settings-footer-actions { margin-top: 20px; display: flex; gap: 8px; flex-wrap: wrap; }
.rules-script-note { margin: 12px 0 20px; }

/* Forms & buttons */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="datetime-local"],
.form-group select,
.form-group textarea {
    width: 100%;
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid #8a8886;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}
.form-group textarea { min-height: 120px; resize: vertical; }
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.form-check label { font-weight: 400; margin: 0; }

.btn {
    display: inline-block;
    padding: 8px 16px;
    background: #0f6cbd;
    color: #fff !important;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none !important;
    font-size: 14px;
    font-family: inherit;
}
.btn:hover { background: #115ea3; }
.btn-secondary { background: #fff; color: #242424 !important; border: 1px solid #8a8886; }
.btn-secondary:hover { background: #f5f5f5; }
.btn-danger { background: #a4262c; }
.btn-small { padding: 6px 12px; font-size: 13px; }

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin: 12px 20px;
    font-size: 14px;
}
.alert-error { background: #fde7e9; color: #a4262c; border: 1px solid #f1aeb5; }
.alert-success { background: #dff6dd; color: #107c10; border: 1px solid #9fd89f; }

/* Accounts (simple page) */
.page-simple { background: #f5f5f5; min-height: 100vh; }
.simple-wrap {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}
.simple-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.simple-header a.brand-link {
    color: #0f6cbd;
    text-decoration: none;
    font-weight: 600;
}
.card {
    background: #fff;
    border: 1px solid #edebe9;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 16px;
}
.card h1 { margin: 0 0 12px; font-size: 22px; }
.meta { color: #616161; font-size: 13px; }

.account-list { list-style: none; padding: 0; margin: 0; }
.account-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}
.account-list .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
    font-size: 11px;
    background: #e0e0e0;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 4px;
}

@media (max-width: 768px) {
    .owa-nav { width: 56px; padding: 8px 4px; }
    .owa-folder-label, .owa-folder-unread, .owa-new-mail { font-size: 0; padding: 8px; }
    .owa-new-mail { margin: 4px; }
    .owa-message-row {
        grid-template-columns: 1fr 64px;
        grid-template-rows: auto auto;
    }
    .owa-msg-from { grid-column: 1 / -1; font-size: 13px; }
    .owa-account-meta { display: none; }
}