:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel-border: #d8dee4;
    --text: #1f2933;
    --muted: #5f6c7b;
    --brand: #1f6feb;
    --brand-hover: #195ac4;
    --danger: #d73a49;
    --success: #1a7f37;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, #f9fbfc 0%, var(--bg) 100%);
}

body.no-scroll {
    overflow: hidden;
}

h1,
h2,
h3,
p {
    margin: 0;
}

.app-version {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #1f3c70;
    background: #e7eefb;
    border: 1px solid #c6d8f7;
    vertical-align: middle;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.muted {
    color: var(--muted);
}

.hidden {
    display: none !important;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(2px);
}

.topbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--panel-border);
    background: #fff;
    color: #364152;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.icon-btn:hover {
    color: var(--brand);
    border-color: #b6cbef;
}

.icon-btn i {
    font-size: 20px;
    line-height: 1;
}

#signOutBtn {
    color: #b42318;
    border-color: #f3c8c4;
    background: #fff7f7;
}

#signOutBtn:hover {
    color: #8f1020;
    border-color: #e6a9a2;
    background: #ffe9e7;
}

.user-pill {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--panel-border);
    font-size: 0.9rem;
    background: #fff;
}

.layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 16px;
    padding: 16px;
}

.layout.single-column {
    grid-template-columns: 1fr;
}

.subheader-panel {
    padding-top: 14px;
    padding-bottom: 14px;
}

.greeting {
    font-size: 1.2rem;
    font-weight: 400;
    font-style: italic;
}

.greeting-user {
    font-size: 1em;
    font-weight: 700;
    font-style: normal;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
}

.form-panel {
    position: sticky;
    top: 12px;
    height: fit-content;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wrap-on-mobile {
    flex-wrap: wrap;
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

label {
    font-weight: 600;
    font-size: 0.92rem;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 10px;
    font: inherit;
    background: #fff;
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid rgba(31, 111, 235, 0.2);
    border-color: var(--brand);
}

.btn {
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 9px 12px;
    cursor: pointer;
    font: inherit;
}

.btn.primary {
    background: var(--brand);
    color: #fff;
}

.btn.primary:hover {
    background: var(--brand-hover);
}

.btn.secondary {
    background: #e7eefb;
    color: #1f3c70;
}

.btn.ghost {
    border-color: var(--panel-border);
    background: #fff;
}

.btn.danger {
    background: #fde8ea;
    color: #8f1020;
}

.btn.tiny {
    padding: 6px 10px;
    font-size: 0.86rem;
}

.btn-icon-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
}

.btn-icon-only i {
    font-size: 1rem;
    line-height: 1;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(0.15);
}

.view-switch {
    display: flex;
    gap: 6px;
}

.view-switch .active {
    border-color: var(--brand);
    color: var(--brand);
    background: #fff;
}

.inline-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.inline-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 8px;
}

.subsection {
    margin-top: 12px;
    border-top: 1px solid var(--panel-border);
    padding-top: 10px;
}

.subsection.no-top-border {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.fields-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.field-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 10px;
    background: #fafcff;
}

.field-row .remove-field-btn {
    align-self: flex-end;
}

.field-main-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.field-main-row .field-name-input,
.field-main-row .field-value-input {
    flex: 1;
}

.field-meta-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.field-type-select {
    flex: 1;
}

.field-meta-row .remove-field-btn {
    flex: 0 0 auto;
    min-width: 90px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

#cardsView,
#tableView {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 0;
}

#cardsView,
#tableView:not(.hidden) {
    margin-top: 2px;
}

.links-section {
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 12px;
    background: #fcfdff;
}

.links-section h3 {
    font-size: 1rem;
    color: #334155;
}

.group-host {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.group-launcher {
    width: 100%;
    border: 1px solid #c8d5e6;
    background: #f8fbff;
    color: #0f2742;
    text-align: left;
    padding: 11px 12px;
    border-radius: 10px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.group-launcher:hover {
    border-color: #97b7e4;
    background: #eef5ff;
}

.group-panel {
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 10px;
    background: #fff;
}

.group-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid #ecf1f7;
    padding-bottom: 8px;
}

.group-panel-head h4 {
    margin: 0;
    font-size: 1rem;
    color: #162b46;
}

.group-panel-body {
    margin-top: 10px;
}

.inline-actions.compact {
    margin-top: 0;
}

.favorite-card {
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
}

.card-head {
    display: flex;
    gap: 10px;
    align-items: center;
}

.card-title-inline,
.table-title-inline {
    /*display: inline-flex;*/
    align-items: center;
    gap: 8px;
}

.shared-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    width: 22px;
    height: 22px;
    padding: 0;
}

.shared-badge-view {
    color: #2c6fa4;
    background: #edf6ff;
    border: 1px solid #cce4fb;
}

.shared-badge-modify {
    color: #0f4c81;
    background: #d8ecff;
    border: 1px solid #9ecbf3;
}

.shared-badge i {
    font-size: 13px;
    line-height: 1;
}

.favicon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid #e3e8ef;
}

.fields-card-table-wrap {
    margin-top: 10px;
}

.inner-fields-table {
    width: 100%;
    border-collapse: collapse;
    min-width: auto;
}

.inner-fields-table td {
    padding: 8px;
    border: 0;
}

.inner-fields-table tr td + td {
    border-left: 1px solid var(--panel-border);
}

.inner-fields-table tr + tr td {
    border-top: 1px solid var(--panel-border);
}

.small {
    font-size: 0.88rem;
}

.copy-field-btn.copied {
    background: #daf5e4;
    border-color: #80d8a4;
    color: #165f30;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    border-bottom: 1px solid var(--panel-border);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

.alert {
    margin-top: 10px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid transparent;
}

.alert.error {
    background: #fdecec;
    color: #9a1321;
    border-color: #f5c2c7;
}

.alert.success {
    background: #eaf7ee;
    color: #1a7f37;
    border-color: #b7ebc4;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.login-wrapper {
    width: min(460px, 92vw);
}

.login-wrapper.wide {
    width: min(980px, 96vw);
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 12px;
}

.login-card {
    background: #fff;
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    padding: 20px;
}

.login-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 14px;
    padding: 4px;
    background: #eef2f7;
    border-radius: 10px;
}

.login-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    padding: 9px 10px;
    cursor: pointer;
    font-weight: 600;
    color: var(--muted);
}

.login-tab.active {
    background: #fff;
    color: var(--brand);
    box-shadow: 0 1px 5px rgba(15, 23, 42, 0.1);
}

.tab-icon {
    font-size: 16px;
    line-height: 1;
    flex: 0 0 auto;
}

.tab-panel {
    margin-top: 12px;
}

.tab-panel.tab-anim {
    animation: tabReveal 220ms ease;
}

@keyframes tabReveal {
    from {
        opacity: 0;
        transform: translateY(4px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.hint {
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
}

.modal-panel {
    position: relative;
    z-index: 1;
    width: min(780px, 95vw);
    max-height: 90vh;
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.modal-panel-small {
    width: min(640px, 94vw);
}

.fields-modal-body {
    margin-top: 12px;
}

.account-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 12px;
}

.account-section {
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 12px;
    background: #fbfcfe;
}

.account-section h3 {
    margin-bottom: 8px;
}

.account-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 4px;
    border-radius: 10px;
    background: #eef2f7;
}

.account-tab {
    border: 0;
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.account-tab.active {
    background: #fff;
    color: var(--brand);
    box-shadow: 0 1px 5px rgba(15, 23, 42, 0.1);
}

.account-tab-panel {
    margin-top: 10px;
}

.danger-guard-grid {
    display: grid;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 10px;
}

.danger-captcha-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.danger-captcha-row input {
    flex: 1;
}

.modal-form-grid {
    display: grid;
    grid-template-columns: minmax(300px, 1fr) minmax(260px, 0.9fr);
    gap: 14px;
    margin-top: 10px;
}

.modal-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.share-table-wrap {
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
}

.share-table {
    min-width: 100%;
    border-collapse: collapse;
}

.share-table th,
.share-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--panel-border);
    text-align: left;
}

.share-table th {
    font-size: 0.85rem;
    color: var(--muted);
    background: #f5f8fc;
}

.share-table tr:last-child td {
    border-bottom: 0;
}

.share-permission-select {
    min-width: 170px;
}

.share-owner-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 0.75rem;
    color: #0f766e;
    background: #ccfbf1;
}


.groups-table-wrap {
    margin-top: 8px;
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: #f9fbfe;
}

.groups-table {
    min-width: 100%;
    border-collapse: collapse;
}

.groups-table th,
.groups-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--panel-border);
    text-align: left;
    vertical-align: middle;
}

.groups-table th {
    font-size: 0.85rem;
    color: var(--muted);
    background: #f5f8fc;
}

.groups-table tr:last-child td {
    border-bottom: 0;
}

.groups-name-cell {
    font-weight: 600;
    color: #1f2937;
}

.groups-actions-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.groups-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #334155;
}

.groups-order-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.group-order-icon-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.group-order-icon-btn i {
    font-size: 14px;
    line-height: 1;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .form-panel {
        position: static;
    }

    .field-row {
        grid-template-columns: 1fr;
    }

    .login-wrapper.wide {
        grid-template-columns: 1fr;
    }

    .modal-form-grid {
        grid-template-columns: 1fr;
    }

    .field-main-row,
    .field-meta-row {
        flex-direction: column;
        align-items: stretch;
    }
}
